Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Experimental builder: pass the script's whole command line to nxb build, pin nxbuild 0.5.1, version 1.2.2

v0lumehi98c03408ef43
diff --git a/BUILDING.md b/BUILDING.md
index da042dea..52b88be1 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -68,9 +68,10 @@ NXB_ENGINE=engine nxb build <NSP folder> --platform mac-app -k <prod.keys> --tit
-o <app> --work-dir <build folder> --engine engine --progress json
```
-- The program is the `nxb` binary the player chose in Settings (the binary, or the folder that holds it), else the copy inside the app. This repository bundles no binary. It needs an `nxb` that has `build`.
+- The program is the `nxb` binary the player chose in Settings (the binary, or the folder that holds it), else the copy inside the app, which `frontend/nxbuild.pin` names. It needs nxb 0.5.1 or newer: the launcher reads `nxb version` first and stops with a message when the nxb is older.
+- The command line is the script's own: the launcher builds the arguments it gives the script (input folder, `.nup` file or dump folder, `-k`, `--work-dir`, `--platform`, `-o`, `--shell-framework`, `--team-id`, `--romfs`, `--env-file`) and runs `nxb build` with them, so the same cases reach nxb. DLC, NSZ, XCI and merged packages in the folder are found by nxb itself. A game with no profile is surveyed by nxb, and the launcher does not pass `--no-heap-check`, as it does not for the script, so nxb stops with exit code 4 and names the step it cannot do yet.
- `--progress json` prints one JSON event per line (`stage`, `step`, `progress`, `stage_end`, `say`, each with `code` and `severity`). The launcher shows them as its own stages and writes every line to the build log.
-- There is no fallback. A case `nxb build` does not take stops before the build with the reason: an iPhone or iPad build, an NSZ, an XCI, a game folder or a NUP, and add-on content (DLC). A failure shows nxb's exit code and its last error line. The exit codes are 0 done, 1 error, 2 bad arguments, 3 damaged data, 4 not supported yet, 6 missing key and 130 interrupted. Turning the setting off builds with the script again.
+- There is no fallback. A failure, or a game or step nxb does not take, shows nxb's exit code in words and its last error line. The exit codes are 0 done, 1 error, 2 bad arguments, 3 damaged data, 4 not supported yet, 6 missing key and 130 interrupted. Turning the setting off builds with the script again.
## Build the IPA
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fdbf0640..3f4ce254 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ Newest first. The fork follows upstream daily, so its game list and host fixes a
| Date | Version | What changed |
|---|---|---|
+| 2026-11-06 | v1.2.2 | **New**: the experimental builder (Settings, Use experimental builder) now builds the whole game with nxbuild: the launcher runs `nxb build` and does not run the build script at all, for a Mac app and for the iPhone and iPad options. It reads NSP, NSZ, XCI, merged packages, a NUP, a game folder and DLC, and surveys a game with no profile. There is no fallback to the script: a case nxb does not take, or a failure, shows nxb's exit code and its last error line. It needs nxb 0.5.1 or newer, which the app bundles when its release is pinned. The setting is off by default and nothing changes for a default build. Not yet run on a device: the iPhone and iPad path, and the new input kinds on real game files (#749) |
| 2026-11-06 | v1.2.1 | **New**: Steam Controller (2026) over USB-C, Bluetooth and the Puck, with per-game mappings in the launcher, games must be rebuilt, by @thehobbit85 (#764, #731). A note in Launch options that says why a game has no resolution setting, by @Haseenesss (#574, #754). **Fixed**: the Mac launcher builds a Switch 2 NUP or a game folder of a game with no profile when the engine can survey it, the game itself does not run yet and needs upstream work (seedds/nxnative#1299), the Qt launcher still refuses it, reported by @xdgpx (#748, #783). The Mac host build uses the selected Python, reported by @temmiegreen, by @thehobbit85 (#711, #729). Windows finds `python.exe` in the install folder when it chains into the venv (#774). 20 Italian shell texts reworded by @zatteogit (#744). The README says Switch 2 games need no `prod.keys`, by @rivitt (#734). The compatibility switch for older iPhones and iPads writes the key the game reads, by @thehobbit85 (#719, #723). Build progress and log stay across launcher windows, by @thehobbit85 (#405, #724). A failure row for low disk space while building the Metal archive, by @thehobbit85 (#463, #725). `DM_PSO_BUNDLE=off` from env files works on iPhone and iPad, by @thehobbit85 (#726). The Tool tests job reports engine test failures and the shell and language-row tests are repaired (#690, #698, #722, #727, #728, #786) |
| 2026-11-05 | v1.2.0 | **Fixed**: wrong library covers such as a Switch 2 Edition or a bundle instead of the game, 164 of 167 titles with several shop products now pick the game, reported by @zatteogit (#403, #632). About 120 iPhone shell texts that were English in German, Swedish, French and Italian, and three error messages that were English everywhere, now in six languages, machine translated and waiting for review (#631). SideStore installs of a shared IPA with a very large shader tree, by @Silverhza (#587, #593). iPhone Duo rotation and the tabletop layout, by @jonochocki (#642). Game files with an upper case extension (#554). Games in a subfolder whose update or DLC sits in a sibling subfolder (#760, #762). The Mac app build on a disk without an atomic swap (#595, #742). The game language row for a Switch 2 game with a NUP update (#619). The game language row for a Switch 2 game with no control data, read from the game's own files, on the Mac and on iPhone and iPad (#668, #693). The iPhone quit prompt text (#620), the game data out of the iCloud backup (#618), the iPhone and iPad shell controller input order and tap echo guard by @Haseenesss (#660), the console mode pointer staying hidden while a game starts by @Haseenesss (#380, #741), the Windows engine recovery crash (#613), and the Windows Python install chaining directly into the venv and offline wheels setup plus 1.2 engine `tree_tar` and single-file shader library support (#765, #772). The stale shader notice popup for both reasons, texts waiting for a native review, by @djdev0010 (#320, #470). **New**: engine pin `777a5f6c618a` with 105 upstream commits, Mario Kart World, Mario Tennis Fever, Super Mario 3D All-Stars and more (#689), and `7249ee9f95ed` with 28 more upstream commits, Star Fox (Switch 2), Yoshi and the Mysterious Book (Switch 2) and DRAGON QUEST BUILDERS 2 at 60 fps, up to 120 fps for Fire Emblem Fortune's Weave and Mario & Luigi: Brothership, and single-file shader libraries and compile caches, by upstream's notes and not played by us, built games are rebuilt on the first Play (#712, #761). The Windows release (`NX2Apple-windows-x64.zip`) on the releases page with the 1.2.0 interface, the bundled engine tree so a Windows player needs no git, multi-core parallel NSO rewriting, cache management and an in-place iPhoneOS 27.2 SDK upgrade (#615, #616, #765, #768, #771, #772). Each iPhone and iPad game framework carries its own host binary (`loader: "FH"`), so future engine updates no longer require rebuilding existing games before they can start (#451, #756). Experimental builder (`nxbuild 0.2.0`, off by default) for Rust extraction and shader splitting of NSP, XCI, NSZ, dump folders and Switch 2 `.nup` packages (#749, #752, #766, #767). Split a Bluetooth Joy-Con pair into two sideways controllers on the Mac (#740, #745, #770). iPhone Duo side column for the chips and Back (#622, #633). "Preparing game…" after Play, by @Silverhza (#652). 24 Italian texts reworded, by @zatteogit and @Dino0005 (#687, #704). The .NET check follows the dotnet the build runs, by @oliphantaaron (#342). **Known issues**: of the Switch 2 games only Donkey Kong Bananza was tried, through the launcher on a Mac, an iPhone and an iPad (#445), the Switch 2 game language list is not seen on a device and has no Thai or Polish (#693), of the Switch 2 games only Donkey Kong Bananza has a store cover (#632), and the Duo side column is only checked in the Simulator (#622) |
| 2026-11-03 | v1.1.0 | **Switch 2 games in the launcher** (#603, #604, #605, #606, #607, #608, #609, #610): the Mac and the Windows launcher take a Switch 2 game folder or a `.nup` file, with no `prod.keys`. Games get a Switch 2 mark and a note for the chosen target, the build stages have names in every language, and a failure row says when the keys are older than the game. Nobody has played one through the launcher yet. **Touch controls** (#582, #581, #580, #600): a size setting, a left stick place, a hint for the right stick of the 3D layout, and an editor in the shell settings that moves each control. **Quit and delete**: hold the controller's Home button for 2 seconds to quit a Mac game on macOS 27 (#579). On iPhone and iPad, the gear menu in the game or a Home hold quits, and the app closes and opens on the library (#601). Delete a game from the launcher, with its saves kept unless chosen (#562). **Also new**: Cloud saves folder in the Mac launcher (#561), Start in console mode (#565), controller button mapping on iPhone and iPad by @Haseenesss (#495, #576), picture Fill or Fit (#575), iPhone Duo layouts by @jonochocki (#230), per-game mods and env.txt (#573, #566), moving the cache folder (#584, #567), the Finder way to send game data (#586), a clearer framework error (#568). **Engine pin** `641d1480021a` (#598): new Switch 2 and other games, by upstream's notes, not played by us. **Fixed**: NSPs without a title ID in the file name by @Haseenesss (#548), the Duo outer screen row (#563), the Windows IPA handoff by @tmrsm (#182), the Windows first sync (#597, #602). **Docs**: README in German, Swedish and French (#569), Italian documents by @PikaMan80 (#527), Italian texts reviewed by @Dino0005 (#541, #570). Requires macOS 27 for the Home quit. |
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index 1e2c2e30..5f74f39d 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -6,6 +6,7 @@ NX2Apple 的版本历史,最新在上,每个版本的完整说明见[发布
| 日期 | 版本 | 变更 |
|---|---|---|
+| 2026-11-06 | v1.2.2 | **新增**:实验性构建器(设置里的「使用实验性构建器」)现在用 nxbuild 构建整个游戏:启动器直接运行 `nxb build`,完全不运行构建脚本,Mac App 和 iPhone、iPad 选项都是如此。它读取 NSP、NSZ、XCI、合并包、NUP、游戏文件夹和 DLC,并勘测没有配置的游戏。不会退回脚本:nxb 不支持的情况或失败时,会显示 nxb 的退出代码和最后一条错误。需要 nxb 0.5.1 或更新版本,固定版本后 App 会自带。该设置默认关闭,默认构建不受影响。尚未在真机上运行:iPhone 和 iPad 路径,以及真实游戏文件的新输入类型(#749) |
| 2026-11-06 | v1.2.1 | **新增**:Steam Controller(2026)支持 USB-C、蓝牙和 Puck,启动器里有每个游戏的映射,旧游戏需要重新构建,作者 @thehobbit85(#764、#731)。启动选项里新增说明游戏为什么没有分辨率设置的提示,作者 @Haseenesss(#574、#754)。**修复**:引擎能勘测游戏时,Mac 启动器可以构建没有配置的 Switch 2 NUP 或游戏文件夹,游戏本身还不能运行,需要上游的工作(seedds/nxnative#1299),Qt 启动器仍然拒绝,由 @xdgpx 报告(#748、#783)。Mac 宿主构建使用所选的 Python,由 @temmiegreen 报告,作者 @thehobbit85(#711、#729)。Windows 链接虚拟环境时在安装文件夹里找到 `python.exe`(#774)。@zatteogit 改写了 20 条意大利语壳 App 文字(#744)。README 说明 Switch 2 游戏不需要 `prod.keys`,作者 @rivitt(#734)。老 iPhone 和 iPad 的兼容开关写入游戏读取的键,作者 @thehobbit85(#719、#723)。构建进度和日志在多个启动器窗口之间保持,作者 @thehobbit85(#405、#724)。构建 Metal 归档时磁盘空间不足有了失败提示,作者 @thehobbit85(#463、#725)。env 文件里的 `DM_PSO_BUNDLE=off` 在 iPhone 和 iPad 上生效,作者 @thehobbit85(#726)。Tool tests 任务会报告引擎测试失败,壳 App 和语言行测试已修复(#690、#698、#722、#727、#728、#786) |
| 2026-11-05 | v1.2.0 | **修复**:游戏库封面不对(选成 Switch 2 版或套装而不是游戏本身),在有多个商店商品的 167 个游戏里 164 个现在选对,由 @zatteogit 报告(#403、#632)。约 120 条 iPhone 壳 App 文字在德语、瑞典语、法语和意大利语里是英文,另有三条错误信息在所有语言里都是英文,现已有六种语言,机器翻译,等待审校(#631)。着色器文件很多的共用 IPA 用 SideStore 安装失败,作者 @Silverhza(#587、#593)。iPhone Duo 旋转和桌面布局,作者 @jonochocki(#642)。扩展名为大写的游戏文件(#554)。子文件夹里的基础游戏与同级子文件夹里的更新或 DLC 自动关联(#760、#762)。在不支持原子替换的磁盘上构建 Mac App(#595、#742)。带 NUP 更新的 Switch 2 游戏的语言一行(#619)。没有控制数据的 Switch 2 游戏的语言一行,读自游戏自己的文件,Mac 和 iPhone、iPad 上都有(#668、#693)。iPhone 退出提示文字(#620)、游戏数据不进 iCloud 备份(#618)、iPhone 和 iPad 壳 App 手柄输入事件顺序与触控回声保护,作者 @Haseenesss(#660)、主机模式启动游戏期间鼠标指针保持隐藏,作者 @Haseenesss(#380、#741)、Windows 引擎恢复崩溃(#613),以及 Windows 安装 Python 后直接连装虚拟环境与内置离线 wheel 包、iOS 交叉构建支持 1.2 引擎 `tree_tar` 和单文件着色器库(#765、#772)。过期着色器提示在两种原因下都会弹出,文字等待母语者审校,作者 @djdev0010(#320、#470)。**新增**:引擎版本 `777a5f6c618a`(含上游 105 个提交,Mario Kart World、Mario Tennis Fever、Super Mario 3D All-Stars 等,#689)及 `7249ee9f95ed`(再进上游 28 个提交,Star Fox(Switch 2)、Yoshi and the Mysterious Book(Switch 2)和 DRAGON QUEST BUILDERS 2 60 帧,Fire Emblem Fortune's Weave 和 Mario & Luigi: Brothership 最高 120 帧,单文件着色器库与编译缓存,#712、#761),按上游的说明,我们没有玩过,已构建的游戏第一次点 Play 会重新构建。Windows 正式版(`NX2Apple-windows-x64.zip`)随发布页提供,对齐 1.2.0 界面并自带引擎目录(Windows 玩家不需要 git),支持多核并行 NSO 重写、缓存管理及就地升级到 iPhoneOS 27.2 SDK(#615、#616、#765、#768、#771、#772)。iPhone 和 iPad 每个游戏框架自带独立宿主二进制(`loader: "FH"`),后续引擎更新不再强制已构建游戏重新构建才能启动(#451、#756)。实验性构建器(`nxbuild 0.2.0`,默认关闭),用 Rust 快速完成 NSP、XCI、NSZ、解包目录及 Switch 2 `.nup` 软件包的解包与着色器拆分(#749、#752、#766、#767)。Mac 端支持将一对蓝牙 Joy-Con 拆分为两个独立横握手柄(#740、#745、#770)。iPhone Duo 侧边栏放置按钮和返回键(#622、#633)。点 Play 后显示「Preparing game…」,作者 @Silverhza(#652)。24 条意大利语文字改写,作者 @zatteogit 和 @Dino0005(#687、#704)。「.NET 检查」跟随构建实际使用的 dotnet,作者 @oliphantaaron(#342)。**已知问题**:Switch 2 游戏里只试过 Donkey Kong Bananza,通过启动器在 Mac、iPhone 和 iPad 上玩过(#445),Switch 2 游戏的语言列表没有在真机上看过,也没有泰语和波兰语(#693),Switch 2 游戏里只有 Donkey Kong Bananza 有商店封面(#632),Duo 侧边栏只在模拟器里检查过(#622) |
| 2026-11-03 | v1.1.0 | **启动器里的 Switch 2 游戏**(#603、#604、#605、#606、#607、#608、#609、#610):Mac 和 Windows 启动器可以选择 Switch 2 游戏文件夹或 `.nup` 文件,不需要 `prod.keys`。游戏带 Switch 2 标记和按目标显示的说明,构建阶段的名称有所有语言的版本,密钥比游戏旧时有专门的失败提示。还没有人通过启动器玩过。**触控按键**(#582、#581、#580、#600):大小设置、左摇杆位置、3D 布局右摇杆的提示,以及壳 App 设置里移动每个按键的编辑器。**退出和删除**:在 macOS 27 上按住手柄 Home 键 2 秒退出 Mac 游戏(#579)。在 iPhone 和 iPad 上,从游戏内齿轮菜单或按住 Home 退出,App 会关闭并在下次回到游戏库(#601)。在启动器里删除游戏,除非选择一并删除,否则存档保留(#562)。**其他新增**:Mac 启动器的云存档文件夹(#561)、启动时进入主机模式(#565)、iPhone 和 iPad 的手柄按键映射,作者 @Haseenesss(#495、#576)、画面填充或适应(#575)、iPhone Duo 布局,作者 @jonochocki(#230)、每个游戏的 mod 和 env.txt(#573、#566)、移动缓存文件夹(#584、#567)、用 Finder 发送游戏数据(#586)、更清楚的框架错误(#568)。**引擎固定点** `641d1480021a`(#598):新增 Switch 2 等游戏,出自上游的说明,我们没有玩过。**修复**:文件名里没有 title ID 的 NSP,作者 @Haseenesss(#548)、Duo 外屏的游戏行(#563)、Windows 的 IPA 交接,作者 @tmrsm(#182)、Windows 首次同步(#597、#602)。**文档**:德语、瑞典语和法语 README(#569)、意大利语文档,作者 @PikaMan80(#527)、由 @Dino0005 审校的意大利语文字(#541、#570)。用 Home 键退出需要 macOS 27。 |
diff --git a/frontend/Sources/NXCore/ExperimentalBuilder.swift b/frontend/Sources/NXCore/ExperimentalBuilder.swift
index 566f751a..d19fa40c 100644
--- a/frontend/Sources/NXCore/ExperimentalBuilder.swift
+++ b/frontend/Sources/NXCore/ExperimentalBuilder.swift
@@ -36,19 +36,26 @@ package enum ExperimentalBuilder {
["NXB_ENGINE": engine]
}
- /// The command line of `nxb build` for a Mac app, in the NSP script's own names. `inputDir` holds one game's NSPs.
- /// No `--gpu`: nxb builds no pipeline archive then, where the script made one for this Mac's GPU.
- package static func buildArguments(inputDir: String, keys: String, titleID: String, out: String, workDir: String, engine: String) -> [String] {
- ["build", inputDir, "--platform", "mac-app", "-k", keys, "--title-id", titleID, "-o", out, "--work-dir", workDir, "--engine", engine, "--progress", "json"]
+ /// The oldest nxbuild that has the whole `nxb build` command line of the NSP script (NSZ, XCI, merged packages, a NUP, a dump folder, DLC, a game with no profile, the iPhone options).
+ package static let minimumVersion = "0.5.1"
+
+ /// The command line of `nxb build` from the script's: the same options in the same names, with `build` in place of the script's path (the first element).
+ package static func arguments(fromScript args: [String]) -> [String] {
+ ["build"] + args.dropFirst()
}
- /// The string key of what `nxb build` does not take, nil when it takes the case. The inputs are what the player picked:
- /// `iPhone` is a build for an iPhone or iPad, `gameFolder` a game's files as a folder or a NUP, `compressed` an NSZ or XCZ, `card` an XCI, `dlc` add-on content.
- package static func unsupportedKey(mac: Bool, gameFolder: Bool, compressed: Bool, card: Bool, dlc: Bool) -> String? {
- if !mac { return "nxb.unsupported.target" }
- if gameFolder || compressed || card { return "nxb.unsupported.input" }
- if dlc { return "nxb.unsupported.dlc" }
- return nil
+ /// Whether the output of `nxb version` ("nxb 0.5.1") names a version of at least `minimum`. A text with no version in it is too old.
+ package static func isNewEnough(_ output: String, minimum: String = minimumVersion) -> Bool {
+ func parts(_ s: String) -> [Int]? {
+ let numbers = s.split(whereSeparator: { !"0123456789.".contains($0) }).first { $0.first?.isNumber == true }
+ return numbers.map { $0.split(separator: ".").compactMap { Int($0) } }.flatMap { $0.isEmpty ? nil : $0 }
+ }
+ guard let have = parts(output), let want = parts(minimum) else { return false }
+ for i in 0..<max(have.count, want.count) {
+ let (h, w) = (i < have.count ? have[i] : 0, i < want.count ? want[i] : 0)
+ if h != w { return h > w }
+ }
+ return true
}
/// The string key of what nxb's exit code says (`nxb build`'s: 0 done, 1 error, 2 bad arguments, 3 damaged data, 4 not supported yet, 6 missing key, 130 interrupted).
diff --git a/frontend/Sources/NXModel/AppUpdateStore.swift b/frontend/Sources/NXModel/AppUpdateStore.swift
index b271ea1c..1c23b5b2 100644
--- a/frontend/Sources/NXModel/AppUpdateStore.swift
+++ b/frontend/Sources/NXModel/AppUpdateStore.swift
@@ -19,7 +19,7 @@ import NXCore
@MainActor package final class AppUpdateStore: ObservableObject {
/// Bump together with each release tag: the update check compares it with the latest release.
/// `build-mac-app.yml`, `sync-upstream.yml`, `tools/try-local` and `RELEASING.md` read this line. Keep it in this form.
- nonisolated package static let appVersion = "1.2.1"
+ nonisolated package static let appVersion = "1.2.2"
/// The version this store compares releases with: `appVersion`, unless a test passes another.
nonisolated package let version: String
diff --git a/frontend/Sources/NXModel/BuildStore+Builder.swift b/frontend/Sources/NXModel/BuildStore+Builder.swift
index 88f1e953..d6e20a04 100644
--- a/frontend/Sources/NXModel/BuildStore+Builder.swift
+++ b/frontend/Sources/NXModel/BuildStore+Builder.swift
@@ -10,18 +10,17 @@ extension BuildStore {
ExperimentalBuilder.resolve(customPath: experimentalBuilderPath, bundled: bundledBuilder)
}
- /// Why the build cannot start as `nxb build`, as the player's text: no nxb found, or an input or target nxb does not take. nil when it can start (or the switch is off).
- func experimentalBuilderProblem(gameFolder: Bool) -> String? {
+ /// Why the build cannot start as `nxb build`: no nxb found, or one that is older than the command line needs. The player's text, nil when it can start (or the switch is off).
+ /// A game or a target nxb does not take is not checked here: nxb says so itself (exit code 4) and the launcher shows it.
+ func experimentalBuilderProblem() -> String? {
guard experimentalBuilder else { return nil }
- if experimentalBuilderBinary == nil { return t("msg.builderMissingError") }
- let ext = ([basePath, updatePath] + dlcPaths).map { ($0 as NSString).pathExtension.lowercased() }
- return ExperimentalBuilder.unsupportedKey(mac: target == BuildTarget.mac, gameFolder: gameFolder, compressed: ext.contains { $0 == "nsz" || $0 == "xcz" },
- card: ext.contains("xci"), dlc: !dlcPaths.isEmpty).map(t)
+ guard let nxb = experimentalBuilderBinary, let version = runner.output(nxb, ["version"]) else { return t("msg.builderMissingError") }
+ return ExperimentalBuilder.isNewEnough(version) ? nil : String(format: t("nxb.tooOld"), version.trimmingCharacters(in: .whitespacesAndNewlines), ExperimentalBuilder.minimumVersion)
}
- /// The launch of `nxb build` for a Mac app: nxb as the program, the engine as its working folder and `NXB_ENGINE`, the tool environment the script gets.
- func experimentalLaunch(nxb: String, inputDir: String, workDir: String, engine: String, environment: [String: String], python: String) -> ProcessLaunch {
- let args = ExperimentalBuilder.buildArguments(inputDir: inputDir, keys: keysPath, titleID: buildKey, out: macAppPath, workDir: workDir, engine: engine)
+ /// The launch of `nxb build`: nxb as the program with the script's own arguments, the engine as its working folder and `NXB_ENGINE`, the tool environment the script gets.
+ func experimentalLaunch(nxb: String, scriptArguments: [String], engine: String, environment: [String: String], python: String) -> ProcessLaunch {
+ let args = ExperimentalBuilder.arguments(fromScript: scriptArguments)
say(String(format: t("msg.builderOn"), nxb) + " " + args.joined(separator: " "))
lastBuildCommand = [nxb] + args
return ProcessLaunch(executable: nxb, arguments: args, environment: environment.merging(ExperimentalBuilder.environment(engine: engine)) { $1 }, directory: engine, groupPython: python)
diff --git a/frontend/Sources/NXModel/BuildStore+Run.swift b/frontend/Sources/NXModel/BuildStore+Run.swift
index 5a69cbd1..6a7bfb0d 100644
--- a/frontend/Sources/NXModel/BuildStore+Run.swift
+++ b/frontend/Sources/NXModel/BuildStore+Run.swift
@@ -24,9 +24,9 @@ extension BuildStore {
fail(repo.path.isEmpty ? t("msg.repoInvalidEmpty") : String(format: t("msg.repoInvalid"), shortPath(repo.path)))
return
}
- // The experimental builder runs `nxb build` and never the script, so a case it does not take stops here with its reason (#749)
+ // The experimental builder runs `nxb build` and never the script: no nxb, or one too old, stops here (#749). A game nxb does not take ends with its own exit code 4
nxbRun = experimentalBuilder
- if let why = experimentalBuilderProblem(gameFolder: gameFolder != nil) { fail(why); return }
+ if let why = experimentalBuilderProblem() { fail(why); return }
// Resolve the interpreter here if the dependency check has not landed yet. checkDeps()
// runs on a background queue and startBuild() can beat it — for a moment deps.pythonPath is
// empty, and the old fallback was Apple's /usr/bin/python3 (3.9), which the script then
@@ -54,7 +54,7 @@ extension BuildStore {
// folder"), even when only the base game was picked (issue #58; ufooer's PR #31).
// A game folder (BuildStore+GameFolder.swift) goes to the script as it is: the engine must have its packer and the game's profile.
let folder = gameFolder
- if let folder, let why = gameFolderEngineProblem(folder) { fail(why); return }
+ if let folder, !nxbRun, let why = gameFolderEngineProblem(folder) { fail(why); return } // nxb reads the folder itself
let baseDir = inputFolder
let allPaths = folder != nil ? [] : [basePath, updatePath] + dlcPaths
let dirs = Set(allPaths.filter { !$0.isEmpty }.map { ($0 as NSString).deletingLastPathComponent })
@@ -108,7 +108,7 @@ extension BuildStore {
// option and would stop with "unrecognized arguments" (issue #5), so ask the script; without
// it the script's own default (<input>/<title ID>_build) is used and the archive step follows
// whatever folder the build reports.
- let hasWorkDir = RepoLayout.supportsWorkDir(repo.path)
+ let hasWorkDir = nxbRun || RepoLayout.supportsWorkDir(repo.path)
if !hasWorkDir {
say(t("msg.noWorkDir"))
}
@@ -119,7 +119,7 @@ extension BuildStore {
let e = ($0 as NSString).pathExtension.lowercased()
return e == "nsz" || e == "xcz"
}
- if compressed, !Toolchain.runOK(py, ["-c", "import nsz"]) {
+ if compressed, !nxbRun, !Toolchain.runOK(py, ["-c", "import nsz"]) { // nxb reads NSZ itself
say(t("msg.installingNsz"))
let r = runner.runCaptured([py, "-m", "pip", "install", "nsz"],
env: ["PATH": BuildCommands.toolPath(python: py),
@@ -182,7 +182,7 @@ extension BuildStore {
var denv = toolEnvironment(python: py)
if !oneGameIPAPath.isEmpty { denv.merge(OneGameIPA.environment) { $1 } }
let launch = nxbRun
- ? experimentalLaunch(nxb: experimentalBuilderBinary ?? "", inputDir: inputDir, workDir: workDir, engine: engine, environment: denv, python: py) // BuildStore+Builder.swift (#749)
+ ? experimentalLaunch(nxb: experimentalBuilderBinary ?? "", scriptArguments: args, engine: engine, environment: denv, python: py) // BuildStore+Builder.swift (#749)
: ProcessLaunch(executable: py, arguments: args, environment: denv, directory: engine, groupPython: py)
let onExit: @Sendable (Int32) -> Void = { [weak self] status in
hop {
diff --git a/frontend/Tests/NXCoreTests/ExperimentalBuilderTests.swift b/frontend/Tests/NXCoreTests/ExperimentalBuilderTests.swift
index c987bd23..a72f2950 100644
--- a/frontend/Tests/NXCoreTests/ExperimentalBuilderTests.swift
+++ b/frontend/Tests/NXCoreTests/ExperimentalBuilderTests.swift
@@ -27,25 +27,22 @@ final class ExperimentalBuilderTests: XCTestCase {
"an app built without a pinned release has no copy")
}
- func testNxbBuildGetsTheScriptsOptionsAndTheEngine() {
- let args = ExperimentalBuilder.buildArguments(inputDir: "/g", keys: "/k/prod.keys", titleID: "010015100B514000", out: "/o/W.app", workDir: "/o/w", engine: "/e")
- XCTAssertEqual(args.first, "build", "the one nxb binary: its subcommand")
- for pair in [["--platform", "mac-app"], ["-k", "/k/prod.keys"], ["--title-id", "010015100B514000"], ["-o", "/o/W.app"], ["--work-dir", "/o/w"], ["--engine", "/e"], ["--progress", "json"]] {
- XCTAssertEqual(args[args.firstIndex(of: pair[0])! + 1], pair[1], pair[0])
- }
+ func testNxbBuildGetsTheScriptsOptionsUnchanged() {
+ let script = ["/e/scripts/build_ipa_from_nsp.py", "/g", "-k", "/k/prod.keys", "--progress", "json", "--work-dir", "/o/w", "--platform", "mac-app", "-o", "/o/W.app"]
+ XCTAssertEqual(ExperimentalBuilder.arguments(fromScript: script), ["build"] + script.dropFirst(), "the one nxb binary: its subcommand in place of the script")
+ XCTAssertEqual(ExperimentalBuilder.arguments(fromScript: []), ["build"])
XCTAssertEqual(ExperimentalBuilder.environment(engine: "/e"), ["NXB_ENGINE": "/e"])
}
- func testWhatNxbBuildDoesNotTake() {
- func key(mac: Bool = true, folder: Bool = false, compressed: Bool = false, card: Bool = false, dlc: Bool = false) -> String? {
- ExperimentalBuilder.unsupportedKey(mac: mac, gameFolder: folder, compressed: compressed, card: card, dlc: dlc)
- }
- XCTAssertNil(key())
- XCTAssertEqual(key(mac: false), "nxb.unsupported.target")
- XCTAssertEqual(key(folder: true), "nxb.unsupported.input")
- XCTAssertEqual(key(compressed: true), "nxb.unsupported.input")
- XCTAssertEqual(key(card: true), "nxb.unsupported.input")
- XCTAssertEqual(key(dlc: true), "nxb.unsupported.dlc")
+ func testTheVersionThatHasTheWholeCommandLine() {
+ XCTAssertTrue(ExperimentalBuilder.isNewEnough("nxb 0.5.1\n"))
+ XCTAssertTrue(ExperimentalBuilder.isNewEnough("nxb 0.5.10"))
+ XCTAssertTrue(ExperimentalBuilder.isNewEnough("nxb 1.0.0"))
+ XCTAssertFalse(ExperimentalBuilder.isNewEnough("nxb 0.5.0"))
+ XCTAssertFalse(ExperimentalBuilder.isNewEnough("nxb 0.4.0"))
+ XCTAssertFalse(ExperimentalBuilder.isNewEnough("usage: nxb <command>"), "no version in it")
+ XCTAssertFalse(ExperimentalBuilder.isNewEnough(""))
+ XCTAssertTrue(ExperimentalBuilder.isNewEnough("nxb 0.5", minimum: "0.5.0"))
}
func testEveryExitCodeOfNxbHasItsOwnMessage() {
diff --git a/frontend/Tests/NXModelTests/BuildStoreTests.swift b/frontend/Tests/NXModelTests/BuildStoreTests.swift
index bb32f811..edd4d680 100644
--- a/frontend/Tests/NXModelTests/BuildStoreTests.swift
+++ b/frontend/Tests/NXModelTests/BuildStoreTests.swift
@@ -150,7 +150,7 @@ import XCTest
func testTheExperimentalBuilderIsOffByDefaultAndItsSettingIsSaved() {
let store = makeStore()
XCTAssertFalse(store.experimentalBuilder)
- XCTAssertNil(store.experimentalBuilderProblem(gameFolder: false), "off: nothing to say")
+ XCTAssertNil(store.experimentalBuilderProblem(), "off: nothing to say")
store.experimentalBuilder = true; store.experimentalBuilderPath = "/opt/nxbuild"
XCTAssertTrue(defaults.bool(forKey: BuildStore.experimentalBuilderKey))
XCTAssertEqual(defaults.string(forKey: BuildStore.experimentalBuilderPathKey), "/opt/nxbuild")
@@ -159,28 +159,24 @@ import XCTest
XCTAssertEqual(again.experimentalBuilderPath, "/opt/nxbuild")
}
- func testTheExperimentalBuilderStopsAnUnsupportedBuildWithItsReasonAndNeverRunsTheScript() throws {
+ func testTheExperimentalBuilderStopsWithoutANewEnoughNxbAndNeverRunsTheScript() throws {
let store = makeStore()
store.bundledBuilder = nil
+ XCTAssertNil(store.experimentalBuilderProblem(), "off: nothing to say")
store.experimentalBuilder = true
store.experimentalBuilderPath = temporary.path + "/gone/nxb"
XCTAssertNil(store.experimentalBuilderBinary)
- XCTAssertEqual(store.experimentalBuilderProblem(gameFolder: false), store.t("msg.builderMissingError"), "no nxb is an error, not a build by the script")
- let nxb = try file("nxb")
- try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: nxb)
+ XCTAssertEqual(store.experimentalBuilderProblem(), store.t("msg.builderMissingError"), "no nxb is an error, not a build by the script")
+ let old = try file("nxb")
+ try "#!/bin/sh\necho 'nxb 0.4.0'\n".write(toFile: old, atomically: true, encoding: .utf8)
+ try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: old)
store.experimentalBuilderPath = temporary.path // the folder that holds it
- XCTAssertEqual(store.experimentalBuilderBinary, nxb)
- store.target = BuildTarget.mac; store.take(picked: ["/g/Game [0100000000001000][v0].nsp"], kind: .base)
- XCTAssertNil(store.experimentalBuilderProblem(gameFolder: false))
- XCTAssertEqual(store.experimentalBuilderProblem(gameFolder: true), store.t("nxb.unsupported.input"))
- store.take(picked: ["/g/Game [0100000000001000].xci"], kind: .base)
- XCTAssertEqual(store.experimentalBuilderProblem(gameFolder: false), store.t("nxb.unsupported.input"))
- store.take(picked: ["/g/Game [0100000000001000].nsp"], kind: .base); store.take(picked: ["/g/DLC [0100000000001001].nsp"], kind: .dlc)
- XCTAssertEqual(store.experimentalBuilderProblem(gameFolder: false), store.t("nxb.unsupported.dlc"))
- store.clear("dlc"); store.target = "ios"
- XCTAssertEqual(store.experimentalBuilderProblem(gameFolder: false), store.t("nxb.unsupported.target"))
+ XCTAssertEqual(store.experimentalBuilderBinary, old)
+ XCTAssertEqual(store.experimentalBuilderProblem(), String(format: store.t("nxb.tooOld"), "nxb 0.4.0", ExperimentalBuilder.minimumVersion))
+ try "#!/bin/sh\necho 'nxb 0.5.1'\n".write(toFile: old, atomically: true, encoding: .utf8)
+ XCTAssertNil(store.experimentalBuilderProblem(), "a game or a target nxb does not take ends with its own exit code 4")
store.experimentalBuilder = false
- XCTAssertNil(store.experimentalBuilderProblem(gameFolder: true), "off again: the script takes every case")
+ XCTAssertNil(store.experimentalBuilderProblem())
}
func testAFailedNxbBuildSaysItsExitCodeAndItsLastErrorLine() {
diff --git a/frontend/l10n/en.json b/frontend/l10n/en.json
index 9d3d1867..3725aaed 100644
--- a/frontend/l10n/en.json
+++ b/frontend/l10n/en.json
@@ -1129,9 +1129,7 @@
"nxb.exit.4": "The experimental builder does not support this game or step yet (nxb exit code %d). Turn it off in Settings to build with the standard builder.",
"nxb.exit.6": "A key is missing from prod.keys (nxb exit code %d).",
"nxb.exit.other": "The build failed (nxb exit code %d).",
- "nxb.unsupported.dlc": "The experimental builder does not take add-on content (DLC) yet. Remove it from the build, or turn the builder off in Settings.",
- "nxb.unsupported.input": "The experimental builder reads NSP files only. NSZ, XCI, a game folder and a NUP are not supported yet. Turn it off in Settings to build this game.",
- "nxb.unsupported.target": "The experimental builder makes Mac apps only. Turn it off in Settings to build for an iPhone or iPad.",
+ "nxb.tooOld": "This nxb is too old (%@). The experimental builder needs nxb %@ or newer. Choose a newer one in Settings or turn the experimental builder off.",
"onboarding.back": "Back",
"onboarding.background.dotnet": ".NET",
"onboarding.background.installing": "Installing…",
diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.json
index edc1edfc..0811947f 100644
--- a/frontend/l10n/zh.json
+++ b/frontend/l10n/zh.json
@@ -1130,9 +1130,7 @@
"nxb.exit.4": "实验性构建器暂不支持此游戏或此步骤(nxb 退出代码 %d)。请在设置中将其关闭,改用标准构建器。",
"nxb.exit.6": "prod.keys 中缺少密钥(nxb 退出代码 %d)。",
"nxb.exit.other": "构建失败(nxb 退出代码 %d)。",
- "nxb.unsupported.dlc": "实验性构建器暂不支持附加内容(DLC)。请从本次构建中移除,或在设置中关闭构建器。",
- "nxb.unsupported.input": "实验性构建器目前只读取 NSP 文件,尚不支持 NSZ、XCI、游戏文件夹和 NUP。请在设置中将其关闭后再构建此游戏。",
- "nxb.unsupported.target": "实验性构建器只能构建 Mac 应用。要为 iPhone 或 iPad 构建,请在设置中将其关闭。",
+ "nxb.tooOld": "此 nxb 版本过旧(%@)。实验性构建器需要 nxb %@ 或更新版本。请在设置中选择较新的版本,或关闭实验性构建器。",
"onboarding.back": "返回",
"onboarding.background.dotnet": ".NET",
"onboarding.background.installing": "正在安装…",
diff --git a/frontend/nxbuild.pin b/frontend/nxbuild.pin
index 29206536..a2eac8b0 100644
--- a/frontend/nxbuild.pin
+++ b/frontend/nxbuild.pin
@@ -2,6 +2,6 @@
# build-mac-app.yml and tools/try-local run `frontend/tools/nxbuild.py fetch`: download the zip, check its SHA-256 against the line
# below, unpack nxb and sign it ad hoc. `frontend/tools/nxbuild.py bump <version>` writes a new version with its digest from the
# release's SHA256SUMS. A sha256 of PLACEHOLDER (no release yet) bundles nothing, and the setting then needs a chosen nxb.
-version 0.2.0
-sha256 2ec8f583ab9ff341e293ecd19e0aaf19c7200fa8676e265c0fdbcbbfc7f2f9f9
+version 0.5.1
+sha256 40573094bcb61d8aeb9298456c7a6ac50310d2975725f4ddb7826d472318ba7f
url https://github.com/v0lumehi/nxbuild/releases/download/v{version}/nxb-v{version}-macos-arm64.zip
diff --git a/frontend/tools/nxbuild.py b/frontend/tools/nxbuild.py
index 00c4f839..e1c6188b 100755
--- a/frontend/tools/nxbuild.py
+++ b/frontend/tools/nxbuild.py
@@ -27,8 +27,11 @@ def digest(path):
return h.hexdigest()
+DATA = ('rewrite-rules', 'own-front') # folders of the release that nxb finds next to its own file
+
+
def unpack(zip_path, expected, dest):
- """Check the zip against expected, then copy its nxb (wherever it sits in the zip) to dest/nxb. Returns that path"""
+ """Check the zip against expected, then copy its nxb (wherever it sits in the zip) to dest/nxb, and the data folders beside it. Returns the path of nxb"""
got = digest(zip_path)
if got != expected:
os.unlink(zip_path)
@@ -39,6 +42,13 @@ def unpack(zip_path, expected, dest):
dest.mkdir(parents=True, exist_ok=True)
out = dest / 'nxb'
out.write_bytes(z.read(names[0]))
+ # The data nxb reads from beside its own file (the rewrite rules, the own front end's verdicts), as the release lays them out next to nxb
+ root = Path(names[0]).parent
+ for n in z.namelist():
+ rel = Path(n).relative_to(root) if Path(n).is_relative_to(root) else None
+ if rel is None or n.endswith('/') or rel.parts[0] not in DATA or '..' in rel.parts: continue
+ (dest / rel).parent.mkdir(parents=True, exist_ok=True)
+ (dest / rel).write_bytes(z.read(n))
out.chmod(0o755)
return out
diff --git a/tools/tests/test_nxbuild_pin.py b/tools/tests/test_nxbuild_pin.py
index 9dcd4c3c..be225d94 100644
--- a/tools/tests/test_nxbuild_pin.py
+++ b/tools/tests/test_nxbuild_pin.py
@@ -29,6 +29,17 @@ class Pin(unittest.TestCase):
for n, b in files.items(): f.writestr(n, b)
return z
+ def test_the_data_folders_of_the_release_go_beside_nxb(self):
+ with tempfile.TemporaryDirectory() as t:
+ z = self.zip(t, {'nxb-v0.5.1/nxb': b'binary', 'nxb-v0.5.1/rewrite-rules/a.toml': b'rule', 'nxb-v0.5.1/own-front/x/y.tsv': b'v',
+ 'nxb-v0.5.1/README': b'r', 'nxb-v0.5.1/other/z': b'z', 'nxb-v0.5.1/rewrite-rules/../../evil': b'e'})
+ out = nxbuild.unpack(z, hashlib.sha256(z.read_bytes()).hexdigest(), Path(t, 'res/nxbuild'))
+ self.assertEqual(Path(t, 'res/nxbuild/rewrite-rules/a.toml').read_bytes(), b'rule')
+ self.assertEqual(Path(t, 'res/nxbuild/own-front/x/y.tsv').read_bytes(), b'v')
+ self.assertFalse(Path(t, 'res/nxbuild/other').exists() or Path(t, 'res/nxbuild/README').exists())
+ self.assertFalse(Path(t, 'res/evil').exists() or Path(t, 'evil').exists())
+ self.assertEqual(out.read_bytes(), b'binary')
+
def test_the_digest_is_checked_before_unpacking(self):
with tempfile.TemporaryDirectory() as t:
z = self.zip(t, {'nxb-v0.1.0/nxb': b'binary', 'nxb-v0.1.0/README': b'r'})