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
Patch 0072: the Mac app's settings read the base game's languages when a NUP update has no control data (#619)
v0lumehi1eb5d7dcd6dc
diff --git a/patches/0072-mac-pack-the-settings-read-the-base-game-s-langu.patch b/patches/0072-mac-pack-the-settings-read-the-base-game-s-langu.patchnew file mode 100644index 00000000..fda2db85--- /dev/null+++ b/patches/0072-mac-pack-the-settings-read-the-base-game-s-langu.patch@@ -0,0 +1,107 @@+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001+From: v0lumehi <[email protected]>+Date: Wed, 4 Nov 2026 10:01:33 +0100+Subject: [PATCH] Mac pack: the settings read the base game's languages when+ the update has no control data++A NUP update may carry no NACP, and pack_nup removes control.nacp from its folder then.+The language check already fell back to the base game's NACP, but the Mac app's launcher+settings read only the packed version's file, found no languages and left out the Game+language row. Both now use the same file.++Upstream-Status: forwarded seedds/nxnative#1182+Reason: The Mac app's settings read only the update's control data, which a NUP update may lack, so a Switch 2 game had no Game language row+Issue: LNPANDY/NX2Apple#619++---+ dm/tools/tests/test_nsp_nup.py | 21 ++++++++++++++++++++++ scripts/build_ipa_from_nsp.py | 16 ++++++++++++----+ 2 files changed, 33 insertions(+), 4 deletions(-)++diff --git a/dm/tools/tests/test_nsp_nup.py b/dm/tools/tests/test_nsp_nup.py+index c7141f9..8b237e4 100644+--- a/dm/tools/tests/test_nsp_nup.py++++ b/dm/tools/tests/test_nsp_nup.py+@@ -222,6 +222,27 @@ class Pack(Base):+ jp = (b / 'control.nacp').read_bytes()[2 * 0x300:2 * 0x300 + 0x200].split(b'\0')[0]+ self.assertEqual(jp.decode(), 'テス')+++ def test_settings_read_the_base_games_languages_when_the_update_has_no_control_data(self): # a Switch 2 game's settings had no Game language row (GitHub issue #619)++ sys.path.insert(0, str(REPO / 'dm/games')); import settings++ vars(nsp)['nacp'] = nacp # main sets it++ n = self.open(); app, base, vers, _ = pack_nup.scan(n)++ pack_nup.pack_version(n, vers[VER], base, app, self.out() / 'u', say=lambda s: None)++ pack_nup.pack_version(n, base, base, app, self.out() / 'b', say=lambda s: None)++ u, b = self.out() / 'u', self.out() / 'b'++ nac = bytearray((b / 'control.nacp').read_bytes()); struct.pack_into('<I', nac, 0x302C, 0b101) # American English and Japanese++ (b / 'control.nacp').write_bytes(nac)++ self.assertFalse((u / 'control.nacp').exists())++ control = nsp.languages_control(u, b)++ self.assertEqual(nacp.languages(control), ['en-US', 'ja'])++ with tempfile.TemporaryDirectory() as tmp:++ (Path(tmp) / 'main.fixups.tsv').write_text('')++ row = lambda path: [s for s in settings.build(f'{TID:016X}', tmp, str(path))['settings'] if s['env'] == 'DM_LANG']++ self.assertEqual(row(u / 'control.nacp'), []) # the path the Mac pack passed before: no row++ self.assertEqual(row(control)[0]['options'], [['en-US', 'American English'], ['ja', 'Japanese']])++ self.assertEqual(nsp.languages_control(b, u), b / 'control.nacp') # the packed version's own list wins when it has one++ nac = bytearray(nac); struct.pack_into('<I', nac, 0x302C, 0b11); (u / 'control.nacp').write_bytes(nac)++ self.assertEqual(nsp.languages_control(u, b), u / 'control.nacp')+++ def test_name_label_without_nacp_writes_none(self): # the script then takes the profile's name, as for a dump+ write_nup(self.path, [(0, TID, 0, version(), tlv([(T_NAME, b'TG'), (pack_nup.T_ICON, b'\xff\xd8 icon')]))])+ n = self.open(); app, base, _, _ = pack_nup.scan(n)+diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.py+index f9dc7e4..4161bec 100755+--- a/scripts/build_ipa_from_nsp.py++++ b/scripts/build_ipa_from_nsp.py+@@ -333,6 +333,13 @@ def game_language(want, asked, have):+ return have[0]++++def languages_control(*dirs):++ """The control.nacp that lists the game's languages: the first of the folders' (the packed version's, then the base game's) that lists any, else the first one's path. An update, a NUP's++ especially, may carry no control data, and the settings must then read the base game's, as the language check does"""++ paths = [d / 'control.nacp' for d in dirs]++ return next((p for p in paths if nacp.languages(p)), paths[0])+++++ def language_list(codes):+ names = dict(nacp.LANGUAGES)+ return ', '.join(f'{c} ({names[c]})' for c in codes)+@@ -2390,7 +2397,7 @@ def mac_app_name(name): # the app's file name: the game name with the characte+ return re.sub(r'\s*[:/]\s*', ' - ', name).strip(' .-') or 'nxnative'+++-def mac_app(py, repo, out, app, work, game, patched, host, font, msl, aoc, gfx, lang, g, name, version, bundle_id, icon, sign, env, logs, env_file='', gpus=''):++def mac_app(py, repo, out, app, work, game, patched, host, font, msl, aoc, gfx, lang, g, name, version, bundle_id, icon, sign, env, logs, env_file='', gpus='', control=None):+ """The last stage of PLATFORM 'mac-app': pack the Mac app (dm/mac/pack_app.py) from what a Mac-only build made: the Mac host and font (mac_host), the packed version's RomFS and rewritten+ modules, the Mac shader libraries (msl: <shader>/cache, whose b-<chain> goes in, or a Vulkan or GL game's <shader>, whose vk / gl goes in), the DLC, the profile's tables (with the shader pairs+ the pipeline prebuild reads), the pipeline archive made offline for this Mac (mac_pso; gpus: --gpu / PSO_GPUS), the launcher settings and an environment file.+@@ -2400,7 +2407,7 @@ def mac_app(py, repo, out, app, work, game, patched, host, font, msl, aoc, gfx,+ PROG.stage('Mac app', step='starting')+ # The launcher settings the IPA carries (dm/games/settings.py), without the iPhone's own switches: the app's settings window and Mac front ends show them (docs/frontends.md)+ settings = work / 'app/launcher.json'; settings.parent.mkdir(parents=True, exist_ok=True)+- run([py, repo / 'dm/games/settings.py', g.id, patched, game / 'control.nacp', settings], logs / 'mac_settings.log', env=dict(env, GFXAPI=gfx, SETTINGS_PLATFORM='mac', DM_LANG=lang))++ run([py, repo / 'dm/games/settings.py', g.id, patched, control or game / 'control.nacp', settings], logs / 'mac_settings.log', env=dict(env, GFXAPI=gfx, SETTINGS_PLATFORM='mac', DM_LANG=lang))+ cmd = [py, repo / 'dm/mac/pack_app.py', out, '--host', host, '--patched', patched, '--romfs', rfs.source(game), '--msl', lib, '--tables', g.table('shader_map.tsv').parent,+ '--font', font, '--title-id', f'{app:016X}', '--name', name, '--bundle-id', bundle_id, '--lang', lang, '--sign', sign or '-']+ split_pairs = work / 'shader/pso_pairs.tsv' # the split's copy of pso_pairs.tsv, for a profile without the table (as mac_run's DM_PSO_PAIRS)+@@ -2760,7 +2767,8 @@ def main(args=None):+ if mac_pack and not (args.out or OUT_IPA): out_ipa = work.parent / f'{mac_app_name(app_name)}{"-provisional" if shadowed else ""}.app'+ if not mac or mac_pack: say(f'app name: {app_name}; version: {app_version or "1.0"}; bundle ID: {bundle_id}' + (f'; app: {out_ipa}' if mac_pack else ''))+ # the game language: Horizon gives the game one of the languages its control data lists (the packed version's, which an update may extend), so the one packed must be among them+- have = nacp.languages(game / 'control.nacp') or nacp.languages(base / 'control.nacp')++ control = languages_control(game, base)++ have = nacp.languages(control)+ lang = game_language(want_lang, bool(lang_in), have)+ say(f'game language: {lang} ({dict(nacp.LANGUAGES)[lang]})' + (f', the game has no {want_lang}' if lang != want_lang else '')+ + (f'; the game\'s languages: {" ".join(have)}' if have else '; the control data lists no languages (not checked)') + (' (DM_LANG=<code> in the run command changes it)' if mac else ' (DM_LANG=<code> in the app\'s Documents/env.txt changes it)'))+@@ -2812,7 +2820,7 @@ def main(args=None):+ host, font = mac_host(py, repo, work, env, logs, g)+ if not icon: say(('no game icon: the NUP carries none' if nup else 'no game icon: a dump folder has no control data') + '; the app\'s icon will be blank' if dump else '[RED] no game icon in the extraction (an older extraction did not save it: delete extract/ and run again); the app\'s icon will be blank')+ mac_app(py, repo, out_ipa, app, work, game, patched, host, font, ios, aoc, gfx, lang, g, app_name, app_version, bundle_id, icon, args.mac_sign or MAC_SIGN, env, logs, env_file,+- (args.gpu or PSO_GPUS).strip())++ (args.gpu or PSO_GPUS).strip(), control)+ rmtree(work / 'tmp')+ say(f'done: {out_ipa} ({tree_size(out_ipa)[1] / 2**30:.1f} GB); '+ f'open it from Finder. Its save is in ~/Library/Application Support/nxnative/{app:016X}/, its log in ~/Library/Logs/nxnative/{app:016X}.log')diff --git a/patches/series b/patches/seriesindex be523566..3157a784 100644--- a/patches/series+++ b/patches/series@@ -44,3 +44,4 @@0069-ios-shell-compile-the-in-game-menu-so-the-gear-o.patch0070-ios-touch-layout.patch0071-ios-shell-restore-native-duo-orientation.patch+0072-mac-pack-the-settings-read-the-base-game-s-langu.patch