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
Keep every extracted version as the build resource it is, and reveal the game data after a device install
LNPANDY0506db0a9ae8
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swiftindex 236446f7..afe0718f 100644--- a/frontend/Sources/NSPortBuilder/ContentView.swift+++ b/frontend/Sources/NSPortBuilder/ContentView.swift@@ -2496,6 +2496,14 @@ struct BuilderView: View {m.openOnDevice(udid: m.installedOn, app: m.installedAppPath) { error in if let error { m.doneNote = error } }}}+ // The game files were copied (or, after a skipped transfer, await a manual copy — a+ // fast external drive handed to the device is quicker than USB): show where they are.+ if !m.archivePath.isEmpty {+ divider+ row(m.t("dev.gameData"), detail: m.shortPath(m.archivePath), dot: LauncherPalette.ready, help: m.archivePath) {+ Button(m.t("install.reveal")) { reveal(m.archivePath) }+ }+ }}} else if m.done && m.target != "mac-app" {group(m.t("install.title")) {diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex 67966fbd..80c7f76b 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -108,6 +108,7 @@ enum L10n {"dev.transferNow": ("传输", "Transfer"),"dev.transferSkip": ("暂不传输", "Not now"),"dev.copySkipped": ("已安装到 %@;游戏文件未传输", "Installed on %@; the game files were not transferred"),+ "dev.gameData": ("游戏数据(romfs.img)", "Game data (romfs.img)"),"dev.installed": ("\u{5df2}\u{5b89}\u{88c5}\u{5230} %@", "Installed on %@"),"dev.installedNote": ("\u{6e38}\u{620f}\u{5df2}\u{5728}\u{8bbe}\u{5907}\u{4e0a}\u{ff0c}\u{53ef}\u{4ee5}\u{76f4}\u{63a5}\u{6253}\u{5f00}\u{3002}", "The game is on the device, ready to open."),"dev.open": ("\u{5728} %@ \u{4e0a}\u{6253}\u{5f00}", "Open on %@"),diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.pyindex dca1d29d..89ff8595 100755--- a/scripts/build_ipa_from_nsp.py+++ b/scripts/build_ipa_from_nsp.py@@ -873,19 +873,6 @@ def extracted(log): # (files, bytes) from the summary lines nx_extract wrote treturn (sum(int(n) for n, _ in rows), int(sum(float(mb) for _, mb in rows) * 2**20)) if rows else None-def prune_intermediate_extracts(dirs, versions, pkg_ver):- """Every extracted version but the packed one: each holds a complete extra copy of the game (one- merged RomFS image per version), and only the packed version's files are reused by the next- build — when its inputs change, the intermediates are extracted again anyway (the packed version- is merged from them). The shader captures above still read them, so they are dropped only once- the build is done. A game without an update extracts one version and this deletes nothing."""- spare = [dirs[v] for v in versions if v != pkg_ver and dirs[v].is_dir()]- if not spare: return- say('deleting the intermediate extractions, one full copy of the game each (the packed version keeps its files): '- + ', '.join(d.name for d in spare))- for d in spare: rmtree(d)--def extract(nx, keys, ex, name, base, upd, cmp_dir, logs, g): # the build IDs are checked by the caller (build_mismatch)dst, marker, log = ex / name, g.get('romfs_marker'), logs / f'extract_{name}.log'try: reusable = (dst / 'ExeFS' / 'main').exists() and (dst / 'RomFS.img').is_file() and not (dst / 'RomFS').exists() and (rfs.source(dst) / marker).exists()@@ -2161,7 +2148,6 @@ def main(args=None):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, args.env_file or DM_ENV_FILE,(args.gpu or PSO_GPUS).strip())rmtree(work / 'tmp')- prune_intermediate_extracts(dirs, versions, pkg_ver)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')report_profile_status(g, reg, pkg_ver, derived, provisional, 'Mac app')@@ -2170,7 +2156,6 @@ def main(args=None):host, font = mac_host(py, repo, work, env, logs, g)cmd = mac_run(work, game, patched, host, font, ios, aoc, gfx, lang, env, logs, g, args.env_file or DM_ENV_FILE)rmtree(work / 'tmp')- prune_intermediate_extracts(dirs, versions, pkg_ver)say(f'done: the game runs on the Mac with this command (its save in {work / "run/save"}, kept from run to run; DM_WINDOW=1 opens a window, DM_AUDIO=1 plays sound):')PROG.say(cmd)report_profile_status(g, reg, pkg_ver, derived, provisional, 'Mac build')@@ -2200,7 +2185,6 @@ def main(args=None):except ValueError as e: raise BuildError(str(e)) from ePROG.end()rmtree(work / 'tmp')- prune_intermediate_extracts(dirs, versions, pkg_ver)say(f'ready: {workspace}')say(f'game project: {project}')say(f'Xcode derived data: {work / "xcode-derived-data"}')@@ -2215,8 +2199,6 @@ def main(args=None):rmtree(work / 'tmp')if not keep:say(f'deleting the extracted game files: {ex}'); rmtree(ex)- else:- prune_intermediate_extracts(dirs, versions, pkg_ver)say(f'done: {out_ipa} ({out_ipa.stat().st_size / 2**30:.1f} GB)')report_profile_status(g, reg, pkg_ver, derived, provisional)