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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: v0lumehi <[email protected]>
Date: Fri, 30 Oct 2026 20:07:20 +0100
Subject: [PATCH] NSP script: --shell-framework builds only the game's
framework for the shell
The Mac launcher's one-app install target passes it: the script runs the usual steps up to the iOS shaders, then build_ipa.sh with
DM_FRAMEWORK_ONLY, and keeps the extracted game files for the copy to the device (it implies --romfs separate and --keep-extracted).
Upstream-Status: fork-only
Reason: the NSP script's switch for the route C shell's game framework (patch 0050), which the fork's Mac launcher passes
Issue: LNPANDY/NX2Apple#144
---
scripts/build_ipa_from_nsp.py | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.py
index ea22543..71922cd 100755
--- a/scripts/build_ipa_from_nsp.py
+++ b/scripts/build_ipa_from_nsp.py
@@ -2808,6 +2808,9 @@ def parse_args(argv):
'is copied to the phone once per game version with the scripts/push_romfs.sh command printed at the end (the app refuses an image of another version)')
ap.add_argument('--prepare-xcode', action='store_true', help='prepare a per-game Xcode project and add it to the shared workspace instead of packing an IPA (requires keeping extracted files)')
ap.add_argument('--framework', action='store_true', help='the game\'s modules go into DmIOS.app/Frameworks/DmGame.framework, which the app dlopens at launch (route C, docs/launcher-c-plan.md M1), instead of the executable; the IPA is otherwise the usual one')
+ ap.add_argument('--shell-framework', metavar='FOLDER', help='route C\'s shell (docs/launcher-c-plan.md M2): build only the game\'s framework, FOLDER/DmGame<title ID>.framework '
+ '(its code, tables, settings list, shader libraries and icon), for dm/ios/tools/build_shell.sh to embed in the one app for all games; no IPA or Xcode project, '
+ 'the game files stay separate (implies --romfs separate and --keep-extracted)')
ap.add_argument('--platform', choices=('ios', 'mac', 'mac-app'), help='ios = the IPA (or the Xcode project); mac = for development: build only what running the game on this Mac needs (the Mac shaders and the Mac host, '
'no iOS shaders, Xcode project or IPA), keep the extracted files and print the command that runs the game; mac-app = what mac builds, then a self-contained, double-clickable '
'Mac app of the game (default: <game name>.app in the NSP folder, -o names another) (default: the PLATFORM setting, ios)')
@@ -2928,6 +2931,10 @@ def main(args=None):
if args.mac_sign and not mac_pack: raise BuildError('--mac-sign signs the Mac app: it needs --platform mac-app')
if mac and prepare_xcode: raise BuildError(f'--prepare-xcode makes an iPhone project: it cannot be combined with --platform {platform}')
if mac and args.framework: raise BuildError(f'--framework builds the iPhone app\'s game framework: it cannot be combined with --platform {platform}')
+ shell_fw = Path(os.path.expanduser(args.shell_framework)).resolve() if args.shell_framework else None
+ if shell_fw and (mac or prepare_xcode or args.framework): raise BuildError('--shell-framework builds only the game framework for the shell: it cannot be combined with --platform mac / mac-app, --prepare-xcode or --framework')
+ if shell_fw and args.romfs == 'bundle': raise BuildError('--shell-framework keeps the game files separate (the shell takes them from Documents/games/<title ID>/): it cannot be combined with --romfs bundle')
+ if shell_fw: args.romfs = 'separate'; args.keep_extracted = True
if mac and not apple_silicon(): raise BuildError(f'--platform {platform} runs the game in the Mac host, which runs the game\'s own arm64 code natively: it needs a Mac with Apple silicon, and this Mac has an Intel processor')
check_native_python()
keep = KEEP_EXTRACTED if args.keep_extracted is None else args.keep_extracted
@@ -3233,8 +3240,8 @@ def main(args=None):
rmtree(work / 'tmp'); return {'row': (PROGRAM_INDEX, g.id, patched, rfs.source(game), ios, gfx), 'ex': ex, 'keep': keep}
programs = other_programs(args, g)
if programs and romfs_mode == 'separate': raise BuildError('a game of several programs keeps its files in the app (ROMFS / --romfs bundle): Documents holds one RomFS image, one program\'s')
- if not prepare_xcode and free_gb(out_ipa.parent) < 5: raise BuildError(f'less than 5 GB free on the volume of {out_ipa.parent}')
- say('preparing the Xcode project' if prepare_xcode else f'building the IPA → {out_ipa}')
+ if not prepare_xcode and not shell_fw and free_gb(out_ipa.parent) < 5: raise BuildError(f'less than 5 GB free on the volume of {out_ipa.parent}')
+ say('preparing the Xcode project' if prepare_xcode else f'building the game framework for the shell → {shell_fw}' if shell_fw else f'building the IPA → {out_ipa}')
ipa_env = dict(env, GAME=g.id, W=str(work / 'ipa'), PATCHED=str(patched), ROMFS=str(rfs.source(game)), MSL_IOS=str(ios), GFXAPI=gfx, FONT_PY=py, DM_DISPLAY_NAME=app_name, DM_BUNDLE_ID=bundle_id, AOC=str(aoc or ''), DM_XCODE_DERIVED_DATA=str(work / 'xcode-derived-data'), DM_TEAM_ID=team_id, DM_LANG=lang, CONTROL=str(control))
if prepare_xcode: ipa_env['DM_XCODE_PROJECT_DIR'] = str(project.parent)
if args.framework: ipa_env['DM_FRAMEWORK'] = '1'; say('route C: the game\'s modules go into DmIOS.app/Frameworks/DmGame.framework (DM_FRAMEWORK=1)')
@@ -3257,6 +3264,18 @@ def main(args=None):
rows = [(0, g.id, patched, rfs.source(game), ios, gfx)] + [programs[n]['row'] for n in sorted(programs)]
tsv.write_text('# program\tprofile\trewritten modules\tRomFS\tiOS shaders\tgraphics API (build_ipa.sh PROGRAMS_TSV)\n' + ''.join('\t'.join(map(str, r)) + '\n' for r in rows))
say(f'one app holding programs {", ".join(str(r[0]) for r in rows)}')
+ if shell_fw: # route C's shell: the framework alone, which build_shell.sh embeds; the game files stay where they are for the copy to the device
+ ipa_env['DM_FRAMEWORK_ONLY'] = str(shell_fw)
+ fw = shell_fw / f'DmGame{g.id.upper()}.framework'
+ PROG.stage('game framework')
+ run(['bash', repo / 'dm/ios/tools/build_ipa.sh'], logs / 'build_framework.log', env=ipa_env)
+ if not (fw / 'game.manifest.json').is_file(): raise BuildError(f'no game framework at {fw}')
+ PROG.end(fw.name)
+ rmtree(work / 'tmp')
+ say(f'game framework: {fw}')
+ say(f'game files: {rfs.source(game)}')
+ report_profile_status(g, reg, pkg_ver, derived, provisional, 'shell framework', patched)
+ return
if prepare_xcode:
PROG.stage('prepare Xcode')
run(['bash', repo / 'dm/ios/tools/build_ipa.sh', '--prepare-xcode'], logs / 'prepare_xcode.log', env=ipa_env)