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
Qt front end: fit a 7-inch handheld, a Windows-correct git hint, and in-app Windows downloads
LNPANDY8e39b4d11e2d
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.pyindex 1a89ad36..de5c8e15 100644--- a/frontend-qt/nspb_qt/localization.py+++ b/frontend-qt/nspb_qt/localization.py@@ -45,7 +45,7 @@ TABLE: dict[str, tuple[str, str]] = {'repo.pulling': ('正在更新…(构建不受影响,之前的构建文件不在仓库里)', 'Updating… (your builds are safe — their files live outside the repository)'),'repo.pulled': ('已更新到最新', 'Updated to the latest'),'repo.pullFail': ('更新失败——详情见日志(本地文件被改过?)', 'Update failed — see the log (local changes?)'),- 'repo.gitMissing': ('没找到 git:在终端运行 xcode-select --install 装一下命令行工具', 'git not found: run xcode-select --install in Terminal to get the Command Line Tools'),+ 'repo.gitMissing': ('没找到 git:Windows 请到 git-scm.com 下载安装,macOS 运行 xcode-select --install', 'git not found: install it from git-scm.com (Windows), or run xcode-select --install (macOS)'),'repo.netFail': ('检查更新失败(网络不通?)', 'Could not check for updates (offline?)'),'data.title': ('游戏数据', 'Game data'),'data.note': ('四项可以分开选', 'four inputs, picked separately'),@@ -70,25 +70,29 @@ TABLE: dict[str, tuple[str, str]] = {'msg.archiveAt': ('归档:%@', 'Archive: %@'),'repo.ok': ('仓库可用', 'repository ready'),'dep.iossdk': ('iPhoneOS SDK', 'iPhoneOS SDK'),- 'dep.iossdk.hint': ('Windows 上需要 iPhoneOS SDK(交叉编译的头文件与 stub 库):由 App 下载,或从 Xcode.xip 解出', 'Windows needs an iPhoneOS SDK (headers and stub libraries for the cross build): the app downloads one, or extracts it from an Xcode.xip'),- 'dep.llvm': ('LLVM-MinGW(交叉编译)', 'LLVM-MinGW (cross compiler)'),- 'dep.llvm.hint': ('点「安装」下载钉死版本的 LLVM-MinGW(含 clang 与 LLD)', 'Install fetches the pinned LLVM-MinGW (clang and LLD)'),- 'dep.lld': ('ld64.lld(Mach-O 链接器)', 'ld64.lld (Mach-O linker)'),- 'dep.lld.hint': ('llvm-mingw 的发布包删掉了 ld64.lld.exe,但 ld.lld.exe 含全部 LLD 驱动,改名即可;App 会自动完成', 'llvm-mingw deletes ld64.lld.exe, but ld.lld.exe carries every LLD driver, so renaming it is enough; the app does that'),- 'dep.probe.compile': ('交叉编译探针', 'cross-compile probe'),- 'dep.probe.compile.hint': ('用 clang -target arm64-apple-ios 编一个 .m,检查产出是 arm64 Mach-O', 'Compiles one .m for arm64-apple-ios and checks the object is arm64 Mach-O'),- 'dep.probe.link': ('交叉链接探针', 'cross-link probe'),- 'dep.probe.link.hint': ('用 ld64.lld 链接一个最小可执行文件,检查它是 iOS 的 MH_EXECUTE', 'Links a minimal executable with ld64.lld and checks it is an iOS MH_EXECUTE'),- 'dep.probe.metal': ('Metal 编译探针', 'Metal compile probe'),- 'dep.probe.metal.hint': ('用 metal.exe / metallib.exe 编一个最小 shader,检查产出的 .metallib', 'Compiles a minimal shader with metal.exe / metallib.exe and checks the .metallib'),- 'dep.glslang': ('glslangValidator(可选)', 'glslangValidator (optional)'),- 'dep.glslang.hint': ('只有 OpenGL 游戏的 shader 需要它', 'needed only for an OpenGL game’s shaders'),- 'dep.optionalMissing': ('未安装(可选)', 'not installed (optional)'),+ 'dep.iossdk.hint': ('Windows 上需要 iPhoneOS SDK(用于交叉编译)', 'Windows needs an iPhoneOS SDK for the cross build'),'dep.metal.missing': ('未找到 metal.exe(Apple Metal Developer Tools for Windows)', 'metal.exe not found (Apple Metal Developer Tools for Windows)'),'dep.title': ('设备依赖', 'Device dependencies'),'dep.checking': ('检测中…', 'Checking…'),'dep.allReady': ('全部就绪', 'All ready'),'dep.missing': ('缺 %d 项', '%d missing'),+ 'dep.llvm': ('LLVM-MinGW(交叉编译)', 'LLVM-MinGW (cross compiler)'),+ 'dep.llvm.hint': ('Windows 上编译 iOS 二进制用(app 内自动下载)', 'builds the iOS binary on Windows (downloaded in-app)'),+ 'dep.llvm.downloading': ('正在下载 LLVM-MinGW…(约 250 MB)', 'Downloading LLVM-MinGW… (about 250 MB)'),+ 'dep.llvm.done': ('LLVM-MinGW 已安装:%@', 'LLVM-MinGW installed: %@'),+ 'dep.lld': ('Mach-O 链接器(ld64.lld)', 'Mach-O linker (ld64.lld)'),+ 'dep.lld.hint': ('随 LLVM-MinGW 提供', 'comes with LLVM-MinGW'),+ 'dep.iossdk.downloading': ('正在下载 iPhoneOS SDK…(约 100 MB)', 'Downloading the iPhoneOS SDK… (about 100 MB)'),+ 'dep.iossdk.done': ('iPhoneOS SDK 已安装:%@', 'iPhoneOS SDK installed: %@'),+ 'dep.probe.compile': ('试编译 arm64 Mach-O', 'trial compile to arm64 Mach-O'),+ 'dep.probe.compile.hint': ('验证 clang 真能产出 iOS 目标文件', 'checks that clang really produces iOS objects'),+ 'dep.probe.link': ('试链接 iOS 可执行文件', 'trial link to an iOS executable'),+ 'dep.probe.link.hint': ('验证 ld64.lld 能链接', 'checks that ld64.lld links'),+ 'dep.probe.metal': ('试编译 Metal 着色器', 'trial Metal shader compile'),+ 'dep.probe.metal.hint': ('验证 metal.exe 能产出 metallib', 'checks that metal.exe produces a metallib'),+ 'dep.optionalMissing': ('可选,未安装', 'optional, not installed'),+ 'dep.glslang': ('glslangValidator(可选)', 'glslangValidator (optional)'),+ 'dep.glslang.hint': ('仅 OpenGL 游戏需要', 'only needed for OpenGL games'),'dep.installAll': ('一键安装全部缺失项', 'Install all missing'),'dep.recheck': ('重新检测', 'Check again'),'dep.install': ('安装', 'Install'),diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.pyindex 3f77d2b6..4064ff7d 100644--- a/frontend-qt/nspb_qt/model.py+++ b/frontend-qt/nspb_qt/model.py@@ -234,10 +234,10 @@ class Model(QObject):p = by_id.get('llvm')if p:detail = p.path if p.ok else (p.detail or '')- install: list[str] = []- if not p.ok:- # the app downloads the pinned LLVM-MinGW itself; no command line needed- install = []+ # A missing LLVM is installable in-app: fetch.install_llvm downloads the pinned+ # LLVM-MinGW and verifies its SHA-256. The marker tells install_dep to run that+ # instead of a command line.+ install = [] if p.ok else ['__win__:llvm']out.append(Dep('llvm', 'dep.llvm', 'dep.llvm.hint', state(p), detail,install=install))p = by_id.get('lld')@@ -253,7 +253,9 @@ class Model(QObject):detail = p.pathelif p.state == 'wrong':detail = p.detail- out.append(Dep('ios_sdk', 'dep.iossdk', 'dep.iossdk.hint', state(p), detail))+ install = [] if p.ok else ['__win__:ios_sdk']+ out.append(Dep('ios_sdk', 'dep.iossdk', 'dep.iossdk.hint', state(p), detail,+ install=install))# Metalp = by_id.get('metal')@@ -410,6 +412,11 @@ class Model(QObject):"""Run a dependency's fix on a thread, streaming its output to the log."""if not dep.install:return+ # A Windows toolchain row carries a marker instead of a command line: the download is+ # in-process (nspb_qt.win.fetch), so there is nothing to spawn.+ if dep.install[0].startswith('__win__:'):+ self._install_win(dep, dep.install[0].split(':', 1)[1])+ returndep.installing = Trueself.depsChanged.emit()@@ -438,6 +445,42 @@ class Model(QObject):threading.Thread(target=work, daemon=True).start()+ def _install_win(self, dep: Dep, what: str) -> None:+ """Download and unpack a Windows toolchain piece, with progress in the log.++ Runs on a thread. Every failure names the step and what to do by hand, because a+ download can fail for reasons the app cannot fix (a proxy, a proxy that blocks GitHub,+ an Apple ID needed for the Metal tools).+ """+ dep.installing = True+ self.depsChanged.emit()++ def work() -> None:+ ok = False+ try:+ from .win import fetch as wf, toolchain as wtc+ if what == 'llvm':+ self.logAppended.emit(self.t('dep.llvm.downloading') + '\n')+ path = wf.install_llvm(log=lambda s: self.logAppended.emit(str(s) + '\n'),+ progress=lambda d, t_: self.logAppended.emit(+ f' {d // 1048576} MB' + (f' / {t_ // 1048576} MB ({d * 100 // t_}%)' if t_ else '') + '\n'))+ self.logAppended.emit(self.t('dep.llvm.done', str(path)) + '\n')+ ok = True+ elif what == 'ios_sdk':+ self.logAppended.emit(self.t('dep.iossdk.downloading') + '\n')+ from .win import sdk_fetch as sf+ path = sf.clone_sdk(log=lambda s: self.logAppended.emit(str(s) + '\n'))+ self.logAppended.emit(self.t('dep.iossdk.done', str(path)) + '\n')+ ok = True+ except Exception as e: # DownloadError, OSError, a missing attribute: all reported+ self.logAppended.emit(self.t('dep.install.fail', str(e)) + '\n')+ ok = False+ dep.installing = False+ self.depsChanged.emit()+ self.check_deps()++ threading.Thread(target=work, daemon=True).start()+def _make_venv(self, base: str) -> bool:vpy = pu.venv_python()if not Path(vpy).is_file():diff --git a/frontend-qt/nspb_qt/style.py b/frontend-qt/nspb_qt/style.pyindex 03e7b420..39281004 100644--- a/frontend-qt/nspb_qt/style.py+++ b/frontend-qt/nspb_qt/style.py@@ -23,7 +23,7 @@ QMainWindow, QDialog, QScrollArea, QWidget#body {{}}QWidget {{color: {TEXT};- font-size: 13px;+ font-size: 9pt; /* pt, not px: a handheld at 150% scaling keeps readable text and a window that fits */}}QLabel {{background: transparent;@@ -37,15 +37,15 @@ QScrollArea > QWidget > QWidget {{QFrame#card {{background: {CARD};border: 1px solid {CARD_EDGE};- border-radius: 10px;+ border-radius: 8px;}}/* ---- buttons ---- */QPushButton {{background: #333a43;border: 1px solid #3d444d;- border-radius: 7px;- padding: 6px 14px;+ border-radius: 6px;+ padding: 3px 10px; /* compact: a 7-inch panel must fit the whole form */color: {TEXT};}}QPushButton:hover {{ background: #3c444e; }}@@ -56,9 +56,9 @@ QPushButton#primary {{background: {ACCENT};border: none;color: white;- font-size: 14px;+ font-size: 10pt;font-weight: 600;- padding: 9px 20px;+ padding: 6px 16px;}}QPushButton#primary:hover {{ background: #3a9bff; }}QPushButton#primary:disabled {{ background: #2c3a4a; color: #6b7683; }}@@ -67,21 +67,21 @@ QPushButton#danger {{background: {RED};border: none;color: white;- font-size: 14px;+ font-size: 10pt;font-weight: 600;- padding: 9px 20px;+ padding: 6px 16px;}}/* ---- labels ---- */-QLabel#title {{ font-size: 26px; font-weight: 700; background: transparent; }}-QLabel#subtitle {{ color: {MUTED}; font-size: 13px; background: transparent; }}-QLabel#note {{ color: {MUTED}; font-size: 12px; background: transparent; }}-QLabel#mono {{ color: {MUTED}; font-family: Menlo, Consolas, monospace; font-size: 12px; background: transparent; }}+QLabel#title {{ font-size: 17pt; font-weight: 700; background: transparent; }}+QLabel#subtitle {{ color: {MUTED}; font-size: 9pt; background: transparent; }}+QLabel#note {{ color: {MUTED}; font-size: 8pt; background: transparent; }}+QLabel#mono {{ color: {MUTED}; font-family: Menlo, Consolas, monospace; font-size: 8pt; background: transparent; }}QLabel#ok {{ color: {GREEN}; font-weight: 600; background: transparent; }}QLabel#warn {{ color: {ORANGE}; font-weight: 600; }}QLabel#bad {{ color: {RED}; font-weight: 600; background: transparent; }}-QLabel#rowname {{ font-size: 14px; background: transparent; }}-QLabel#footer {{ color: {MUTED}; font-size: 12px; padding: 8px 4px; background: transparent; }}+QLabel#rowname {{ font-size: 10pt; background: transparent; }}+QLabel#footer {{ color: {MUTED}; font-size: 8pt; padding: 4px 2px; background: transparent; }}/* ---- the log ---- */QTextEdit {{@@ -91,7 +91,7 @@ QTextEdit {{padding: 8px;color: #b9c2cc;font-family: Menlo, Consolas, monospace;- font-size: 11px;+ font-size: 8pt;}}/* ---- progress ---- */diff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.pyindex e9ec5fe8..4b9926a6 100644--- a/frontend-qt/nspb_qt/ui.py+++ b/frontend-qt/nspb_qt/ui.py@@ -29,10 +29,12 @@ class MainWindow(QMainWindow):# reach it. Fit within 90% of the available area and let the scroll area do the rest.avail = self.screen().availableGeometry() if self.screen() else Noneif avail is not None:- self.resize(min(1000, int(avail.width() * 0.92)), min(980, int(avail.height() * 0.90)))+ # Use most of the panel: a 1280x800 handheld at 150% has only ~853x533 logical pixels,+ # so the margins must be small and the height is what matters.+ self.resize(min(900, int(avail.width() * 0.98)), min(900, int(avail.height() * 0.96)))else:- self.resize(1000, 980)- self.setMinimumSize(560, 400)+ self.resize(900, 800)+ self.setMinimumSize(420, 300) # the scroll area carries everything below thisself._mono = QFontDatabase.systemFont(QFontDatabase.FixedFont)root = QWidget()@@ -47,8 +49,8 @@ class MainWindow(QMainWindow):body = QWidget()body.setObjectName('body')self.body = QVBoxLayout(body)- self.body.setContentsMargins(22, 20, 22, 18)- self.body.setSpacing(14)+ self.body.setContentsMargins(12, 10, 12, 10)+ self.body.setSpacing(8)scroll.setWidget(body)outer.addWidget(scroll, 1)@@ -75,11 +77,11 @@ class MainWindow(QMainWindow):def _build_header(self) -> None:row = QHBoxLayout()- row.setSpacing(14)+ row.setSpacing(8)badge = QLabel('🎮')- badge.setFixedSize(54, 54)+ badge.setFixedSize(40, 40)badge.setAlignment(Qt.AlignCenter)- badge.setStyleSheet(f'background: {GREEN}; border-radius: 13px; font-size: 26px;')+ badge.setStyleSheet(f'background: {GREEN}; border-radius: 10px; font-size: 18px;')row.addWidget(badge)left = QVBoxLayout()left.setSpacing(3)@@ -102,10 +104,10 @@ class MainWindow(QMainWindow):box = QFrame()box.setObjectName('card')lay = QVBoxLayout(box)- lay.setContentsMargins(18, 16, 18, 16)- lay.setSpacing(10)+ lay.setContentsMargins(12, 10, 12, 10)+ lay.setSpacing(6)head = QHBoxLayout()- head.setSpacing(8)+ head.setSpacing(6)t = QLabel(title)f = t.font()f.setBold(True)@@ -160,8 +162,8 @@ class MainWindow(QMainWindow):self.folder_label.setObjectName('mono')lay.addWidget(self.folder_label)grid = QGridLayout()- grid.setHorizontalSpacing(10)- grid.setVerticalSpacing(9)+ grid.setHorizontalSpacing(8)+ grid.setVerticalSpacing(4)grid.setColumnStretch(2, 1)self.input_rows: dict[str, tuple[QLabel, QLabel]] = {}specs = [('base', 'data.base', False), ('update', 'data.update', True),@@ -170,12 +172,12 @@ class MainWindow(QMainWindow):dot = QLabel('○')dot.setFixedWidth(14)name = QLabel(self.m.t(l10n))- name.setFixedWidth(150)+ name.setFixedWidth(110)val = QLabel('—')val.setObjectName('mono')val.setTextInteractionFlags(Qt.TextSelectableByMouse)btn = QPushButton(self.m.t('data.choose'))- btn.setFixedWidth(92)+ btn.setFixedWidth(72)btn.clicked.connect(lambda _=False, k=key: self._choose_input(k))grid.addWidget(dot, i, 0)grid.addWidget(name, i, 1)@@ -205,7 +207,7 @@ class MainWindow(QMainWindow):head.addWidget(recheck)lay.addLayout(head)self.deps_container = QVBoxLayout()- self.deps_container.setSpacing(7)+ self.deps_container.setSpacing(3)lay.addLayout(self.deps_container)def _build_progress(self) -> None:@@ -216,7 +218,7 @@ class MainWindow(QMainWindow):self.overall.setTextVisible(False)lay.addWidget(self.overall)self.stages_container = QVBoxLayout()- self.stages_container.setSpacing(7)+ self.stages_container.setSpacing(3)lay.addLayout(self.stages_container)def _build_log(self) -> None:@@ -224,18 +226,18 @@ class MainWindow(QMainWindow):self.log.setReadOnly(True)self.log.setFont(self._mono)self.log.setPlaceholderText(self.m.t('log.placeholder'))- self.log.setMinimumHeight(150)+ self.log.setMinimumHeight(90)self.log.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)self.body.addWidget(self.log, 1)def _build_footer(self) -> None:wrap = QWidget()row = QHBoxLayout(wrap)- row.setContentsMargins(22, 10, 22, 12)+ row.setContentsMargins(12, 6, 12, 8)row.setSpacing(10)self.build_btn = QPushButton(self.m.t('build.start'))self.build_btn.setObjectName('primary')- self.build_btn.setMinimumWidth(150)+ self.build_btn.setMinimumWidth(110)self.build_btn.clicked.connect(self._build_clicked)row.addWidget(self.build_btn)self.footer = QLabel('')@@ -311,13 +313,13 @@ class MainWindow(QMainWindow):row = QWidget()h = QHBoxLayout(row)h.setContentsMargins(0, 0, 0, 0)- h.setSpacing(8)+ h.setSpacing(6)mark = QLabel('●' if d.ok else ('◐' if d.state is DepState.OLD else '✕'))mark.setFixedWidth(14)mark.setStyleSheet(f'color: {GREEN if d.ok else (ORANGE if d.state is DepState.OLD else RED)};')h.addWidget(mark)name = QLabel(self.m.t(d.title_key))- name.setFixedWidth(190)+ name.setFixedWidth(140)h.addWidget(name)detail = d.detailif detail.startswith('dep.'):@@ -373,7 +375,7 @@ class MainWindow(QMainWindow):row = QWidget()h = QHBoxLayout(row)h.setContentsMargins(0, 0, 0, 0)- h.setSpacing(8)+ h.setSpacing(6)mark = {'done': '●', 'running': '◐', 'failed': '✕'}.get(st.state, '○')colour = {'done': GREEN, 'failed': RED}.get(st.state, MUTED)lab = QLabel(mark)diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex 66d9e90d..520ed101 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -85,8 +85,8 @@ enum L10n {"repo.pulled": ("已更新到最新", "Updated to the latest"),"repo.pullFail": ("更新失败——详情见日志(本地文件被改过?)","Update failed — see the log (local changes?)"),- "repo.gitMissing": ("没找到 git:在终端运行 xcode-select --install 装一下命令行工具",- "git not found: run xcode-select --install in Terminal to get the Command Line Tools"),+ "repo.gitMissing": ("没找到 git:Windows 请到 git-scm.com 下载安装,macOS 运行 xcode-select --install",+ "git not found: install it from git-scm.com (Windows), or run xcode-select --install (macOS)"),"repo.netFail": ("检查更新失败(网络不通?)", "Could not check for updates (offline?)"),// ---- game data ----@@ -127,6 +127,27 @@ enum L10n {"dep.checking": ("检测中…", "Checking…"),"dep.allReady": ("全部就绪", "All ready"),"dep.missing": ("缺 %d 项", "%d missing"),+ "dep.llvm": ("LLVM-MinGW(交叉编译)", "LLVM-MinGW (cross compiler)"),+ "dep.llvm.hint": ("Windows 上编译 iOS 二进制用(app 内自动下载)",+ "builds the iOS binary on Windows (downloaded in-app)"),+ "dep.llvm.downloading": ("正在下载 LLVM-MinGW…(约 250 MB)", "Downloading LLVM-MinGW… (about 250 MB)"),+ "dep.llvm.done": ("LLVM-MinGW 已安装:%@", "LLVM-MinGW installed: %@"),+ "dep.lld": ("Mach-O 链接器(ld64.lld)", "Mach-O linker (ld64.lld)"),+ "dep.lld.hint": ("随 LLVM-MinGW 提供", "comes with LLVM-MinGW"),+ "dep.iossdk.downloading": ("正在下载 iPhoneOS SDK…(约 100 MB)",+ "Downloading the iPhoneOS SDK… (about 100 MB)"),+ "dep.iossdk.done": ("iPhoneOS SDK 已安装:%@", "iPhoneOS SDK installed: %@"),+ "dep.probe.compile": ("试编译 arm64 Mach-O", "trial compile to arm64 Mach-O"),+ "dep.probe.compile.hint": ("验证 clang 真能产出 iOS 目标文件",+ "checks that clang really produces iOS objects"),+ "dep.probe.link": ("试链接 iOS 可执行文件", "trial link to an iOS executable"),+ "dep.probe.link.hint": ("验证 ld64.lld 能链接", "checks that ld64.lld links"),+ "dep.probe.metal": ("试编译 Metal 着色器", "trial Metal shader compile"),+ "dep.probe.metal.hint": ("验证 metal.exe 能产出 metallib",+ "checks that metal.exe produces a metallib"),+ "dep.optionalMissing": ("可选,未安装", "optional, not installed"),+ "dep.glslang": ("glslangValidator(可选)", "glslangValidator (optional)"),+ "dep.glslang.hint": ("仅 OpenGL 游戏需要", "only needed for OpenGL games"),"dep.installAll": ("一键安装全部缺失项", "Install all missing"),"dep.recheck": ("重新检测", "Check again"),"dep.install": ("安装", "Install"),