From 328221ff64106540fb0f3c039939dc0879b83beb Mon Sep 17 00:00:00 2001 From: tkgstrator Date: Thu, 9 Jul 2026 00:59:27 +0000 Subject: [PATCH] feat(tools): fall back to main-executable when framework is absent build_patched_ipa.sh assumed the hook target lived at `Payload/.app/Frameworks/.framework/`, which works for Unity-style consumers (KiouEditor, KiouKifExporter) whose hook sites are in UnityFramework but breaks for pure Swift / Objective-C apps whose hook sites live directly in the CFBundle executable. When --framework points at a Mach-O that doesn't exist under Frameworks/ but does exist at the .app root, treat it as the main executable instead. Existing Unity consumers see no behaviour change (their framework path exists, so the fallback branch is never taken). PiyoShot (targeting PiyoShogi.app/PiyoShogi) is the first consumer of the new path. Co-Authored-By: Claude Opus 4.7 --- tools/build_patched_ipa.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/build_patched_ipa.sh b/tools/build_patched_ipa.sh index 8ac2422..0782692 100755 --- a/tools/build_patched_ipa.sh +++ b/tools/build_patched_ipa.sh @@ -192,12 +192,36 @@ fi APP_NAME="$(basename "$APP_DIR")" echo "==> found bundle: $APP_NAME" +# Target Mach-O resolution. +# +# Two consumer shapes are supported: +# +# 1. Unity-style app whose hook sites live in a Frameworks binary +# (e.g. UnityFramework). Path convention: +# Payload/.app/Frameworks/.framework/ +# +# 2. Swift / Objective-C app whose hook sites live directly in the +# main executable (i.e. --framework is the CFBundleExecutable +# basename). Path convention: +# Payload/.app/ +# +# Try (1) first; fall back to (2) if the framework path is missing but +# the main-executable path exists. Only one of the two should exist for +# any given consumer, so there is no ambiguity. FRAMEWORK_BIN="$APP_DIR/Frameworks/${FRAMEWORK}.framework/${FRAMEWORK}" +MAIN_EXE_BIN="$APP_DIR/${FRAMEWORK}" INFO_PLIST="$APP_DIR/Info.plist" if [ ! -f "$FRAMEWORK_BIN" ]; then - echo "error: framework Mach-O missing at $FRAMEWORK_BIN" >&2 - exit 1 + if [ -f "$MAIN_EXE_BIN" ]; then + FRAMEWORK_BIN="$MAIN_EXE_BIN" + echo "==> target is main executable: ${APP_NAME%.app}/${FRAMEWORK}" + else + echo "error: target Mach-O missing." >&2 + echo " looked for framework at: $FRAMEWORK_BIN" >&2 + echo " looked for main exe at: $MAIN_EXE_BIN" >&2 + exit 1 + fi fi if [ ! -f "$INFO_PLIST" ]; then echo "error: Info.plist missing at $INFO_PLIST" >&2