Skip to content

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

The Mac app stops picking a Python the build script will reject (issue #53)

LNPANDY1a5b7f656689
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swift
index 82795015..0c77ee05 100644
--- a/frontend/Sources/NSPortBuilder/ContentView.swift
+++ b/frontend/Sources/NSPortBuilder/ContentView.swift
@@ -664,7 +664,11 @@ final class BuildModel: ObservableObject {
fail(repoPath.isEmpty ? t("msg.repoInvalidEmpty") : String(format: t("msg.repoInvalid"), shortPath(repoPath)))
return
}
- let py = pythonPath.isEmpty ? "/usr/bin/python3" : pythonPath
+ // 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 pythonPath is
+ // empty, and the old fallback was Apple's /usr/bin/python3 (3.9), which the script then
+ // rejected with "require Python 3.12 or newer" whatever the machine actually had (#53).
+ let py = pythonPath.isEmpty ? Self.findPython().path : pythonPath
// One folder when everything lives together; otherwise a staging folder of symlinks. A folder
// that holds other games too (a ROMs folder with one file per game) is staged as well: the
@@ -1396,7 +1400,12 @@ final class BuildModel: ObservableObject {
/// The minimum the build scripts need. /usr/bin/python3 is 3.9 on a stock Mac and has none of
/// the packages; picking it made a build fail with a syntax error deep inside the script
/// (an f-string only 3.12 can parse) instead of a clear message here.
- nonisolated static let minPython = (3, 9)
+ ///
+ /// 3.12 is the script's own floor, not a guess: build_ipa_from_nsp.py:1911 raises "Direct
+ /// RomFS image builds require Python 3.12 or newer". This said 3.9 — the comment above even
+ /// said 3.12 — so findPython() was happy to return Apple's 3.9 and the build then died inside
+ /// the script with a message the user could not act on (issue #53).
+ nonisolated static let minPython = (3, 12)
/// The interpreter probe: lz4 / capstone / fontTools always, and zstd from either source —
/// `compression.zstd` is built in from Python 3.14 and `backports.zstd` (which declares
diff --git a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
index 52696202..20b9fddf 100644
--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift
@@ -798,4 +798,19 @@ final class LibraryTests: XCTestCase {
XCTAssertEqual(BuildModel.titleID("/ROMs/TotK [01007EF00011E000].xci"), 0x01007EF00011E000)
XCTAssertNil(BuildModel.titleID("no title id here.nsp"))
}
+
+ /// Issue #53: the interpreter floor is the script's own, so Apple's 3.9 is never picked.
+ func testThePythonFloorIsTheScriptsOwnThreeTwelve() {
+ XCTAssertEqual(BuildModel.minPython.0, 3)
+ XCTAssertEqual(BuildModel.minPython.1, 12,
+ "build_ipa_from_nsp.py:1911 refuses anything below 3.12; a lower floor let the "
+ + "app pick /usr/bin/python3 and the build died in the script")
+ let (path, _) = BuildModel.findPython()
+ XCTAssertFalse(path.isEmpty, "a Mac with any usable interpreter must yield one")
+ if let v = BuildModel.pythonVersion(path) {
+ let floor = BuildModel.minPython
+ XCTAssertTrue(v.0 > floor.0 || (v.0 == floor.0 && v.1 >= floor.1),
+ "picked \(path) at \(v.0).\(v.1), below the \(floor.0).\(floor.1) floor")
+ }
+ }
}