Skip to content

Commit fe972c0

Browse files
authored
feat: add share extension (#23)
1 parent c3eae01 commit fe972c0

File tree

5 files changed

+106
-21
lines changed

5 files changed

+106
-21
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ on:
1717
default: false
1818
description: "This is a TestFlight build"
1919
type: boolean
20-
add_extension:
20+
add_extensions:
2121
default: true
22-
description: "Include OpenInDiscord"
22+
description: "Include extensions (OpenInDiscord & ShareToDiscord)"
2323
type: boolean
2424
workflow_call:
2525
inputs:
@@ -32,7 +32,7 @@ on:
3232
is_testflight:
3333
default: false
3434
type: boolean
35-
add_extension:
35+
add_extensions:
3636
default: true
3737
type: boolean
3838
caller_workflow:
@@ -187,24 +187,57 @@ jobs:
187187
go build -o patcher
188188
./patcher -i ../discord.ipa -o ../patched.ipa
189189
190-
- name: Build Safari Extension
191-
if: inputs.add_extension == true
190+
- name: Update ShareToDiscord Info.plist
191+
if: inputs.add_extensions == true
192192
run: |
193+
INFO_PLIST="extensions/ShareToDiscord/Share/Info.plist"
194+
/usr/libexec/PlistBuddy -c "Set :URLScheme unbound" "$INFO_PLIST" 2>/dev/null || \
195+
/usr/libexec/PlistBuddy -c "Add :URLScheme string unbound" "$INFO_PLIST"
196+
echo "Updated ShareToDiscord Info.plist - Changed URLScheme to 'unbound'"
197+
198+
- name: Build Extensions
199+
if: inputs.add_extensions == true
200+
run: |
201+
if [ ${{ inputs.is_testflight }} == true ]; then
202+
SAFARI_EXT_BUNDLE_ID="com.hammerandchisel.discord.testflight.OpenInDiscord"
203+
SHARE_EXT_BUNDLE_ID="com.hammerandchisel.discord.testflight.Share"
204+
else
205+
SAFARI_EXT_BUNDLE_ID="com.hammerandchisel.discord.OpenInDiscord"
206+
SHARE_EXT_BUNDLE_ID="com.hammerandchisel.discord.Share"
207+
fi
208+
193209
cd extensions/OpenInDiscord
194210
xcodebuild build \
195211
-target "OpenInDiscord Extension" \
196212
-configuration Release \
197213
-sdk iphoneos \
198214
CONFIGURATION_BUILD_DIR="build" \
199215
PRODUCT_NAME="OpenInDiscord" \
200-
PRODUCT_BUNDLE_IDENTIFIER="com.hammerandchisel.discord.OpenInDiscord" \
216+
PRODUCT_BUNDLE_IDENTIFIER="$SAFARI_EXT_BUNDLE_ID" \
201217
PRODUCT_MODULE_NAME="OpenInDiscordExt" \
202218
SKIP_INSTALL=NO \
203219
DEVELOPMENT_TEAM="" \
204220
CODE_SIGN_IDENTITY="" \
205221
CODE_SIGNING_REQUIRED=NO \
206222
CODE_SIGNING_ALLOWED=NO \
207223
ONLY_ACTIVE_ARCH=NO | xcbeautify
224+
225+
cd ../ShareToDiscord
226+
xcodebuild build \
227+
-target "Share" \
228+
-configuration Release \
229+
-sdk iphoneos \
230+
CONFIGURATION_BUILD_DIR="build" \
231+
PRODUCT_NAME="Share" \
232+
PRODUCT_BUNDLE_IDENTIFIER="$SHARE_EXT_BUNDLE_ID" \
233+
PRODUCT_MODULE_NAME="Share" \
234+
SKIP_INSTALL=NO \
235+
DEVELOPMENT_TEAM="" \
236+
CODE_SIGN_IDENTITY="" \
237+
CODE_SIGNING_REQUIRED=NO \
238+
CODE_SIGNING_ALLOWED=NO \
239+
ONLY_ACTIVE_ARCH=NO | xcbeautify
240+
cd ../../
208241
209242
- name: Extract app name
210243
run: |
@@ -214,13 +247,13 @@ jobs:
214247
- name: Install cyan
215248
run: pip install --force-reinstall https://github.com/asdfzxcvbn/pyzule-rw/archive/main.zip Pillow
216249

217-
- name: Inject tweak (and extension)
250+
- name: Inject tweak (and extensions)
218251
run: |
219-
if [ ${{ inputs.add_extension }} == true ]; then
252+
if [ ${{ inputs.add_extensions }} == true ]; then
220253
if [ ${{ inputs.is_testflight }} == true ]; then
221-
cyan -duwsgq -b "com.hammerandchisel.discord.testflight" -i discord.ipa -o ${{ env.APP_NAME }}.ipa -f *.deb extensions/OpenInDiscord/build/OpenInDiscord.appex
254+
cyan -duwsgq -b "com.hammerandchisel.discord.testflight" -i discord.ipa -o ${{ env.APP_NAME }}.ipa -f *.deb extensions/OpenInDiscord/build/OpenInDiscord.appex extensions/ShareToDiscord/build/Share.appex
222255
else
223-
cyan -duwsgq -i patched.ipa -o ${{ env.APP_NAME }}.ipa -f *.deb extensions/OpenInDiscord/build/OpenInDiscord.appex
256+
cyan -duwsgq -i patched.ipa -o ${{ env.APP_NAME }}.ipa -f *.deb extensions/OpenInDiscord/build/OpenInDiscord.appex extensions/ShareToDiscord/build/Share.appex
224257
fi
225258
else
226259
if [ ${{ inputs.is_testflight }} == true ]; then

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "extensions/OpenInDiscord"]
55
path = extensions/OpenInDiscord
66
url = https://github.com/castdrian/OpenInDiscord
7+
[submodule "extensions/ShareToDiscord"]
8+
path = extensions/ShareToDiscord
9+
url = https://github.com/castdrian/ShareToDiscord

build-local.sh

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ fi
5757

5858
USE_EXTENSION=0
5959
if [ "$UNAME" = "Darwin" ]; then
60-
print_status "Include Safari extension? (y/n):"
61-
read -t 3 SAFARI_INPUT
60+
print_status "Include extensions? (y/n):"
61+
read -t 3 EXTENSIONS_INPUT
6262
if [ $? -gt 128 ]; then
6363
echo "y"
6464
USE_EXTENSION=1
65-
print_status "Including Safari extension... (default)"
66-
elif [[ $SAFARI_INPUT =~ ^[Nn]$ ]]; then
65+
print_status "Including extensions... (default)"
66+
elif [[ $EXTENSIONS_INPUT =~ ^[Nn]$ ]]; then
6767
USE_EXTENSION=0
68-
print_status "Skipping Safari extension..."
68+
print_status "Skipping extensions..."
6969
else
7070
USE_EXTENSION=1
71-
print_status "Including Safari extension..."
71+
print_status "Including extensions..."
7272
fi
7373
fi
7474

@@ -147,8 +147,9 @@ if [ $? -ne 0 ]; then
147147
fi
148148
print_success "Patched ipa"
149149

150-
SAFARI_EXT=""
150+
EXTENSIONS=""
151151
if [ "$USE_EXTENSION" = "1" ] && [ "$UNAME" = "Darwin" ]; then
152+
# OpenInDiscord Extension
152153
SAFARI_EXT="extensions/OpenInDiscord/build/OpenInDiscord.appex"
153154

154155
if [ ! -f "$SAFARI_EXT" ]; then
@@ -168,7 +169,7 @@ if [ "$USE_EXTENSION" = "1" ] && [ "$UNAME" = "Darwin" ]; then
168169
CODE_SIGN_IDENTITY="" \
169170
CODE_SIGNING_REQUIRED=NO \
170171
CODE_SIGNING_ALLOWED=NO \
171-
ONLY_ACTIVE_ARCH=NO
172+
ONLY_ACTIVE_ARCH=NO | xcbeautify
172173
cd ../..
173174

174175
if [ $? -ne 0 ]; then
@@ -179,6 +180,53 @@ if [ "$USE_EXTENSION" = "1" ] && [ "$UNAME" = "Darwin" ]; then
179180
else
180181
print_status "Using existing Safari extension..."
181182
fi
183+
184+
EXTENSIONS="$SAFARI_EXT"
185+
186+
# ShareToDiscord Extension
187+
SHARE_EXT="extensions/ShareToDiscord/build/Share.appex"
188+
189+
# Update the Info.plist to change URLScheme from 'discord' to 'unbound'
190+
print_status "Updating ShareToDiscord Info.plist..."
191+
INFO_PLIST_PATH="extensions/ShareToDiscord/Share/Info.plist"
192+
if [ -f "$INFO_PLIST_PATH" ]; then
193+
/usr/libexec/PlistBuddy -c "Set :URLScheme unbound" "$INFO_PLIST_PATH" 2>/dev/null || \
194+
/usr/libexec/PlistBuddy -c "Add :URLScheme string unbound" "$INFO_PLIST_PATH"
195+
print_success "Updated ShareToDiscord Info.plist"
196+
else
197+
print_error "ShareToDiscord Info.plist not found at $INFO_PLIST_PATH"
198+
fi
199+
200+
if [ ! -f "$SHARE_EXT" ]; then
201+
print_status "Building Share extension..."
202+
mkdir -p extensions/ShareToDiscord/build
203+
cd extensions/ShareToDiscord
204+
xcodebuild build \
205+
-target "Share" \
206+
-configuration Release \
207+
-sdk iphoneos \
208+
CONFIGURATION_BUILD_DIR="build" \
209+
PRODUCT_NAME="Share" \
210+
PRODUCT_BUNDLE_IDENTIFIER="com.hammerandchisel.discord.Share" \
211+
PRODUCT_MODULE_NAME="Share" \
212+
SKIP_INSTALL=NO \
213+
DEVELOPMENT_TEAM="" \
214+
CODE_SIGN_IDENTITY="" \
215+
CODE_SIGNING_REQUIRED=NO \
216+
CODE_SIGNING_ALLOWED=NO \
217+
ONLY_ACTIVE_ARCH=NO | xcbeautify
218+
cd ../..
219+
220+
if [ $? -ne 0 ]; then
221+
print_error "Failed to build Share extension"
222+
exit 1
223+
fi
224+
print_success "Built Share extension"
225+
else
226+
print_status "Using existing Share extension..."
227+
fi
228+
229+
EXTENSIONS="$EXTENSIONS $SHARE_EXT"
182230
fi
183231

184232
if [ ! -d "venv" ] || [ ! -f "venv/bin/cyan" ]; then
@@ -201,8 +249,8 @@ fi
201249
DEB_FILE=$(find packages -maxdepth 1 -name "*.deb" -print -quit)
202250

203251
print_status "Injecting tweak..."
204-
if [ "$USE_EXTENSION" = "1" ] && [ -n "$SAFARI_EXT" ]; then
205-
cyan -duwsgq -i "$TEMP_PATCHED_IPA" -o "$OUTPUT_IPA" -f "$DEB_FILE" "$SAFARI_EXT"
252+
if [ "$USE_EXTENSION" = "1" ] && [ -n "$EXTENSIONS" ]; then
253+
cyan -duwsgq -i "$TEMP_PATCHED_IPA" -o "$OUTPUT_IPA" -f "$DEB_FILE" $EXTENSIONS
206254
else
207255
cyan -duwsgq -i "$TEMP_PATCHED_IPA" -o "$OUTPUT_IPA" -f "$DEB_FILE"
208256
fi

control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: Unbound
22
Description: Discord mobile client aimed at providing the user control, stability and customizability.
3-
Version: 1.3.0
3+
Version: 1.4.0
44
Package: app.unbound.ios
55
Architecture: iphoneos-arm
66
Maintainer: eternal, acquitelol, Adrian Castro

extensions/ShareToDiscord

Submodule ShareToDiscord added at a69cc8e

0 commit comments

Comments
 (0)