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 Windows IPA build handoff
tmrsmfb95f609ba1b
diff --git a/frontend-qt/README.md b/frontend-qt/README.mdindex 62cd6820..24baa7a1 100644--- a/frontend-qt/README.md+++ b/frontend-qt/README.md@@ -48,11 +48,12 @@ wherever `NSPB_REPO` points, and the repository group lets you pick it by hand.## What is not there yet-- **The Windows build path has run on a real Windows machine** — a handheld PC, which is where the- bug reports came from — through repository download, git auto-install and the LLVM / SDK / .NET- downloads. The compile, link, `Metal` compile and the final IPA on Windows have still not been- exercised end to end against a genuine LLVM-MinGW + iPhoneOS SDK + Metal Developer Tools- install. See [Windows build → Open risks](#open-risks).+- **The Windows build path remains experimental.** One Rhythm Heaven Groove 1.0.0 build produced+ an IPA on Windows and was reported to launch on an iPhone. It used local fixes to the upstream+ image reader and Windows frontend, SDK symlinks materialized by hand, and a Windows build of the+ pinned SPIRV-Cross source with locally recorded compiler fingerprints. The current unmodified+ frontend is not yet verified end to end; other games and gameplay beyond startup remain untested.+ See [Windows build → Open risks](#open-risks).- No self-update. Repository download and update buttons do exist (`Download repository`,`Check for updates`, `Pull updates`), and they log what git is doing.- No per-stage progress bar, no cancel-with-cleanup (cancel terminates the child).@@ -258,9 +259,9 @@ the tool offers it. The IPA name and the RomFS archive come out where the macOS## Open risks-The app's own toolchain discovery, downloads and repository handling have now run on a real-Windows machine (a handheld PC). These are the parts that still have not, and that only a full-build on Windows plus a device run can settle:+The frontend's setup has run on Windows, and one locally patched Windows build was reported to+launch on an iPhone. That first boot does not settle these risks for other games or for an+unmodified checkout:1. **Shader libraries on the device.** They come from the Windows Metal compiler, not Xcode's.They must load and render on iOS 26+ (`newLibraryWithURL`). `own_compilers.py` accepts adiff --git a/frontend-qt/nspb_qt/win/build_app.py b/frontend-qt/nspb_qt/win/build_app.pyindex 6dbacdd5..72cec465 100644--- a/frontend-qt/nspb_qt/win/build_app.py+++ b/frontend-qt/nspb_qt/win/build_app.py@@ -476,7 +476,9 @@ def main(argv: list[str] | None = None) -> int:for m in mods:if not ((patched / f'{m}.patched.bin').exists() and (patched / f'{m}.fixups.tsv').exists()):die(f'no rewritten module {patched}/{m} (the rewrite step must run first)')- if not (romfs / marker).exists():+ sys.path.insert(0, str(repo / 'dm' / 'tools'))+ from romfs import Path as RomFSPath+ if not (RomFSPath(romfs) / marker).exists():die(f'no RomFS at {romfs} (missing {marker})')name = env.get('DM_DISPLAY_NAME') or ''@@ -667,7 +669,8 @@ def main(argv: list[str] | None = None) -> int:t('add-on content: ' + ' '.join(sorted(p.name for p in aoc.iterdir())))full = bool(env.get('DM_FULL_ROMFS'))if full:- maps.append(f'Payload/DmIOS.app/romfs={romfs}')+ resource = 'romfs.img' if romfs.is_file() else 'romfs'+ maps.append(f'Payload/DmIOS.app/{resource}={romfs}')t('packing the full IPA with the RomFS (only sensible for small games)')else:t('packing a slim IPA without the RomFS (the game files come from Documents/romfs)')@@ -677,7 +680,7 @@ def main(argv: list[str] | None = None) -> int:if store:pack += ['--store', ':'.join(store.split(':'))]pack += ['--skip', 'Payload/DmIOS.app/msl', '--skip', 'Payload/DmIOS.app/aoc',- '--skip', 'Payload/DmIOS.app/romfs', *maps]+ '--skip', 'Payload/DmIOS.app/romfs', '--skip', 'Payload/DmIOS.app/romfs.img', *maps]r = subprocess.run(pack, capture_output=True, text=True, errors='replace')if r.returncode:print(((r.stdout or '') + (r.stderr or ''))[-3000:], file=sys.stderr)diff --git a/frontend-qt/nspb_qt/win/driver.py b/frontend-qt/nspb_qt/win/driver.pyindex 347f02b6..8fbfe990 100644--- a/frontend-qt/nspb_qt/win/driver.py+++ b/frontend-qt/nspb_qt/win/driver.py@@ -228,7 +228,7 @@ def patch(mod: ModuleType, repo: Path, *, j: int | None = None) -> None:mod.heap_check = heap_check# ---------------------------------------------------------------- the shader cache key- def toolchain_probe():+ def toolchain_probe(repo_=None, env=None):"""What the shader-stage cache keys record as "the compilers".Upstream records `xcodebuild -version` and `spirv-cross --revision`. Here the Metaldiff --git a/frontend-qt/nspb_qt/win/shim.py b/frontend-qt/nspb_qt/win/shim.pyindex 30f268f5..ff9b4773 100644--- a/frontend-qt/nspb_qt/win/shim.py+++ b/frontend-qt/nspb_qt/win/shim.py@@ -184,6 +184,7 @@ if os.name == 'nt' and not os.environ.get('NSPB_SHIM_OFF'):return _resolve(args[1:]) or [sys.executable, _XCRUN] + args[1:]if base == 'dmsh_xlate' and '/dmsh_xlate_bin/' in head:# an absolute path, not `which`: a .NET SDK the app installed is not on PATH+ import toolchain as tcdn = tc.dotnet_dir()dotnet = str(dn / 'dotnet.exe') if dn else (shutil.which('dotnet') or 'dotnet')return [dotnet, args[0] + '.dll'] + args[1:]@@ -322,11 +323,13 @@ def build_env(base: dict[str, str] | None = None, python_exe: str | None = None)p = tc.find_exe(name)if p:parts.append(str(p.parent))+ if name == 'spirv-cross': env.setdefault('SPIRV_CROSS', str(p))# tc.dotnet_dir() first: it knows about the SDK the app installed for itself, which is not on# PATH and not in Program Files. `which` alone missed it, so `dotnet build` and the shader# translator failed on a machine that had just installed .NET through this app.if dn := tc.dotnet_dir():parts.append(str(dn))+ env['DOTNET_ROOT'] = env['DOTNET_ROOT_X64'] = str(dn)elif dn := shutil.which('dotnet'):parts.append(str(Path(dn).parent))diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.pyindex e95e5ab4..c7fd2418 100644--- a/frontend-qt/tests/test_win.py+++ b/frontend-qt/tests/test_win.py@@ -303,6 +303,16 @@ class MetalArgsTest(unittest.TestCase):got = xcrun_shim.metal_args('iphoneos', ['-target', 'air64-apple-ios26.0', '-c'])self.assertEqual(got.count('-target'), 1)+ def test_link_probe_reports_a_linker_failure(self) -> None:+ # An unavailable linker should be reported by the doctor, not crash its probe.+ with tempfile.TemporaryDirectory() as td, \+ mock.patch.object(tc, 'llvm_tool', return_value=Path(td) / 'clang.exe'), \+ mock.patch.object(tc, 'ensure_ld64_lld', return_value=(Path(td) / 'ld64.lld.exe', '')), \+ mock.patch.object(tc.subprocess, 'run', side_effect=OSError('linker unavailable')):+ ok, detail = tc.probe_link(Path(td))+ self.assertFalse(ok)+ self.assertIn('linker unavailable', detail)+def test_metal_tt_has_no_windows_tool(self) -> None:# the pipeline archive is disabled here, and the caller relies on this being Noneself.assertIsNone(tc.metal_tool('metal-tt'))@@ -548,6 +558,45 @@ class ShimTest(unittest.TestCase):self.assertTrue(env['PYTHONPATH'].startswith(td))self.assertEqual(env['PYTHONUTF8'], '1')+ def test_build_env_passes_portable_dotnet_and_spirv_cross_to_children(self) -> None:+ with tempfile.TemporaryDirectory() as td:+ root = Path(td)+ dotnet = root / 'dotnet'+ spirv = root / 'cross' / 'spirv-cross.exe'+ def find(name):+ return spirv if name == 'spirv-cross' else None+ with mock.patch.object(shim, 'shim_dir', return_value=root / 'shim'), \+ mock.patch.object(tc, 'dotnet_dir', return_value=dotnet), \+ mock.patch.object(tc, 'find_exe', side_effect=find):+ env = shim.build_env({'PATH': '', 'PYTHONPATH': ''}, python_exe=sys.executable)+ self.assertEqual(env['DOTNET_ROOT'], str(dotnet))+ self.assertEqual(env['DOTNET_ROOT_X64'], str(dotnet))+ self.assertEqual(env['SPIRV_CROSS'], str(spirv))++ def test_build_env_preserves_an_explicit_spirv_cross(self) -> None:+ with tempfile.TemporaryDirectory() as td:+ with mock.patch.object(shim, 'shim_dir', return_value=Path(td)), \+ mock.patch.object(tc, 'find_exe', return_value=Path('detected-cross')):+ env = shim.build_env({'PATH': '', 'SPIRV_CROSS': 'chosen-cross'},+ python_exe=sys.executable)+ self.assertEqual(env['SPIRV_CROSS'], 'chosen-cross')++ @unittest.skipUnless(os.name == 'nt', 'Windows subprocess shim')+ def test_translator_mapping_can_find_the_dotnet_module(self) -> None:+ # The generated sitecustomize runs in child interpreters and must resolve dotnet there.+ with tempfile.TemporaryDirectory() as td:+ shim.install(Path(td), python_exe=sys.executable)+ env = dict(os.environ, PYTHONPATH=td, NSPB_SHIM_OFF='')+ script = ("import sitecustomize as s, toolchain\n"+ "from pathlib import Path\n"+ "toolchain.dotnet_dir = lambda: Path('portable-dotnet')\n"+ "got = s._map(['x/dmsh_xlate_bin/dmsh_xlate', '--source-sha'])\n"+ "assert got[0] == str(Path('portable-dotnet') / 'dotnet.exe'), got\n"+ "assert got[1:] == ['x/dmsh_xlate_bin/dmsh_xlate.dll', '--source-sha'], got\n")+ r = subprocess.run([sys.executable, '-c', script], env=env,+ capture_output=True, text=True)+ self.assertEqual(r.returncode, 0, r.stdout + r.stderr)+class DriverCliTest(unittest.TestCase):"""Mac-only options are refused before any work starts."""@@ -636,7 +685,7 @@ class DriverPatchTest(unittest.TestCase):self.assertIn('need a Mac', str(ctx.exception))def test_toolchain_probe_uses_the_windows_metal(self) -> None:- probes = self.mod.toolchain()+ probes = self.mod.toolchain(self.repo, {})self.assertTrue(probes)joined = ' '.join(' '.join(p[1]) for p in probes if p[0] == 'cmd')self.assertIn('xcrun_shim.py', joined)