Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Fix the UnboundLocalError every app build hit: work before out_ipa (PR #15)
LNPANDYbaf9647383eb
diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.pyindex 3250a6d8..de012350 100755--- a/scripts/build_ipa_from_nsp.py+++ b/scripts/build_ipa_from_nsp.py@@ -1793,10 +1793,12 @@ def main(args=None):if alias and not derived: derived = f'title {app:016X} is not game profile {g.id}\'s title {g.title_id:016X}'if derived: say(f'{derived}: packing {pkg_ver} from a profile derived from it')versions = [pkg_ver] if derived else need + ([pkg_ver] if pkg_ver not in need else [])+ work = Path(os.path.expanduser(args.work_dir)).resolve() if args.work_dir else nsp_dir / f'{g.id}_build' # the folder holding the NSPs by default; --work-dir puts the build elsewhere+ # out_ipa reads `work`, so `work` must be assigned first (upstream's order had them the other+ # way round; the --work-dir patch moved `work` up here and this line had to follow it).out_ipa = Path(os.path.expanduser(args.out or OUT_IPA)).resolve() if (args.out or OUT_IPA) else work.parent / g.get('ipa') # by default next to the NSPs and <id>_build/if shadowed and not (args.out or OUT_IPA): out_ipa = out_ipa.with_name(out_ipa.stem + '-provisional.ipa') # never over the IPA of the game's real profileif mac_pack and (args.out or OUT_IPA) and out_ipa.suffix != '.app': raise BuildError(f'the Mac app (-o / OUT_IPA) must end in .app: {out_ipa}')- work = Path(os.path.expanduser(args.work_dir)).resolve() if args.work_dir else nsp_dir / f'{g.id}_build' # the folder holding the NSPs by default; --work-dir puts the build elsewhereproject = work / 'xcode/DmIOS.xcodeproj'workspace = Path(os.path.expanduser(args.xcode_workspace or XCODE_WORKSPACE)).resolve() if (args.xcode_workspace or XCODE_WORKSPACE) else nsp_dir.parent / 'NxNative.xcworkspace'if prepare_xcode and workspace.suffix != '.xcworkspace': raise BuildError('--xcode-workspace must end in .xcworkspace')diff --git a/scripts/sync_upstream.py b/scripts/sync_upstream.pyindex 3ed1e46f..93119ef0 100644--- a/scripts/sync_upstream.py+++ b/scripts/sync_upstream.py@@ -353,12 +353,20 @@ def patch_nsp(t):# Two separate one-line anchors: upstream inserts lines between them whenever it adds a check# (ffcd910 put a mac_pack check right above `work`), which broke the old three-line anchor and# stopped the daily sync for two days (issue #13). `work` and that out_ipa line each appear once.- P.append(('work-dir work', 'args.work_dir', [(+ # One replacement for both lines: `out_ipa` reads `work`, so patching them separately let the+ # out_ipa patch land above the work patch (issue: PR #15, an UnboundLocalError on every build+ # without -o). The anchor covers upstream's three-line block and puts work first.+ P.append(('work-dir paths', 'args.work_dir', [(+ " out_ipa = Path(os.path.expanduser(args.out or OUT_IPA)).resolve() if (args.out or OUT_IPA) else nsp_dir / g.get('ipa') # by default in the NSP folder, next to the NSPs and <id>_build/\n"+ " if shadowed and not (args.out or OUT_IPA): out_ipa = out_ipa.with_name(out_ipa.stem + '-provisional.ipa') # never over the IPA of the game's real profile\n"+ " if mac_pack and (args.out or OUT_IPA) and out_ipa.suffix != '.app': raise BuildError(f'the Mac app (-o / OUT_IPA) must end in .app: {out_ipa}')\n"" work = nsp_dir / f'{g.id}_build'",- " work = Path(os.path.expanduser(args.work_dir)).resolve() if args.work_dir else nsp_dir / f'{g.id}_build' # the folder holding the NSPs by default; --work-dir puts the build elsewhere")]))- P.append(('work-dir out_ipa', 'work.parent / g.get', [(- " out_ipa = Path(os.path.expanduser(args.out or OUT_IPA)).resolve() if (args.out or OUT_IPA) else nsp_dir / g.get('ipa') # by default in the NSP folder, next to the NSPs and <id>_build/",- " out_ipa = Path(os.path.expanduser(args.out or OUT_IPA)).resolve() if (args.out or OUT_IPA) else work.parent / g.get('ipa') # by default next to the NSPs and <id>_build/")]))+ " work = Path(os.path.expanduser(args.work_dir)).resolve() if args.work_dir else nsp_dir / f'{g.id}_build' # the folder holding the NSPs by default; --work-dir puts the build elsewhere\n"+ " # out_ipa reads `work`, so `work` must be assigned first (upstream's order had them the other\n"+ " # way round; the --work-dir patch moved `work` up here and this line had to follow it).\n"+ " out_ipa = Path(os.path.expanduser(args.out or OUT_IPA)).resolve() if (args.out or OUT_IPA) else work.parent / g.get('ipa') # by default next to the NSPs and <id>_build/\n"+ " if shadowed and not (args.out or OUT_IPA): out_ipa = out_ipa.with_name(out_ipa.stem + '-provisional.ipa') # never over the IPA of the game's real profile\n"+ " if mac_pack and (args.out or OUT_IPA) and out_ipa.suffix != '.app': raise BuildError(f'the Mac app (-o / OUT_IPA) must end in .app: {out_ipa}')")]))P.append(('DOTNET_ROOT', 'list-runtimes', [(" env.setdefault('USER', getpass.getuser()) # xcodegen fails without USER (Couldn't find current username)",""" env.setdefault('USER', getpass.getuser()) # xcodegen fails without USER (Couldn't find current username)