Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions tools/build_patched_ipa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
# --framework <Mach-O basename, e.g. UnityFramework> \
# --dylib <path/to/Payload.dylib> \
# --input <clean.ipa> \
# [--output <out.ipa>]
# [--output <out.ipa>] \
# [--bundle-id-suffix <suffix>]
#
# The script never distributes the input IPA itself — the operator
# supplies one.
Expand All @@ -50,6 +51,12 @@ Usage: build_patched_ipa.sh --recipe NAME --framework BASENAME --dylib PATH --in
NOT distribute the IPA itself).
--output IPA Optional; defaults to packages/ipa/<basename-of-input>-patched.ipa
(e.g. Kiou-1.0.1.ipa -> packages/ipa/Kiou-1.0.1-patched.ipa).
--bundle-id-suffix SUFFIX
Optional; if non-empty, append ".<SUFFIX>" to the
Info.plist CFBundleIdentifier so the patched IPA
installs alongside the original app instead of
overwriting it (e.g. "chinlan" turns
com.acme.app into com.acme.app.chinlan).
EOF
exit 64
}
Expand All @@ -59,16 +66,18 @@ FRAMEWORK=""
DYLIB_SRC=""
INPUT_IPA=""
OUTPUT_IPA=""
BUNDLE_ID_SUFFIX=""

while [ $# -gt 0 ]; do
case "$1" in
--recipe) RECIPE="$2"; shift 2;;
--framework) FRAMEWORK="$2"; shift 2;;
--dylib) DYLIB_SRC="$2"; shift 2;;
--input) INPUT_IPA="$2"; shift 2;;
--output) OUTPUT_IPA="$2"; shift 2;;
-h|--help) usage;;
*) echo "error: unknown argument: $1" >&2; usage;;
--recipe) RECIPE="$2"; shift 2;;
--framework) FRAMEWORK="$2"; shift 2;;
--dylib) DYLIB_SRC="$2"; shift 2;;
--input) INPUT_IPA="$2"; shift 2;;
--output) OUTPUT_IPA="$2"; shift 2;;
--bundle-id-suffix) BUNDLE_ID_SUFFIX="$2"; shift 2;;
-h|--help) usage;;
*) echo "error: unknown argument: $1" >&2; usage;;
esac
done

Expand Down Expand Up @@ -243,6 +252,29 @@ echo "==> verifying LC_LOAD_DYLIB (recipe: $RECIPE)"
echo "==> patching Info.plist (recipe: $RECIPE)"
"$PY" -m tools.patch_plist --recipe "$RECIPE" "$INFO_PLIST"

# Optional CFBundleIdentifier rewrite so the patched IPA can live
# side-by-side with the original app instead of overwriting it. Skipped
# when --bundle-id-suffix is empty (the default), so the pipeline stays
# a no-op for the "overwrite the original" workflow.
if [ -n "$BUNDLE_ID_SUFFIX" ]; then
ORIGINAL_BUNDLE_ID="$("$PY" -c "import plistlib,sys; print(plistlib.load(open(sys.argv[1],'rb')).get('CFBundleIdentifier',''))" "$INFO_PLIST")"
if [ -z "$ORIGINAL_BUNDLE_ID" ]; then
echo "error: Info.plist has no CFBundleIdentifier to append suffix to" >&2
exit 1
fi
# Idempotent: if the suffix is already present, don't append it twice.
case "$ORIGINAL_BUNDLE_ID" in
*".$BUNDLE_ID_SUFFIX")
echo "==> CFBundleIdentifier already carries suffix .$BUNDLE_ID_SUFFIX — skipping rewrite"
;;
*)
NEW_BUNDLE_ID="${ORIGINAL_BUNDLE_ID}.${BUNDLE_ID_SUFFIX}"
echo "==> rewriting CFBundleIdentifier: $ORIGINAL_BUNDLE_ID -> $NEW_BUNDLE_ID"
"$PY" -m tools.patch_plist --set "CFBundleIdentifier=${NEW_BUNDLE_ID}" "$INFO_PLIST"
;;
esac
fi

# ---------------------------------------------------------------------------
# 4. inject dylib
# ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading