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
Launcher: iPhone / iPad is the shared app, the per-game IPA target is gone
v0lumehic198d0563dc4
diff --git a/README.md b/README.mdindex 0212e50f..80ec181e 100644--- a/README.md+++ b/README.md@@ -78,8 +78,9 @@ installs what it can with one click.manual ZIP route), checks the tools above and updates itself later. You never need git.4. **Build a game.** Pick the game's folder (or its base game, update, DLC and `prod.keys` one byone), choose **This Mac** or **iPhone / iPad**, and press build. The page shows the real stages and- the time left, and a stopped build continues where it left off. An iPhone build ends with the three- steps to put the app on the phone.+ the time left, and a stopped build continues where it left off. The **iPhone / iPad** target is one+ app on the device for all your games. The launcher signs it with Xcode, installs it and copies the+ game in. It needs a device paired with the Mac.Building by hand from a terminal is in [BUILDING.md](BUILDING.md).@@ -144,7 +145,8 @@ display version must match the profile's, or the build says so.AltStore Classic 2.2+, Impactor and Xcode with a Personal Team keep it; SideStore with a free AppleID needs a one-time App ID fix, and Sideloadly drops it ([the steps](ENTITLEMENTS.md)). Thefull measurements are in [GAMES.md](GAMES.md#verified-on).-- **Unsigned apps.** The launcher and the iPhone builds are not signed for you; you sideload them.+- **Unsigned launcher.** The launcher is not signed for you, so you sideload it. The iPhone app is signed+ by Xcode with your own team when the launcher installs it.- **Your own files.** No game data, firmware or keys are included or downloaded.- **Older shard archives are not read any more.** The first iPhone builds packed Tears of the Kingdominto a RomFS shard archive (`romfs.idx`); the build writes a single `romfs.img` now. An iPhonediff --git a/README.zh-CN.md b/README.zh-CN.mdindex 0423fd16..6d57993e 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -71,8 +71,8 @@ App 自带构建工具和 Python,不需要装 Homebrew 和 Python;.NET SDK 13. **按设置页走。** 启动器会取回构建用的项目(设置页上的「下载仓库」按钮,浅克隆到 `~/NX2Apple`;GitHub 不顺手时页面会给出手动 ZIP 的路线),检查上面的工具,之后还会自己更新。全程不需要懂 git。4. **构建游戏。** 选好游戏文件夹(或者分别选本体、更新包、DLC 和 `prod.keys`),选择「这台 Mac」或- 「iPhone / iPad」,按构建。页面显示真实的阶段和剩余时间,中途停止的构建会从上次继续。iPhone 构建- 结束时会给出装到手机的三步。+ 「iPhone / iPad」,按构建。页面显示真实的阶段和剩余时间,中途停止的构建会从上次继续。「iPhone / iPad」+ 是装在设备上、容纳你所有游戏的一个共用 App。启动器用 Xcode 为它签名、安装并拷入游戏,需要一台与这台 Mac 配对的设备。在终端里手动构建见 [BUILDING.zh-CN.md](BUILDING.zh-CN.md)。@@ -128,7 +128,7 @@ iPhone 上在「文件」App 里该 App 名字下:`save/` 和 `log.txt`(上约 3.4 GB,不够《王国之泪》用。App 请求了它,AltStore Classic 2.2+、Impactor 和 Xcode + Personal Team会保留;SideStore 配合免费 Apple ID 需要对 App ID 做一次性修复,Sideloadly 会丢掉它([步骤](ENTITLEMENTS.md))。完整的测量见 [GAMES.zh-CN.md](GAMES.zh-CN.md#验证情况)。-- **App 未签名。** 启动器和 iPhone 构建不会替你签名,需要你自己侧载。+- **启动器未签名。** 启动器不会替你签名,需要你自己侧载。iPhone 上的 App 在启动器安装时由 Xcode 用你自己的团队签名。- **你自己的文件。** 不包含也不下载任何游戏数据、固件或密钥。- **旧的分片归档不再被读取。** 最早的 iPhone 构建把《王国之泪》打成 RomFS 分片归档(`romfs.idx`);现在构建写出单个 `romfs.img`。仍保留旧归档的 iPhone 需要通过启动器把游戏数据重新发送一次(`romfs.img`)。diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.pyindex 56238d7f..013b6ad6 100644--- a/frontend-qt/nspb_qt/localization.py+++ b/frontend-qt/nspb_qt/localization.py@@ -942,6 +942,37 @@ TABLE: dict[str, tuple[str, str, str, str]] = {'pad.options': ('启动选项', 'Options', 'Alternativ', 'Optionen'),'pad.back': ('返回', 'Back', 'Tillbaka', 'Zurück'),'msg.archiveLog': ('归档:%@ → %@', 'Archive: %@ → %@', 'Arkiv: %@ → %@', 'Archiv: %@ → %@'),+ 'engine.title': ('构建引擎', 'Build engine', 'Byggmotor', 'Build-Engine'),+ 'engine.detail': ('%@ · 上游 %@', '%@ · upstream %@', '%@ · uppström %@', '%@ · Upstream %@'),+ 'engine.none': ('尚未准备好', 'Not set up yet', 'Inte förberedd än', 'Noch nicht eingerichtet'),+ 'engine.install': ('安装 %@', 'Install %@', 'Installera %@', '%@ installieren'),+ 'engine.update': ('引擎更新', 'Engine update', 'Motoruppdatering', 'Engine-Update'),+ 'engine.channelNote': ('稳定版是与本版本应用一起测试过的引擎。实验版跟随最新的上游,通过自动检查后发布。', 'Stable is the engine tested with this app version. Experimental follows the newest upstream and is published once it passes the automated checks.', 'Stabil är motorn som testats med den här appversionen. Experimentell följer senaste uppström och publiceras när den klarat de automatiska kontrollerna.', 'Stabil ist die Engine, die mit dieser App-Version getestet wurde. Experimentell folgt dem neuesten Upstream und erscheint, sobald sie die automatischen Prüfungen besteht.'),+ 'engine.channel.stable': ('稳定版', 'Stable', 'Stabil', 'Stabil'),+ 'engine.channel.experimental': ('实验版', 'Experimental', 'Experimentell', 'Experimentell'),+ 'engine.autoNote': ('打开应用时安装所选通道的新引擎', 'Installs a newer engine of the selected channel when the app opens', 'Installerar en nyare motor i den valda kanalen när appen öppnas', 'Installiert beim Öffnen der App eine neuere Engine des gewählten Kanals'),+ 'engine.preparing': ('正在准备引擎…', 'Preparing the engine…', 'Förbereder motorn…', 'Engine wird vorbereitet…'),+ 'engine.seedFail': ('无法把应用内的引擎复制到 Application Support。请检查可用空间后重新打开应用。', 'Could not copy the engine from the app into Application Support. Check the free space and open the app again.', 'Kunde inte kopiera motorn från appen till Application Support. Kontrollera ledigt utrymme och öppna appen igen.', 'Die Engine konnte nicht aus der App nach Application Support kopiert werden. Prüfe den freien Speicher und öffne die App erneut.'),+ 'engine.waitForBuild': ('正在构建。请在构建结束后再试。', 'A build is running. Try again when it has finished.', 'Ett bygge pågår. Försök igen när det är klart.', 'Ein Build läuft. Versuche es erneut, wenn er fertig ist.'),+ 'engine.checking': ('正在检查新引擎…', 'Checking for a new engine…', 'Söker efter en ny motor…', 'Suche nach einer neuen Engine…'),+ 'engine.switching': ('正在切换引擎…', 'Switching the engine…', 'Byter motor…', 'Engine wird gewechselt…'),+ 'engine.upToDate': ('引擎已是最新(%@)', 'The engine is up to date (%@)', 'Motorn är uppdaterad (%@)', 'Die Engine ist aktuell (%@)'),+ 'engine.available': ('引擎 %@ 可用', 'Engine %@ is available', 'Motor %@ finns', 'Engine %@ ist verfügbar'),+ 'engine.waitsForBuild': ('引擎 %@ 已安装。当前构建结束后切换到它。', 'Engine %@ is installed. The build tools switch to it when the running build has finished.', 'Motor %@ är installerad. Byggverktygen byter till den när det pågående bygget är klart.', 'Engine %@ ist installiert. Die Build-Werkzeuge wechseln zu ihr, wenn der laufende Build fertig ist.'),+ 'engine.installed': ('引擎 %@ 已安装', 'Engine %@ is installed', 'Motor %@ är installerad', 'Engine %@ ist installiert'),+ 'engine.chainChanged': ('引擎 %@ 已安装。着色器链已从 %@ 变为 %@,每个游戏下次构建时都会重新编译着色器。', 'Engine %@ is installed. The shader chain changed from %@ to %@, so every game compiles its shaders again on its next build.', 'Motor %@ är installerad. Shaderkedjan har ändrats från %@ till %@, så varje spel kompilerar sina shaders igen vid nästa bygge.', 'Engine %@ ist installiert. Die Shader-Kette hat sich von %@ zu %@ geändert, daher kompiliert jedes Spiel seine Shader beim nächsten Build neu.'),+ 'engine.switch.title': ('切换引擎通道?', 'Switch the engine channel?', 'Byta motorkanal?', 'Engine-Kanal wechseln?'),+ 'engine.switch.go': ('切换到%@', 'Switch to %@', 'Byt till %@', 'Zu %@ wechseln'),+ 'engine.switch.cancel': ('取消', 'Cancel', 'Avbryt', 'Abbrechen'),+ 'engine.switch.toExperimental': ('实验版跟随最新的上游。它通过了自动检查,但还没有人玩过。如果它的着色器链不同,每个游戏下次构建时都会重新编译着色器。切换回稳定版时也是如此。', 'Experimental follows the newest upstream. It passed the automated checks, but nobody has played it yet. If its shader chain differs, every game compiles its shaders again on its next build. Switching back to Stable does the same.', 'Experimentell följer senaste uppström. Den har klarat de automatiska kontrollerna, men ingen har spelat den än. Om dess shaderkedja skiljer sig kompilerar varje spel sina shaders igen vid nästa bygge. Att byta tillbaka till Stabil gör samma sak.', 'Experimentell folgt dem neuesten Upstream. Sie hat die automatischen Prüfungen bestanden, wurde aber noch nicht gespielt. Weicht ihre Shader-Kette ab, kompiliert jedes Spiel seine Shader beim nächsten Build neu. Der Wechsel zurück zu Stabil hat dieselbe Folge.'),+ 'engine.switch.toStable': ('稳定版是与本版本应用一起测试过的引擎。如果它的着色器链与实验版不同,每个游戏下次构建时都会重新编译着色器。', 'Stable is the engine tested with this app version. If its shader chain differs from the experimental one, every game compiles its shaders again on its next build.', 'Stabil är motorn som testats med den här appversionen. Om dess shaderkedja skiljer sig från den experimentella kompilerar varje spel sina shaders igen vid nästa bygge.', 'Stabil ist die Engine, die mit dieser App-Version getestet wurde. Weicht ihre Shader-Kette von der experimentellen ab, kompiliert jedes Spiel seine Shader beim nächsten Build neu.'),+ 'engine.fail.network': ('无法连接 GitHub 检查引擎。请检查网络后重试。', 'Could not reach GitHub to check the engine. Check the connection and try again.', 'Kunde inte nå GitHub för att kontrollera motorn. Kontrollera anslutningen och försök igen.', 'GitHub war nicht erreichbar, um die Engine zu prüfen. Prüfe die Verbindung und versuche es erneut.'),+ 'engine.fail.noManifest': ('%@通道还没有适用于此应用版本的引擎', 'The %@ channel has no engine for this app version yet', 'Kanalen %@ har ännu ingen motor för den här appversionen', 'Der Kanal %@ hat noch keine Engine für diese App-Version'),+ 'engine.fail.unsigned': ('引擎清单没有用应用的密钥签名。未安装任何内容。', "The engine list is not signed with the app's key. Nothing was installed.", 'Motorlistan är inte signerad med appens nyckel. Inget installerades.', 'Die Engine-Liste ist nicht mit dem Schlüssel der App signiert. Es wurde nichts installiert.'),+ 'engine.fail.manifest': ('无法读取引擎清单。未安装任何内容。', 'The engine list could not be read. Nothing was installed.', 'Motorlistan kunde inte läsas. Inget installerades.', 'Die Engine-Liste konnte nicht gelesen werden. Es wurde nichts installiert.'),+ 'engine.fail.download': ('无法下载引擎。请检查网络后重试。', 'The engine could not be downloaded. Check the connection and try again.', 'Motorn kunde inte laddas ner. Kontrollera anslutningen och försök igen.', 'Die Engine konnte nicht geladen werden. Prüfe die Verbindung und versuche es erneut.'),+ 'engine.fail.digest': ('下载的引擎与校验和不符。未安装任何内容。', 'The downloaded engine does not match its checksum. Nothing was installed.', 'Den nedladdade motorn stämmer inte med sin kontrollsumma. Inget installerades.', 'Die geladene Engine passt nicht zu ihrer Prüfsumme. Es wurde nichts installiert.'),+ 'engine.fail.install': ('无法安装引擎。请检查可用空间后重试。', 'The engine could not be installed. Check the free space and try again.', 'Motorn kunde inte installeras. Kontrollera ledigt utrymme och försök igen.', 'Die Engine konnte nicht installiert werden. Prüfe den freien Speicher und versuche es erneut.'),}diff --git a/frontend/README.md b/frontend/README.mdindex 2d341278..69de7149 100644--- a/frontend/README.md+++ b/frontend/README.md@@ -57,8 +57,8 @@ That is the file to attach when the panel and the terminal disagree — a Finderlaunch gives the app a different PATH from the shell's.A completed Mac build appears in the collection automatically and can be started-with **Play**. An iPhone build, by default, offers its unsigned IPA and the-sideloading and RomFS-copy instructions.+with **Play**. An iPhone or iPad build goes into the shared app on the device+(see below), and the game appears in the collection with a button that opens it there.When a build finishes or fails while the app is in the background, a notificationnames the game and the target. Clicking it shows the game in the library, or the@@ -67,42 +67,35 @@ first build starts, and **Settings → App** turns it off. Notifications need thapp bundle: started with `swift run` the launcher has no bundle identifier, andthere are none.-## Install on an iPhone or iPad--With Xcode, a development certificate (sign in to Xcode with your Apple ID under-Settings → Accounts) and a device paired with this Mac, an iPhone build can go-straight to the device: choose it under **Install on** and the **Signing team**-next to it. The script then prepares the game's Xcode project-(`--prepare-xcode --team-id`, the route it offers developers) instead of an IPA,-`xcodebuild -allowProvisioningUpdates` signs it for that device with the team-(Xcode makes the provisioning profile), and `xcrun devicectl device install app`-installs it. The game files take the same route as for sideloading. They are packed into-`games/<title ID>/romfs.img`, with any DLC in `aoc/` beside it, and the app is built-without them (`DM_COPY_ROMFS=NO`). After the install, `xcrun devicectl device copy to`-puts that folder into the app's `Documents/games/<title ID>/`, where the app looks first. devicectl skips files-that did not change, so a reinstall sends the code and shaders, not the whole game-again. The first copy of a large game takes a few minutes. The game then appears-in the collection, and its button opens it on the device.--**iPhone or iPad (one app for all games)** is a third target for the same device. The build-script makes only the game's framework (`--shell-framework`), and one shared app on the device-holds every game you add. The launcher keeps the list of games in `shell.json` in the-`NX2Apple-shell` folder (next to the output folder, saved as `shellRoot`), generates the app's-project with `dm/ios/tools/build_shell.sh --prepare-xcode`, signs it with `xcodebuild` and-installs it over the one already there, which keeps the app's Documents. Game data is-compared with the device by path and size and only what is missing is copied, so a second-install of the same game copies nothing. The same steps run without the window:+## iPhone and iPad++The **iPhone / iPad** target is one app on the device that holds every game you add. It needs+Xcode, a development certificate (sign in to Xcode with your Apple ID under Settings → Accounts)+and a device paired with this Mac. Choose the device under **Install on** and the **Signing team**+next to it before the build. The build script makes only the game's framework+(`--shell-framework`), and the shared app holds the games. The launcher keeps the list of games in+`shell.json` in the `NX2Apple-shell` folder (next to the output folder, saved as `shellRoot`),+generates the app's project with `dm/ios/tools/build_shell.sh --prepare-xcode`, signs it with+`xcodebuild -allowProvisioningUpdates` and installs it over the one already there with+`xcrun devicectl device install app`, which keeps the app's Documents. The game files are packed+into `games/<title ID>/romfs.img`, with any DLC in `aoc/` beside it. They are compared with the+device by path and size, and only what is missing is copied to the app's+`Documents/games/<title ID>/`, so a second install of the same game copies nothing. The first copy+of a large game takes a few minutes. The same steps run without the window:NSPortBuilder --install-shell --framework <path> --archive <games/TITLEID folder> --title-id <id> \--name <name> --device <udid> --team <team> --repo <repo> [--shell-root <dir>] [--python <path>]The first time, turn on Developer Mode on the device and trust the developerunder Settings → General → VPN & Device Management. With a free Apple ID the-profile expires after seven days. **Don't install, export the IPA** keeps the-unsigned IPA as before. The devices and teams are read with `devicectl list-devices` and `security find-identity`. The team is the certificate's+profile expires after seven days, and **Re-sign** on the game renews it. The devices and teams are+read with `devicectl list devices` and `security find-identity`. The team is the certificate'sorganizational unit, not the code in its name.+A game that an earlier version built as its own app or IPA stays in the library, marked as an+older iPhone build. Nothing is deleted. **Build** makes it again for the shared app. A saved+iPhone target from an earlier version becomes the shared-app target.+**Manage > Show game log** opens the game's latest log in Console. It is `<library folder>/log/<title ID>.log`when the app's folder holds the library marker (`.nx2apple-library`), else`~/Library/Logs/nxnative/<title ID>.log` (`dm/mac/launcher.c`), and the row is off with a tooltip until the game has run.@@ -123,7 +116,7 @@ folder beside it (`dm/host/hle_fs.c`), which goes along. The copy is refused whithe game runs on the Mac. Close it on the device too, or it writes its own save over thecopy later. The device side uses the install's route: `devicectl device info files` forthe date and `devicectl device copy from` / `copy to` with the app's data container. Only-a game installed from here has a known bundle ID, so a sideloaded IPA has no device side.+a game installed from here has a known bundle ID, so an app installed another way has no device side.## Cheatsdiff --git a/frontend/Sources/NSPortBuilder/BuildTarget.swift b/frontend/Sources/NSPortBuilder/BuildTarget.swiftnew file mode 100644index 00000000..a6c73a36--- /dev/null+++ b/frontend/Sources/NSPortBuilder/BuildTarget.swift@@ -0,0 +1,20 @@+import Foundation++/// What a build makes. The launcher has two targets: a Mac app, and the game's framework in the one shared app on an+/// iPhone or iPad. The target is stored as text in the settings and in the library.+enum BuildTarget {+ static let mac = "mac-app"+ static let ios = "ios"++ /// Anything that is not the Mac app is the iPhone / iPad target. That covers a missing value, and the values older+ /// versions stored ("ios" for one IPA per game, "ios-shell" for the shared app).+ static func normalized(_ value: String?) -> String { value == mac ? mac : ios }++ /// The saved choice. An old value is stored again in its new form.+ static func saved(_ defaults: UserDefaults = .standard) -> String {+ let stored = defaults.string(forKey: "buildTarget")+ let value = normalized(stored)+ if stored != nil, stored != value { defaults.set(value, forKey: "buildTarget") }+ return value+ }+}diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swiftindex fff0e291..fed375d5 100644--- a/frontend/Sources/NSPortBuilder/ContentView.swift+++ b/frontend/Sources/NSPortBuilder/ContentView.swift@@ -115,12 +115,11 @@ final class BuildModel: ObservableObject {@Published var confirmingOverride: BuildFailureKind?/// The one-off `--allow-*` of a confirmed "Build anyway": taken by the next build and never stored.private(set) var armedOverride: BuildFailureKind?- @Published var ipaPath = "" // captured from the script's "output IPA:" line@Published var macAppPath = "" // --platform mac-app: the .app this build produced- /// 'ios' = an IPA for an iPhone; 'mac-app' = a double-clickable Mac app (upstream's- /// --platform mac-app). A Mac app is a different output of the same pipeline, not a+ /// BuildTarget.ios = the game's framework in the one shared app on an iPhone or iPad; BuildTarget.mac = a double-clickable+ /// Mac app (upstream's --platform mac-app). A Mac app is a different output of the same pipeline, not a/// different pipeline: same extraction, rewrite and shaders, then dm/mac/pack_app.py.- @Published var target = (UserDefaults.standard.string(forKey: "buildTarget") ?? "ios") {+ @Published var target = BuildTarget.saved() {didSet {UserDefaults.standard.set(target, forKey: "buildTarget")// A Mac-only setup needs no iOS SDK for a Mac build, but does for an iPhone one (needsIOSPlatform)@@ -162,21 +161,6 @@ final class BuildModel: ObservableObject {fileprivate var shellCopyAnswer: ((ShellCopyDecision) -> Void)?let shellWaitCancelled = LockedFlag()private var shellRetry: (framework: String, titleID: String, name: String, archive: String)?- @Published var transferAsk = false // the transfer-the-game-files question is up: USB from the Mac is slow, so copying is the player's call- private var transferHandler: ((Bool) -> Void)?-- /// Asks whether to copy the game files to the device now, and runs `then` with the answer on the main queue.- func askTransfer(_ then: @escaping (Bool) -> Void) {- transferHandler = then- transferAsk = true- }-- func transferAnswer(_ ok: Bool) {- guard let then = transferHandler else { return }- transferHandler = nil- then(ok)- }- private var bundleID = "" // from the script's "bundle ID:" linevar xcrunPath = "/usr/bin/xcrun" // tests stand in for xcodebuild and devicectlvar volumesRoot = "/Volumes" // where external drives are mountedvar teamsProvider: () -> [SigningTeam] = { DeviceTools.teams() } // the teams the Mac knows, read when a signing step fails@@ -185,7 +169,7 @@ final class BuildModel: ObservableObject {var openApp: (URL) -> Void = { NSWorkspace.shared.openApplication(at: $0, configuration: NSWorkspace.OpenConfiguration()) }/// This iPhone build goes straight to a device.- var installsDirectly: Bool { target != "mac-app" && !installDevice.isEmpty && !signingTeam.isEmpty }+ var installsDirectly: Bool { target != BuildTarget.mac && !installDevice.isEmpty && !signingTeam.isEmpty }func deviceName(_ udid: String) -> String { devices.first { $0.id == udid }?.name ?? "iPhone" }@@ -1216,7 +1200,7 @@ final class BuildModel: ObservableObject {func startBuild() {guard !running else { return }// The shared app needs a device this Mac knows. Found out here, before an hour of building, not after it.- if target == "ios-shell", !shellDeviceChecked {+ if target != BuildTarget.mac, !shellDeviceChecked {guard installsDirectly else { doneNote = t("shell.needsDevice"); done = false; return }verifyShellDevice()return@@ -1226,7 +1210,7 @@ final class BuildModel: ObservableObject {running = true; done = false; doneNote = ""; stages = []; logTail = ""; lineBuf = ""; chainNoteShown = falsefailure = nil; confirmingOverride = nillet override = takeOverrideFlag() // for this build only: the next one asks again- installedOn = ""; installedAppPath = ""; bundleID = ""+ installedOn = ""; installedAppPath = ""guard repoOK else {fail(repoPath.isEmpty ? t("msg.repoInvalidEmpty") : String(format: t("msg.repoInvalid"), shortPath(repoPath)))return@@ -1332,9 +1316,9 @@ final class BuildModel: ObservableObject {var args = [engine + "/" + Self.buildScript, inputDir, "-k", keysPath,"--progress", "json"]// A compatibility switch the player turned on: written to a small env file the pipeline- // copies into the app bundle (main.m sets one variable per line at boot). Only for an IPA;+ // copies into the app bundle (main.m sets one variable per line at boot). Only for an iPhone or iPad build;// a Mac app runs on this Mac's GPU, which always has BC support.- if bcOnCPU && target != "mac-app" {+ if bcOnCPU && target != BuildTarget.mac {let envPath = NSTemporaryDirectory() + "nspb-env-\(UUID().uuidString.prefix(8)).txt"do {try "DM_TEX_BC_CPU=1\n".write(toFile: envPath, atomically: true, encoding: .utf8)@@ -1345,21 +1329,15 @@ final class BuildModel: ObservableObject {}}if hasWorkDir { args += ["--work-dir", workDir] }- let macApp = target == "mac-app"+ let macApp = target == BuildTarget.macif macApp {// -o names the .app; the RomFS goes inside it, so the archive step is skipped below.args += ["--platform", "mac-app"]macAppPath = (outDir.isEmpty ? baseDir : outDir) + "/" + tidHex + ".app"args += ["-o", macAppPath]- } else if target == "ios-shell" {+ } else {// Only the game's framework: the one shared app is made and signed after the script (installShell)args += ShellInstall.buildArguments(workDir: workDir, team: signingTeam)- } else if installsDirectly {- // The game's Xcode project instead of an IPA, signed for the device after the script (signAndInstall)- args += ["--prepare-xcode", "--keep-extracted", "--team-id", signingTeam]- } else if !outDir.isEmpty {- ipaPath = outDir + "/" + tidHex + ".ipa"- args += ["-o", ipaPath]}// The archive step packs whatever folder the build reported; without --work-dir that is the// script's default, which is the same workDir unless a separate output folder was chosen.@@ -1410,7 +1388,7 @@ final class BuildModel: ObservableObject {}if status.terminationStatus == 0 {self.markAllDone()- if self.target == "mac-app" {+ if self.target == BuildTarget.mac {// The .app is self-contained (its RomFS is inside), and the marker file// beside it (.nx2apple-library, a dot file the Finder hides) tells the// game's launcher that this folder is a library: its saves and log live@@ -1427,19 +1405,14 @@ final class BuildModel: ObservableObject {}self.running = falseself.cleanupStaging()- } else if self.target == "ios-shell" {- // The same archive, then the game's framework into the one shared app on the device+ } else {+ // The game's archive, then its framework into the one shared app on the devicelet tid = Self.titleID(self.basePath).map { String(format: "%016llX", $0) } ?? "game"let name = ((self.basePath as NSString).lastPathComponent as NSString).deletingPathExtensionself.packArchive(workDir: self.effectiveWorkDir) {self.installShell(framework: ShellInstall.frameworkPath(workDir: self.effectiveWorkDir, titleID: tid),titleID: tid, name: name, archive: $0)}- } else if self.installsDirectly {- // The same archive as for sideloading, then the app without the game files, then the archive into its Documents- self.packArchive(workDir: self.effectiveWorkDir) { self.signAndInstall(archive: $0) }- } else {- self.packArchive(workDir: self.effectiveWorkDir) // keeps running=true until the archive is done}} else {if let i = self.stages.lastIndex(where: { $0.state == .running }) {@@ -1489,13 +1462,6 @@ final class BuildModel: ObservableObject {}}- /// The build's last step is done either way: release the button and show the outcome.- func finishBuild(ok: Bool, note: String) {- running = false- done = ok- doneNote = note- }-/// A failed build's log read for the script's known early stops: the card under the build button then says what/// happened and what to do. An unknown stop leaves the note (the last line of the log) as it is.func noteFailure() {@@ -1721,10 +1687,6 @@ final class BuildModel: ObservableObject {}append(line + "\n")noteChainChange(line)- noteBundleID(line)- if let range = line.range(of: "output IPA: ") {- ipaPath = String(line[range.upperBound...]).trimmingCharacters(in: .whitespacesAndNewlines)- }guard let s = Self.parseStage(line) else { return }if let i = stages.firstIndex(where: { $0.id == s.k }) {if !s.name.isEmpty { stages[i].name = s.name }@@ -1752,12 +1714,6 @@ final class BuildModel: ObservableObject {a.runModal()}- /// The script's "app name: …; version: …; bundle ID: org.nxnative.…" line: the app to open on the device.- private func noteBundleID(_ text: String) {- guard let range = text.range(of: #"bundle ID: [A-Za-z0-9.\-]+"#, options: .regularExpression) else { return }- bundleID = String(text[range].dropFirst("bundle ID: ".count))- }-/// One event of `--progress json`: the stage list follows it, and the log gets a readable line (no count updates).private func handleEvent(_ kind: String, _ e: [String: Any]) {let k = (e["k"] as? NSNumber)?.intValue ?? 0@@ -1789,10 +1745,6 @@ final class BuildModel: ObservableObject {let msg = e["msg"] as? String ?? ""append(msg + "\n")noteChainChange(msg)- noteBundleID(msg)- if let range = msg.range(of: "output IPA: ") {- ipaPath = String(msg[range.upperBound...]).trimmingCharacters(in: .whitespacesAndNewlines)- }default: break}}@@ -1881,8 +1833,8 @@ final class BuildModel: ObservableObject {/// Pack the extracted RomFS into one romfs.img. The extracted folder is/// <work>/extract/v<N>/RomFS where N is the profile's package version, so take/// the highest v* that actually has a RomFS instead of hardcoding one game.- /// `then` continues the build with the archive's folder (installing on a device) instead of ending it.- private func packArchive(workDir: String, then: ((String) -> Void)? = nil) {+ /// `then` continues the build with the archive's folder (installing on a device).+ private func packArchive(workDir: String, then: @escaping (String) -> Void) {running = truelet fm = FileManager.defaultlet extract = workDir + "/extract"@@ -1924,10 +1876,7 @@ final class BuildModel: ObservableObject {detail: String(format: t("prog.archiveReused"), reused)))say(String(format: t("msg.archiveReused"), dest))placeAddOnContent(workDir: workDir, in: dest)- if let then { return then(dest) }- cleanupStaging()- finishBuild(ok: true, note: t("msg.done"))- return+ return then(dest)}// One romfs.img instead of a ROMFSARC shard set: upstream reads the image directly// (hle_fs.c), one file copies to a phone at full speed where 300,000 did not, and it fits@@ -1960,10 +1909,7 @@ final class BuildModel: ObservableObject {say(String(format: t("msg.archiveReused"), dest))placeAddOnContent(workDir: workDir, in: dest)archivePath = dest- if let then { return then(dest) }- cleanupStaging()- finishBuild(ok: true, note: t("msg.done"))- return+ return then(dest)}try? fm.removeItem(atPath: to)do {@@ -1977,9 +1923,7 @@ final class BuildModel: ObservableObject {say(String(format: t("msg.archiveLog"), romfsImage, dest))placeAddOnContent(workDir: workDir, in: dest)archivePath = dest- if let then { return then(dest) }- cleanupStaging()- finishBuild(ok: true, note: t("msg.done"))+ return then(dest)} catch {if let i = stages.firstIndex(where: { $0.id == idx }) {stages[i].state = .failed; stages[i].detail = error.localizedDescription@@ -2019,119 +1963,24 @@ final class BuildModel: ObservableObject {? String(format: self.t("prog.archiveDone"), dest): String(format: self.t("msg.archiveFailed"), st.terminationStatus)}- if succeeded, let then { return then(dest) }+ if succeeded { return then(dest) }self.cleanupStaging()self.running = false- self.done = succeeded+ self.done = falseif cancelled { self.resetProgress() }- self.doneNote = cancelled ? self.t("msg.stopped") : (succeeded ? self.t("msg.done") : self.t("msg.archiveIpaOnly"))+ self.doneNote = cancelled ? self.t("msg.stopped") : String(format: self.t("msg.archiveFailed"), st.terminationStatus)}}proc = pdo { try p.run(); Self.track(p) } catch {if let i = stages.firstIndex(where: { $0.id == idx }) {stages[i].state = .failed; stages[i].detail = t("msg.archiveNoStart")}- running = false; doneNote = t("msg.archiveIpaOnly"); cleanupStaging()+ running = false; doneNote = t("msg.archiveNoStart"); cleanupStaging()}}// MARK: Installing on a device- /// After the script prepared the Xcode project and the game data is packed: sign the app for the device without the- /// game files (DM_COPY_ROMFS=NO), install it, then copy the game's folder (romfs.img, aoc/) into its- /// Documents/games/<title ID>/, where the app looks first (main.m), as a sideloaded copy has it. devicectl skips files- /// that did not change, so a reinstall sends the code and shaders, not the game again.- /// Install the app xcodebuild produced, then copy the game data into it. Shared by the plain- /// sign flow and the team-variant retry.- private func installBuiltApp(app: String, archive: String, device: String, xcrun: String) {- let name = deviceName(device)- guard FileManager.default.fileExists(atPath: app) else { return finishInstall(String(format: t("dev.noProject"), shortPath(app))) }- runTool(id: 1002, name: String(format: t("dev.installStage"), name),- [xcrun, "devicectl", "device", "install", "app", "--device", device, app], step: Self.installStep) { error in- if let error {- self.finishInstall(String(format: self.t("dev.installFailed"), error))- return self.noteInstallFailure(.install, error: error)- }- guard let bundle = NSDictionary(contentsOfFile: app + "/Info.plist")?["CFBundleIdentifier"] as? String else {- return self.finishInstall(String(format: self.t("dev.noProject"), self.shortPath(app + "/Info.plist")))- }- let tid = Self.titleID(self.basePath).map { String(format: "%016llX", $0) } ?? "game"- // Copying the game files over USB is the slowest part of an install and the player may- // rather hand the data to the device themselves (a fast external drive in Files), so it- // is their call. Without game files there is nothing to ask about.- let copy = {- self.runTool(id: 1003, name: String(format: self.t("dev.copyStage"), name),- Self.archiveCopy(xcrun: xcrun, device: device, bundle: bundle, archive: archive, titleID: tid), step: Self.installStep) { error in- if let error {- self.finishInstall(String(format: self.t("dev.copyFailed"), error))- return self.noteInstallFailure(.copy, error: error)- }- self.installedOn = device- self.installedAppPath = app- self.finishInstall(nil)- }- }- guard FileManager.default.fileExists(atPath: archive + "/romfs.img") else { return copy() }- self.askTransfer { ok in- guard ok else {- self.installedOn = device- self.installedAppPath = app- self.running = false- self.done = true- self.doneNote = String(format: self.t("dev.copySkipped"), name)- self.cleanupStaging()- return- }- copy()- }- }- }-- private func signAndInstall(archive: String) {- let work = effectiveWorkDir, project = work + "/xcode/DmIOS.xcodeproj", derived = work + "/xcode-derived-data"- let device = installDevice, team = signingTeam, name = deviceName(device), xcrun = xcrunPath- guard FileManager.default.fileExists(atPath: project) else { return finishInstall(String(format: t("dev.noProject"), shortPath(project))) }- DispatchQueue.global(qos: .userInitiated).async {- let scheme = Self.scheme(of: project, xcrun: xcrun)- DispatchQueue.main.async {- guard let scheme else { return self.finishInstall(String(format: self.t("dev.noProject"), self.shortPath(project))) }- // The app's own bundle ID can be taken: App IDs are global and register to the first- // team that uses one, so a game built before with another Apple ID fails here for- // ever after. The retry appends this team to the identifier — a stable per-team- // variant — as a command-line setting, which overrides the project's.- func sign(_ extra: [String] = []) -> [String] {- [xcrun, "xcodebuild", "-project", project, "-scheme", scheme, "-configuration", "Release",- "-destination", "id=\(device)", "-derivedDataPath", derived, "-allowProvisioningUpdates",- "DEVELOPMENT_TEAM=\(team)", "DM_COPY_ROMFS=NO"] + extra + ["build"]- }- let appID = "org.nxnative." + (Self.titleID(self.basePath).map { String(format: "%016llX", $0) } ?? "game").lowercased()- let teamVariant = "org.nxnative." + appID.split(separator: ".").last!.appending(".\(team)")- func taken(_ e: String?) -> Bool { e.map(BuildFailureClassifier.signingTeamTaken) ?? false }- self.runTool(id: 1001, name: String(format: self.t("dev.signStage"), name), sign(), step: Self.xcodeStep) { firstError in- if let firstError, taken(firstError) {- // Once more under this team's own identifier, and the log says why the first try failed.- fputs("signing: " + appID + " is registered to another team; retrying as " + teamVariant + "\n", stderr)- self.runTool(id: 1001, name: String(format: self.t("dev.signStage"), name), sign(["PRODUCT_BUNDLE_IDENTIFIER=" + teamVariant]), step: Self.xcodeStep) { retryError in- if let retryError, !retryError.isEmpty {- self.finishInstall(String(format: self.t("dev.signFailed"), retryError))- self.noteInstallFailure(.sign, error: retryError)- } else {- self.installBuiltApp(app: derived + "/Build/Products/Release-iphoneos/DmIOS.app", archive: archive, device: device, xcrun: xcrun)- }- }- return- }- if let firstError, !firstError.isEmpty {- self.finishInstall(String(format: self.t("dev.signFailed"), firstError))- self.noteInstallFailure(.sign, error: firstError)- } else {- self.installBuiltApp(app: derived + "/Build/Products/Release-iphoneos/DmIOS.app", archive: archive, device: device, xcrun: xcrun)- }- }- }- }- }-/// Steps 4 to 7 of the shared app (ShellInstall.swift) for a game whose framework is built and whose archive is packed: the/// shell's project, signing, the install over the app that is already there, and the game data the device lacks.func installShell(framework: String, titleID: String, name: String, archive: String, dataOnly: Bool = false) {@@ -2248,83 +2097,52 @@ final class BuildModel: ObservableObject {[xcrun, "devicectl", "device", "install", "app", "--device", device, app]}- /// Renew an installed app's signature (a free Apple ID's profile lasts 7 days). The same xcodebuild parameters as+ /// Renew the shared app's signature (a free Apple ID's profile lasts 7 days). The same xcodebuild parameters as/// the install, run on the cached project and derived data: Xcode reuses the compiled products and only signs- /// again, then devicectl installs the app over itself. PRODUCT_BUNDLE_IDENTIFIER is the installed app's own, so the- /// device keeps that app's Documents (game data, saves); a retry under another identifier would lose them.+ /// again, then devicectl installs the app over itself. PRODUCT_BUNDLE_IDENTIFIER is the one shell.json holds, so the+ /// device keeps the app's Documents (game data, saves).func resignOnDevice(app: String, device: String, then: (() -> Void)? = nil) {guard !device.isEmpty, !app.isEmpty else { then?(); return }guard !signingTeam.isEmpty else {doneNote = t("dev.resignNoTeam")then?(); return}- let shell = ShellInstall.paths(ofApp: app)- // The shared app's identifier is the one shell.json holds, the others' is the installed app's own- guard let bundle = shell.map({ ShellLibrary.load(root: $0.root).bundleID })- ?? (NSDictionary(contentsOfFile: app + "/Info.plist")?["CFBundleIdentifier"] as? String) else {- doneNote = String(format: t("dev.noProject"), shortPath(app + "/Info.plist"))+ // An app from before the shared app has its own project and cannot be signed again here: build the game again+ guard let shell = ShellInstall.paths(ofApp: app) else {+ doneNote = t("dev.resignOlder")then?(); return}- guard let paths = shell.map({ (project: $0.project, derived: $0.derived) }) ?? Self.buildPaths(ofApp: app),- FileManager.default.fileExists(atPath: paths.project) else {- doneNote = String(format: t("dev.resignNoProject"), shortPath(Self.buildPaths(ofApp: app)?.project ?? app))+ guard FileManager.default.fileExists(atPath: shell.project) else {+ doneNote = String(format: t("dev.resignNoProject"), shortPath(shell.project))then?(); return}let xcrun = xcrunPath, team = signingTeam, name = deviceName(device)- DispatchQueue.global(qos: .userInitiated).async {- let scheme = shell != nil ? ShellInstall.scheme : Self.scheme(of: paths.project, xcrun: xcrun)- DispatchQueue.main.async {- guard let scheme else {- self.doneNote = String(format: self.t("dev.noProject"), self.shortPath(paths.project))- then?(); return- }- self.running = true- // The shared app is signed again under the identifier shell.json holds, so the device keeps its Documents- let command = shell.map { ShellInstall.buildCommand(xcrun: xcrun, root: $0.root, device: device, team: team, bundleID: bundle) }- ?? Self.resignCommand(xcrun: xcrun, project: paths.project, scheme: scheme, device: device,- derived: paths.derived, team: team, bundle: bundle)- self.runTool(id: 1006, name: String(format: self.t("dev.resignStage"), name),- command, step: Self.xcodeStep) { error in- if let error, !error.isEmpty {- self.running = false- self.doneNote = String(format: self.t("dev.resignFailed"), error)- then?(); return- }- self.runTool(id: 1007, name: String(format: self.t("dev.installStage"), name),- Self.reinstallCommand(xcrun: xcrun, device: device, app: app), step: Self.installStep) { installError in- self.running = false- if let installError {- self.doneNote = String(format: self.t("dev.installFailed"), installError)- } else {- self.installedOn = device- self.installedAppPath = app- self.doneNote = String(format: self.t("dev.resigned"), name)- }- then?()- }+ let bundle = ShellLibrary.load(root: shell.root).bundleID+ running = true+ // The shared app is signed again under the identifier shell.json holds, so the device keeps its Documents+ let command = ShellInstall.buildCommand(xcrun: xcrun, root: shell.root, device: device, team: team, bundleID: bundle)+ runTool(id: 1006, name: String(format: t("dev.resignStage"), name),+ command, step: Self.xcodeStep) { error in+ if let error, !error.isEmpty {+ self.running = false+ self.doneNote = String(format: self.t("dev.resignFailed"), error)+ then?(); return+ }+ self.runTool(id: 1007, name: String(format: self.t("dev.installStage"), name),+ Self.reinstallCommand(xcrun: xcrun, device: device, app: app), step: Self.installStep) { installError in+ self.running = false+ if let installError {+ self.doneNote = String(format: self.t("dev.installFailed"), installError)+ } else {+ self.installedOn = device+ self.installedAppPath = app+ self.doneNote = String(format: self.t("dev.resigned"), name)}+ then?()}}}- /// The xcodebuild parameters of a re-sign: signAndInstall's, plus the installed app's own identifier. The same- /// derived data is what keeps Xcode from rebuilding the game's code.- nonisolated static func resignCommand(xcrun: String, project: String, scheme: String, device: String, derived: String,- team: String, bundle: String) -> [String] {- [xcrun, "xcodebuild", "-project", project, "-scheme", scheme, "-configuration", "Release",- "-destination", "id=\(device)", "-derivedDataPath", derived, "-allowProvisioningUpdates",- "DEVELOPMENT_TEAM=\(team)", "DM_COPY_ROMFS=NO", "PRODUCT_BUNDLE_IDENTIFIER=\(bundle)", "build"]- }-- /// The cached project and derived data an installed app came from, from the app's own path- /// (<work>/xcode-derived-data/Build/Products/Release-iphoneos/DmIOS.app): a re-sign must run there to reuse them.- nonisolated static func buildPaths(ofApp app: String) -> (project: String, derived: String)? {- guard let marker = app.range(of: "/Build/Products/") else { return nil }- let derived = String(app[..<marker.lowerBound])- let work = (derived as NSString).deletingLastPathComponent- return (work + "/xcode/DmIOS.xcodeproj", derived)- }-/// Ask where to write the .ipa, then pack the signed app there.func saveIPAPanel() {let p = NSSavePanel()@@ -2379,27 +2197,6 @@ final class BuildModel: ObservableObject {return name.replacingOccurrences(of: "/", with: "_").replacingOccurrences(of: ":", with: "_") + ".ipa"}- /// The game's folder (romfs.img, aoc/) into the installed app's Documents, where main.m looks for this game's files first.- nonisolated static func archiveCopy(xcrun: String, device: String, bundle: String, archive: String, titleID: String) -> [String] {- [xcrun, "devicectl", "device", "copy", "to", "--device", device, "--source", archive,- "--destination", "Documents/games/\(titleID)", "--domain-type", "appDataContainer", "--domain-identifier", bundle]- }-- /// The scheme the script made for the game ("<name> (<profile>)"), from `xcodebuild -list`.- nonisolated static func scheme(of project: String, xcrun: String) -> String? {- let p = Process(), out = Pipe()- p.executableURL = URL(fileURLWithPath: xcrun)- p.arguments = ["xcodebuild", "-list", "-json", "-project", project]- p.standardOutput = out; p.standardError = FileHandle.nullDevice- guard (try? p.run()) != nil else { return nil }- let data = out.fileHandleForReading.readDataToEndOfFile()- p.waitUntilExit()- let start = data.firstIndex(of: UInt8(ascii: "{")) ?? data.startIndex // xcodebuild may print a line before the JSON- guard let root = try? JSONSerialization.jsonObject(with: data[start...]) as? [String: Any],- let schemes = (root["project"] as? [String: Any])?["schemes"] as? [String] else { return nil }- return schemes.first { $0 != "DmIOS" } ?? schemes.first- }-/// What xcodebuild is doing, from the actions it prints.nonisolated static func xcodeStep(_ line: String) -> (detail: String, percent: Double?)? {let actions = [("CompileC ", "compiling"), ("SwiftCompile ", "compiling"), ("Ld ", "linking"),@@ -2921,7 +2718,7 @@ final class BuildModel: ObservableObject {nonisolated static func needsIOSPlatform(defaults: UserDefaults = .standard) -> Bool {if OnboardingDefaults.sessionPlatform == "mac" { return false } // a forced run's choice, not stored yetguard defaults.string(forKey: OnboardingDefaults.platform) == "mac" else { return true }- return (defaults.string(forKey: "buildTarget") ?? "ios") != "mac-app"+ return BuildTarget.normalized(defaults.string(forKey: "buildTarget")) != BuildTarget.mac}@@ -3241,12 +3038,6 @@ struct BuilderView: View {if let id, id.hasPrefix("set.") { withAnimation(.easeInOut(duration: 0.2)) { proxy.scrollTo(id, anchor: .center) } }}.modifier(GameFilesDrop(enabled: !settings && !m.running, label: m.t("drop.hint")) { m.take(dropped: $0) }) // DropFiles.swift- .alert(String(format: m.t("dev.askTransferTitle"), m.deviceName(m.installDevice)), isPresented: $m.transferAsk) {- Button(m.t("dev.transferNow")) { m.transferAnswer(true) }- Button(m.t("dev.transferSkip"), role: .cancel) { m.transferAnswer(false) }- } message: {- Text(m.t("dev.askTransferText"))- }}.buttonStyle(LauncherSecondaryButtonStyle())}@@ -3337,7 +3128,7 @@ struct BuilderView: View {}files.disabled(m.running)target- if m.target != "mac-app" { install.disabled(m.running) }+ if m.target != BuildTarget.mac { install.disabled(m.running) }logPanelactionShellCopyCard(m: m)@@ -3430,12 +3221,11 @@ struct BuilderView: View {Text(m.t("section.target")).font(.manrope(15, .semibold)).foregroundStyle(.secondary).padding(.leading, 2)HStack(spacing: 14) {- targetCard("mac-app", symbol: "desktopcomputer", title: "build.mac", note: "build.macNote")- targetCard("ios", symbol: "iphone", title: "build.ios", note: "build.iosNote")- targetCard("ios-shell", symbol: "square.stack.3d.up", title: "build.shell", note: "build.shellNote")+ targetCard(BuildTarget.mac, symbol: "desktopcomputer", title: "build.mac", note: "build.macNote")+ targetCard(BuildTarget.ios, symbol: "iphone", title: "build.ios", note: "build.iosNote")}// A Mac app runs on this Mac's GPU, which always decodes BC textures: the switch is the iPhone's only.- if m.target != "mac-app" {+ if m.target != BuildTarget.mac {VStack(spacing: 0) {HStack(alignment: .center, spacing: 12) {VStack(alignment: .leading, spacing: 3) {@@ -3481,7 +3271,7 @@ struct BuilderView: View {}@ViewBuilder private var outcome: some View {- if m.done && m.target == "mac-app" {+ if m.done && m.target == BuildTarget.mac {group(m.t("section.done")) {row(m.t("library.ready"), detail: m.shortPath(m.macAppPath), dot: LauncherPalette.ready, help: m.macAppPath) {Button(m.t("install.reveal")) { reveal(m.macAppPath) }@@ -3505,33 +3295,6 @@ struct BuilderView: View {}}}- } else if m.done && m.target != "mac-app" {- group(m.t("install.title")) {- VStack(alignment: .leading, spacing: 10) {- guideRow(m.t("install.step1")); guideRow(m.t("install.step2")); guideRow(m.t("install.step3"))- }- .padding(.horizontal, 18).padding(.vertical, 16)- divider- row("IPA", detail: m.shortPath(m.ipaPath), dot: LauncherPalette.ready, help: m.ipaPath) {- Button(m.t("install.reveal")) { reveal(m.ipaPath) }- }- divider- row("RomFS", detail: m.shortPath(m.archivePath), dot: LauncherPalette.ready, help: m.archivePath) {- Button(m.t("install.reveal")) { reveal(m.archivePath) }- }- }- }- }-- private func guideRow(_ s: String) -> some View {- // "1\t…": the tab splits the step number from the text- let parts = s.split(separator: "\t", maxSplits: 1)- let num = parts.first.map(String.init) ?? ""- let text = parts.count > 1 ? String(parts[1]) : s- return HStack(alignment: .firstTextBaseline, spacing: 12) {- Text(num).font(.manrope(13, .bold)).foregroundStyle(LauncherPalette.cream).frame(width: 14)- Text(text).font(.manrope(14)).fixedSize(horizontal: false, vertical: true)- Spacer(minLength: 0)}}diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swiftindex 727d3f1e..5682c12d 100644--- a/frontend/Sources/NSPortBuilder/LauncherView.swift+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift@@ -542,7 +542,7 @@ struct ContentView: View {}// A free Apple ID's provisioning profile lasts 7 days. Say when this app's runs out, and offer the// re-sign at any time: renewing early (before a trip, say) is as valid as renewing just in time.- if game.onDevice {+ if game.onDevice && !game.isOlderIOSBuild {HStack(spacing: 10) {Image(systemName: "checkmark.seal").font(.system(size: 12)).foregroundStyle(LauncherPalette.cream.opacity(0.7))@@ -669,7 +669,7 @@ struct ContentView: View {private func status(_ game: LibraryGame, prominent: Bool = false) -> some View {let building = m.running && activeBuildID == game.idlet color = building ? LauncherPalette.building : ((game.isReady || game.hasIOSBuild) ? LauncherPalette.ready : LauncherPalette.unbuilt)- let key = building ? "library.building" : (game.isReady ? "library.ready" : (game.hasIOSBuild ? "library.readyIOS" : "library.notBuilt"))+ let key = building ? "library.building" : (game.isReady ? "library.ready" : (game.hasIOSBuild ? (game.isOlderIOSBuild ? "library.olderIOS" : "library.readyIOS") : "library.notBuilt"))return HStack(spacing: 7) {Circle().fill(color).frame(width: prominent ? 9 : 7, height: prominent ? 9 : 7)Text(prominent ? m.t(key).uppercased() : m.t(key))@@ -700,7 +700,7 @@ struct ContentView: View {if m.running {Image(systemName: "wrench.and.screwdriver").font(.system(size: 22, weight: .light)).foregroundStyle(.secondary)VStack(alignment: .leading, spacing: 4) {- Text(m.t(m.target == "mac-app" ? "activity.mac" : "activity.ios")).font(.manrope(15, .bold))+ Text(m.t(m.target == BuildTarget.mac ? "activity.mac" : "activity.ios")).font(.manrope(15, .bold))TimelineView(.periodic(from: Date(), by: 1)) { context in // the clock ticks while a count may stand stillText(m.stages.last(where: { $0.state == .running }).map { [$0.name, $0.detail, $0.clock(at: context.date, left: m.t("prog.eta"))].filter { !$0.isEmpty }.joined(separator: " · ") }@@ -771,7 +771,7 @@ struct ContentView: View {private func newBuild() {guard !m.running else { page = .builds; return }for index in m.slots.indices { m.slots[index].paths = []; m.slots[index].problem = "" }- m.gameDir = ""; m.done = false; m.doneNote = ""; m.macAppPath = ""; m.ipaPath = ""; m.stages = []+ m.gameDir = ""; m.done = false; m.doneNote = ""; m.macAppPath = ""; m.stages = []if m.outDir.isEmpty && !library.folder.isEmpty { m.outDir = library.folder }page = .builds}@@ -936,8 +936,8 @@ struct ContentView: View {private func recordBuild() {guard m.done, let id = activeBuildID else { return }- if m.target == "mac-app" { library.recordCompletedApp(path: m.macAppPath, commit: buildCommit, for: id) }- else { library.recordCompletedIOS(ipa: m.ipaPath, archive: m.archivePath, app: m.installedAppPath, device: m.installedOn, commit: buildCommit, for: id) }+ if m.target == BuildTarget.mac { library.recordCompletedApp(path: m.macAppPath, commit: buildCommit, for: id) }+ else { library.recordCompletedIOS(archive: m.archivePath, app: m.installedAppPath, device: m.installedOn, commit: buildCommit, for: id) }refreshArtwork()if performStartupChecks { checkTools() }}diff --git a/frontend/Sources/NSPortBuilder/Library.swift b/frontend/Sources/NSPortBuilder/Library.swiftindex ae648754..1af07879 100644--- a/frontend/Sources/NSPortBuilder/Library.swift+++ b/frontend/Sources/NSPortBuilder/Library.swift@@ -9,7 +9,7 @@ struct LibraryGame: Codable, Identifiable, Equatable {var appPath = ""var ipaPath = ""var archivePath = ""- var lastTarget = "ios"+ var lastTarget = BuildTarget.iosvar inputs: [String: [String]] = [:]var outputDirectory = ""/// The folder this game's files were found in, which is what the Build page shows: the parent of a base package a@@ -39,6 +39,9 @@ struct LibraryGame: Codable, Identifiable, Equatable {var hasIOSBuild: Bool { hasIPA || hasIOSApp }var hasIPA: Bool { !ipaPath.isEmpty && FileManager.default.fileExists(atPath: ipaPath) }var hasIOSApp: Bool { !iosAppPath.isEmpty && FileManager.default.fileExists(atPath: iosAppPath + "/Info.plist") }+ /// An iPhone build made before the shared app: a single IPA, or an app of its own. It stays in the library and Build makes+ /// the game again for the shared app, which then replaces it.+ var isOlderIOSBuild: Bool { hasIOSBuild && !(hasIOSApp && ShellInstall.paths(ofApp: iosAppPath) != nil) }/// What the hero's primary button does: play the Mac app, open the installed iPhone app, else build (an IPA alone is not a reason to show anything else).enum Primary: Equatable { case play, openOnDevice, build }@@ -62,7 +65,7 @@ extension LibraryGame {appPath = try c.decodeIfPresent(String.self, forKey: .appPath) ?? ""ipaPath = try c.decodeIfPresent(String.self, forKey: .ipaPath) ?? ""archivePath = try c.decodeIfPresent(String.self, forKey: .archivePath) ?? ""- lastTarget = try c.decodeIfPresent(String.self, forKey: .lastTarget) ?? "ios"+ lastTarget = BuildTarget.normalized(try c.decodeIfPresent(String.self, forKey: .lastTarget))inputs = try c.decodeIfPresent([String: [String]].self, forKey: .inputs) ?? [:]outputDirectory = try c.decodeIfPresent(String.self, forKey: .outputDirectory) ?? ""sourceFolder = try c.decodeIfPresent(String.self, forKey: .sourceFolder) ?? ""@@ -497,13 +500,14 @@ final class GameLibrary: ObservableObject {upsert(game)}- func recordCompletedIOS(ipa: String, archive: String, app: String = "", device: String = "", commit: String = "", for id: UUID) {+ func recordCompletedIOS(archive: String, app: String, device: String = "", commit: String = "", for id: UUID) {guard var game = games.first(where: { $0.id == id }),- FileManager.default.fileExists(atPath: ipa) || FileManager.default.fileExists(atPath: app + "/Info.plist") else { return }- // What this build made; an earlier build's IPA or installed app stays when this one made none- if !ipa.isEmpty { game.ipaPath = ipa }+ FileManager.default.fileExists(atPath: app + "/Info.plist") else { return }+ // The shared app replaces an older build's single IPA: the file stays on disk, the library stops listing it+ game.ipaPath = ""if !archive.isEmpty { game.archivePath = archive }- if !app.isEmpty { game.iosAppPath = app; game.installedDevice = device }+ game.iosAppPath = app+ game.installedDevice = devicegame.toolsCommit = commitupsert(game)}diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex 48b1bcae..7e012d52 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -243,6 +243,7 @@ enum L10n {"console.demoController3": ("USB \u{624b}\u{67c4}", "USB controller"),"library.readyIOS": ("\u{53ef}\u{7528}\u{4e8e} iPhone", "Ready for iPhone"),+ "library.olderIOS": ("旧版 iPhone 构建", "Older iPhone build"),"library.stopping": ("\u{6b63}\u{5728}\u{505c}\u{6b62}…", "Stopping…"),"build.setup": ("\u{5b8c}\u{6210}\u{8bbe}\u{7f6e}", "Finish setup"),"library.chooseFolder": ("\u{6e38}\u{620f}\u{6587}\u{4ef6}\u{5939}\u{2026}", "Change folder…"),@@ -255,9 +256,7 @@ enum L10n {"settings.appNote": ("\u{4e3a} Apple \u{8bbe}\u{5907}\u{6784}\u{5efa}\u{6e38}\u{620f}", "Build your games for Apple devices"),"build.compatibility": ("\u{517c}\u{5bb9}\u{6027}\u{9009}\u{9879}", "Older iPhone support"),"build.macNote": ("\u{5728}\u{8fd9}\u{53f0} Mac \u{4e0a}\u{76f4}\u{63a5}\u{8fd0}\u{884c}\u{3002}", "Play directly on this Mac."),- "build.iosNote": ("\u{4e3a}\u{4f60}\u{7684} iPhone \u{6216} iPad \u{521b}\u{5efa}\u{5e94}\u{7528}\u{3002}", "Create an app for your iPhone or iPad."),- "build.shell": ("iPhone 或 iPad(所有游戏共用一个应用)", "iPhone or iPad (one app for all games)"),- "build.shellNote": ("设备上的一个应用装下你添加的所有游戏。每个游戏的数据只复制一次。", "One app on the device holds every game you add. Each game's data is copied once."),+ "build.iosNote": ("你的 iPhone 或 iPad 上用一个应用装下所有游戏。", "One app on your iPhone or iPad for all your games."),"shell.projectStage": ("准备共用应用", "Prepare the shared app"),"shell.projectFailed": ("无法准备共用应用:%@", "The shared app could not be prepared: %@"),"shell.checkStage": ("比较 %@ 上的游戏数据", "Compare the game data on %@"),@@ -289,7 +288,7 @@ enum L10n {// ---- Launcher and guided builds ----"dev.section": ("\u{5b89}\u{88c5}\u{5230}\u{8bbe}\u{5907}", "Install"),"dev.target": ("\u{5b89}\u{88c5}\u{5230}", "Install on"),- "dev.none": ("\u{4e0d}\u{5b89}\u{88c5}\u{ff0c}\u{53ea}\u{5bfc}\u{51fa} IPA", "Don't install, export the IPA"),+ "dev.none": ("选择设备", "Choose a device"),"dev.notConnected": ("\u{672a}\u{8fde}\u{63a5}", "not connected"),"dev.noDevices": ("\u{6ca1}\u{6709}\u{4e0e}\u{8fd9}\u{53f0} Mac \u{914d}\u{5bf9}\u{7684} iPhone \u{6216} iPad\u{ff08}\u{9700}\u{8981} Xcode\u{ff09}\u{3002}", "No iPhone or iPad paired with this Mac (needs Xcode)."),"dev.refresh": ("\u{5237}\u{65b0}", "Refresh"),@@ -299,7 +298,7 @@ enum L10n {"dev.teamNoCert": ("这个团队还没有开发证书:第一次安装时 Xcode 会自动创建(Mac 需要联网)。","This team has no development certificate yet: Xcode creates it at the first install (the Mac needs to be online)."),"dev.personalTeam": ("个人团队", "Personal team"),- "dev.note": ("Xcode 会为这台设备签名并直接安装,游戏数据(romfs.img)复制到 App 的“文稿”中,与侧载相同。第一次复制大型游戏需要几分钟。第一次需要在设备上开启开发者模式,并信任开发者(设置 → 通用 → VPN 与设备管理)。", "Xcode signs the game for this device and installs it there, then copies the game data (romfs.img) into the app’s Documents, as for sideloading. The first copy of a large game takes a few minutes. The first time, turn on Developer Mode on the device and trust the developer (Settings → General → VPN & Device Management)."),+ "dev.note": ("Xcode 会为这台设备签名共用应用并安装,然后把游戏数据(romfs.img)复制到应用的“文稿”中。第一次复制大型游戏需要几分钟。第一次需要在设备上开启开发者模式,并信任开发者(设置 → 通用 → VPN 与设备管理)。", "Xcode signs the shared app for this device and installs it there, then copies the game data (romfs.img) into the app’s Documents. The first copy of a large game takes a few minutes. The first time, turn on Developer Mode on the device and trust the developer (Settings → General → VPN & Device Management)."),// ---- Saves: a game's save copied between this Mac and the device it is installed on (SaveTransfer.swift) ----"saves.menu": ("存档…", "Saves…"),"saves.title": ("存档", "Saves"),@@ -368,11 +367,6 @@ enum L10n {"dev.signStage": ("\u{4e3a} %@ \u{7b7e}\u{540d}", "Sign for %@"),"dev.installStage": ("\u{5b89}\u{88c5}\u{5230} %@", "Install on %@"),"dev.copyStage": ("复制游戏文件到 %@", "Copy the game files to %@"),- "dev.copyFailed": ("复制游戏文件失败:%@", "Copying the game files failed: %@"),- "dev.askTransferTitle": ("传输游戏文件到 %@?", "Transfer the game files to %@?"),- "dev.askTransferText": ("Mac 通过 USB 线向 iPhone 传输的速度有限(约 25–70 MB/s,视线缆和设备而定),大游戏需要较长时间。如果游戏文件在高速存储设备上(USB3 移动硬盘、读卡器),把它直接连到 iPhone,在游戏启动器的“选择游戏数据”里选取会更快。", "USB transfer from the Mac is limited (about 25–70 MB/s, depending on cable and device), so a large game takes a while. If the game files are on fast external storage (a USB 3 drive or card reader), connecting it to the iPhone and picking it under “Choose game data” in the launcher is faster."),- "dev.transferNow": ("传输", "Transfer"),- "dev.transferSkip": ("暂不传输", "Not now"),"dev.copySkipped": ("已安装到 %@,游戏文件未传输", "Installed on %@, but 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 %@"),@@ -406,6 +400,7 @@ enum L10n {"dev.resigned": ("已续签并安装到 %@", "Re-signed and installed on %@"),"dev.resignFailed": ("续签失败:%@(请在 Xcode → 设置 → 账户 → Manage Certificates 检查证书,或确认网络)", "Re-signing failed: %@ (check the certificate in Xcode → Settings → Accounts → Manage Certificates, or the network)"),"dev.resignNoProject": ("找不到缓存的 Xcode 工程:%@(请重新构建一次)", "The cached Xcode project is not there: %@ (build once more)"),+ "dev.resignOlder": ("这个游戏是在共用应用出现之前构建成独立应用的。请重新构建,把它放进共用应用。", "This game was built as its own app, before there was one shared app. Build it again to put it in the shared app."),"dev.resignNoTeam": ("续签需要签名团队:请选择签名团队后再试。", "Re-signing needs a signing team: pick one first."),"prog.eta": ("\u{8fd8}\u{5269} %@", "%@ left"),"activity.mac": ("\u{6b63}\u{5728}\u{6784}\u{5efa} Mac \u{7248}", "Mac build in progress"),@@ -728,7 +723,6 @@ enum L10n {"target.macDone": ("Mac App 已生成,可在访达里双击运行", "Mac app ready — double-click it in the Finder"),"target.missingApp": ("构建结束但没有找到 .app 文件——看日志末尾", "Build finished but no .app was produced — see the end of the log"),"build.outDir": ("输出目录…", "Output folder…"),- "msg.ipaAt": ("IPA:%@", "IPA: %@"),"msg.archiveAt": ("归档:%@", "Archive: %@"),"repo.ok": ("仓库可用", "repository ready"),"dep.iossdk": ("iPhoneOS SDK", "iPhoneOS SDK"),@@ -898,11 +892,6 @@ enum L10n {"status.chooseRepo": ("先选择项目仓库", "Choose the project repository first"),"status.needInputs": ("还需要选择游戏本体和 prod.keys", "Still need the base game and prod.keys"),"status.output": ("输出:%@", "Output: %@"),- "install.title": ("安装到 iPhone", "Install on the iPhone"),- "install.step1": ("1\t用 AltStore / Sideloadly 安装上面的 IPA", "1\tInstall the IPA above with AltStore / Sideloadly"),- "install.step2": ("2\t把上面的 romfs 文件夹整个拷到游戏 App 的 Documents 里(文件 App → 我的 iPhone → 游戏名)",- "2\tCopy the whole romfs folder above into the game app's Documents (Files → On My iPhone → game name)"),- "install.step3": ("3\t启动游戏", "3\tLaunch the game"),"library.showLog": ("显示游戏日志", "Show game log"),"library.showLog.none": ("这个游戏还没有日志,运行一次就会生成", "No game log yet. Play the game once to create it"),"install.reveal": ("在访达中显示", "Reveal in Finder"),@@ -1031,12 +1020,10 @@ enum L10n {"Invalid repository path: %@ — use Choose repository… above to point at your clone"),"msg.repoInvalidEmpty": ("仓库路径无效:未选择——用上方的「选择仓库…」指向本项目的 clone","Invalid repository path: none chosen — use Choose repository… above"),- "msg.archiveSkipped": ("IPA 已生成,但归档跳过:找不到 %@/v*/RomFS",- "IPA built, archive skipped: no %@/v*/RomFS"),+ "msg.archiveSkipped": ("游戏数据已跳过:找不到 %@/v*/RomFS",+ "Game data skipped: no %@/v*/RomFS"),"msg.archiveFailed": ("归档失败(退出码 %d)", "Archive failed (exit code %d)"),"msg.archiveNoStart": ("无法启动 romfs_image.py", "Could not start romfs_image.py"),- "msg.archiveIpaOnly": ("IPA 已生成,归档失败", "IPA built, but the archive failed"),- "msg.done": ("完成:IPA 与 romfs 归档已生成,按下面三步装到手机", "Done: the IPA and the romfs archive are ready — three steps below"),"prog.archiveDone": ("游戏数据就绪:%@/romfs.img", "game data ready: %@/romfs.img"),"prog.archiveReused": ("复用上次的镜像(%d 个文件未变)", "reused the previous image (%d files unchanged)"),"msg.archiveReused": ("归档未变,复用 %@", "archive unchanged, reusing %@"),@@ -1261,6 +1248,7 @@ enum L10n {"library.rescan": "Uppdatera","library.clearSearch": "Rensa sökning","library.readyIOS": "Klar för iPhone",+ "library.olderIOS": "Äldre iPhone-bygge","library.stopping": "Avslutar …","library.chooseFolder": "Byt mapp …","library.folderTitle": "Din spelmapp",@@ -1269,9 +1257,7 @@ enum L10n {"settings.appNote": "Bygg dina spel för Apple-enheter","build.compatibility": "Stöd för äldre iPhone-modeller","build.macNote": "Spela direkt på den här Mac-datorn.",- "build.iosNote": "Skapa en app för din iPhone eller iPad.",- "build.shell": "iPhone eller iPad (en app för alla spel)",- "build.shellNote": "En app på enheten rymmer alla spel du lägger till. Varje spels data kopieras en gång.",+ "build.iosNote": "En app på din iPhone eller iPad för alla dina spel.","shell.projectStage": "Förbereder den gemensamma appen","shell.projectFailed": "Den gemensamma appen kunde inte förberedas: %@","shell.checkStage": "Jämför speldata på %@",@@ -1302,13 +1288,13 @@ enum L10n {"build.folderSelected": "Spelmapp vald","dev.section": "Installera","dev.target": "Installera på",- "dev.none": "Installera inte, exportera IPA-filen",+ "dev.none": "Välj en enhet","dev.notConnected": "inte ansluten","dev.noDevices": "Ingen iPhone eller iPad är parkopplad med den här Mac-datorn (Xcode krävs).","dev.refresh": "Uppdatera","dev.team": "Signeringsteam","dev.personalTeam": "Personligt team",- "dev.note": "Xcode signerar spelet för den här enheten och installerar det där. Därefter kopieras speldata (romfs.img) till appens Dokument, som vid sidoinläsning. Första kopieringen av ett stort spel tar några minuter. Aktivera utvecklarläge på enheten och lita på utvecklaren första gången (Inställningar → Allmänt → VPN och enhetshantering).",+ "dev.note": "Xcode signerar den gemensamma appen för den här enheten och installerar den där. Därefter kopieras speldata (romfs.img) till appens Dokument. Första kopieringen av ett stort spel tar några minuter. Aktivera utvecklarläge på enheten och lita på utvecklaren första gången (Inställningar → Allmänt → VPN och enhetshantering).","saves.menu": "Sparfiler …","saves.title": "Sparfiler","saves.mac": "Den här Mac-datorn",@@ -1376,11 +1362,6 @@ enum L10n {"dev.signStage": "Signerar för %@","dev.installStage": "Installerar på %@","dev.copyStage": "Kopierar spelfilerna till %@",- "dev.copyFailed": "Kopieringen av spelfilerna misslyckades: %@",- "dev.askTransferTitle": "Överföra spelfilerna till %@?",- "dev.askTransferText": "USB-överföring från Mac-datorn är begränsad, omkring 25–70 MB/s beroende på kabel och enhet, så ett stort spel tar en stund. Om spelfilerna ligger på snabb extern lagring, till exempel en USB 3-enhet eller kortläsare, går det fortare att ansluta den till iPhone och välja den under ”Välj speldata” i startprogrammet.",- "dev.transferNow": "Överför",- "dev.transferSkip": "Inte nu","dev.copySkipped": "Installerad på %@; spelfilerna överfördes inte","dev.gameData": "Speldata (romfs.img)","dev.installed": "Installerad på %@",@@ -1625,7 +1606,6 @@ enum L10n {"target.macDone": "Mac-appen är klar. Dubbelklicka på den i Finder.","target.missingApp": "Bygget blev klart men ingen .app skapades. Se slutet av loggen.","build.outDir": "Utdatamapp …",- "msg.ipaAt": "IPA: %@","msg.archiveAt": "Arkiv: %@","repo.ok": "förrådet är klart","dep.iossdk": "iPhoneOS SDK",@@ -1710,9 +1690,6 @@ enum L10n {"status.chooseRepo": "Välj först projektförrådet.","status.needInputs": "Grundspelet och prod.keys saknas fortfarande","status.output": "Utdata: %@",- "install.title": "Installera på iPhone",- "install.step1": "1\tInstallera IPA-filen ovan med AltStore/Sideloadly",- "install.step3": "3\tStarta spelet","install.reveal": "Visa i Finder","msg.running": "Kör: %@","msg.stopped": "Stoppad",@@ -1722,8 +1699,6 @@ enum L10n {"msg.launchFailed": "Kunde inte starta byggskriptet: %@","msg.archiveFailed": "Arkiveringen misslyckades (slutkod %d)","msg.archiveNoStart": "Kunde inte starta romfs_image.py",- "msg.archiveIpaOnly": "IPA-filen byggdes, men arkiveringen misslyckades",- "msg.done": "Klart: IPA-filen och romfs-arkivet är färdiga. Följ de tre stegen nedan.","prog.archiveDone": "speldata klar: %@/romfs.img","prog.archiveReused": "återanvände föregående avbildning (%d filer oförändrade)","msg.archiveReused": "arkivet är oförändrat, återanvänder %@",@@ -1864,7 +1839,6 @@ enum L10n {"dep.fix.nonascii": "SDK-sökvägen innehåller icke-ASCII-tecken (ett kinesiskt användarnamn till exempel): ld64.lld på Windows kan därför misslyckas med att öppna SDK-filerna. Kopiera hela SDK-mappen till en sökväg med bara ASCII (till exempel C:\\NSPB\\sdk) och peka beroendepanelens ”Välj mapp …” på den.","dep.row.log": "beroende %@: [%@] %@","prog.empty": "När bygget startar visas varje steg från skriptet här",- "install.step2": "2\tKopiera hela romfs-mappen ovan till spelappens Dokument (appen Filer → På min iPhone → spelets namn)","msg.installingNsz": "Det valda filformatet är komprimerat NSZ/XCZ. Installerar nsz i Python-miljön som används för bygget …","msg.noWorkDir": "Det här förrådet är inte den senaste NX2Apple-versionen och byggskriptet saknar --work-dir. Bygger med skriptets standardlayout. Använd NX2Apple-förrådet för arkivåteranvändning och återupptagning.","msg.nszFailed": "Installationen av nsz misslyckades (Python för bygget: %@). Är nätverket nere? Kör annars pip install nsz manuellt.",@@ -1873,7 +1847,7 @@ enum L10n {"msg.stagingFailed": "Kunde inte skapa en länk i mellanlagringsmappen. Ligger filerna på olika diskar?","msg.repoInvalid": "Ogiltig förrådssökväg: %@. Använd ”Välj förråd …” ovan och välj projektets klon.","msg.repoInvalidEmpty": "Ogiltig förrådssökväg: inget valt. Använd ”Välj förråd …” ovan och välj projektets klon.",- "msg.archiveSkipped": "IPA-filen skapades men arkiveringen hoppades över eftersom %@/v*/RomFS inte hittades",+ "msg.archiveSkipped": "Speldata hoppades över eftersom %@/v*/RomFS inte hittades","section.library": "Spelbibliotek","section.tools": "Byggverktyg","section.app": "App",@@ -2145,6 +2119,7 @@ enum L10n {"console.demoController2": "Großer Controller","console.demoController3": "USB-Controller","library.readyIOS": "Bereit für iPhone",+ "library.olderIOS": "Älterer iPhone-Build","library.stopping": "Wird beendet …","build.setup": "Einrichtung beenden","library.chooseFolder": "Ordner ändern …",@@ -2157,12 +2132,12 @@ enum L10n {"settings.appNote": "Baue deine Spiele für Apple-Geräte","build.compatibility": "Unterstützung für ältere iPhones","build.macNote": "Direkt auf diesem Mac spielen.",- "build.iosNote": "Erstelle eine App für dein iPhone oder iPad.",+ "build.iosNote": "Eine App auf deinem iPhone oder iPad für alle deine Spiele.","build.folderCTA": "Spieleordner wählen","build.folderSelected": "Spieleordner ausgewählt","dev.section": "Installation","dev.target": "Installieren auf",- "dev.none": "Nicht installieren, IPA exportieren",+ "dev.none": "Gerät wählen","dev.notConnected": "nicht verbunden","dev.noDevices": "Mit diesem Mac ist kein iPhone oder iPad gekoppelt (benötigt Xcode).","dev.refresh": "Aktualisieren",@@ -2170,7 +2145,7 @@ enum L10n {"dev.noTeam": "In Xcode ist keine Apple-ID angemeldet und es gibt kein Entwicklungszertifikat. Öffne in Xcode „Xcode → Settings → Apple Accounts“ (die Xcode-Menüs sind nur auf Englisch), melde dich mit deiner Apple-ID an, wähle „Personal Team“ und klicke auf „Download Manual Profiles“. Das Zertifikat erscheint nicht sofort. Warte etwa 30 Sekunden und klicke auf „Erneut prüfen“. Erscheint es weiterhin nicht, klicke unter „Manage Certificates“ auf „+“, um manuell ein Apple-Development-Zertifikat zu erstellen.","dev.teamNoCert": "Dieses Team hat noch kein Entwicklungszertifikat. Xcode erstellt es bei der ersten Installation (der Mac muss online sein).","dev.personalTeam": "Persönliches Team",- "dev.note": "Xcode signiert das Spiel für dieses Gerät und installiert es dort. Danach kopiert es die Spieldaten (romfs.img) wie beim Sideloading in die Dokumente der App. Das erste Kopieren eines großen Spiels dauert einige Minuten. Aktiviere beim ersten Mal den Entwicklermodus auf dem Gerät und vertraue dem Entwickler („Einstellungen → Allgemein → VPN & Geräteverwaltung“).",+ "dev.note": "Xcode signiert die gemeinsame App für dieses Gerät und installiert sie dort. Danach kopiert es die Spieldaten (romfs.img) in die Dokumente der App. Das erste Kopieren eines großen Spiels dauert einige Minuten. Aktiviere beim ersten Mal den Entwicklermodus auf dem Gerät und vertraue dem Entwickler („Einstellungen → Allgemein → VPN & Geräteverwaltung“).","saves.menu": "Spielstände …","saves.title": "Spielstände","saves.mac": "Dieser Mac",@@ -2238,11 +2213,6 @@ enum L10n {"dev.signStage": "Für %@ signieren","dev.installStage": "Auf %@ installieren","dev.copyStage": "Spieldateien auf %@ kopieren",- "dev.copyFailed": "Kopieren der Spieldateien fehlgeschlagen: %@",- "dev.askTransferTitle": "Spieldateien auf %@ übertragen?",- "dev.askTransferText": "Die USB-Übertragung vom Mac ist begrenzt (etwa 25 bis 70 MB/s, je nach Kabel und Gerät), daher dauert ein großes Spiel eine Weile. Liegen die Spieldateien auf einem schnellen externen Speicher (USB-3-Laufwerk oder Kartenleser), geht es schneller, ihn am iPhone anzuschließen und im Launcher unter „Spieldaten wählen“ auszuwählen.",- "dev.transferNow": "Übertragen",- "dev.transferSkip": "Nicht jetzt","dev.copySkipped": "Auf %@ installiert, aber die Spieldateien wurden nicht übertragen","dev.gameData": "Spieldaten (romfs.img)","dev.installed": "Auf %@ installiert",@@ -2276,6 +2246,7 @@ enum L10n {"dev.resigned": "Neu signiert und auf %@ installiert","dev.resignFailed": "Neu signieren fehlgeschlagen: %@ (prüfe das Zertifikat unter „Xcode → Settings → Accounts → Manage Certificates“ oder das Netzwerk)","dev.resignNoProject": "Das zwischengespeicherte Xcode-Projekt ist nicht vorhanden: %@ (bitte noch einmal bauen)",+ "dev.resignOlder": "Dieses Spiel wurde als eigene App gebaut, bevor es die gemeinsame App gab. Baue es neu, damit es in der gemeinsamen App landet.","dev.resignNoTeam": "Zum Neusignieren ist ein Signierteam nötig. Wähle zuerst eines.","prog.eta": "Noch %@","activity.mac": "Mac-Build läuft",@@ -2538,7 +2509,6 @@ enum L10n {"target.macDone": "Mac-App bereit. Doppelklicke sie im Finder","target.missingApp": "Build beendet, aber es wurde keine .app erzeugt. Siehe das Ende des Protokolls","build.outDir": "Ausgabeordner …",- "msg.ipaAt": "IPA: %@","msg.archiveAt": "Archiv: %@","repo.ok": "Repository bereit","dep.iossdk": "iPhoneOS SDK",@@ -2660,10 +2630,6 @@ enum L10n {"status.chooseRepo": "Wähle zuerst das Projekt-Repository","status.needInputs": "Basisspiel und prod.keys fehlen noch","status.output": "Ausgabe: %@",- "install.title": "Auf dem iPhone installieren",- "install.step1": "1\tInstalliere die IPA oben mit AltStore / Sideloadly",- "install.step2": "2\tKopiere den ganzen romfs-Ordner oben in die Dokumente der Spiel-App („Dateien → Auf meinem iPhone → Spielname“)",- "install.step3": "3\tStarte das Spiel","library.showLog": "Spielprotokoll zeigen","library.showLog.none": "Noch kein Spielprotokoll. Spiele das Spiel einmal, um eines zu erzeugen","install.reveal": "Im Finder zeigen",@@ -2754,11 +2720,9 @@ enum L10n {"msg.launchFailed": "Das Build-Skript konnte nicht gestartet werden: %@","msg.repoInvalid": "Ungültiger Repository-Pfad: %@. Verweise oben mit „Repository wählen …“ auf deinen Klon","msg.repoInvalidEmpty": "Ungültiger Repository-Pfad: keiner gewählt. Nutze oben „Repository wählen …“",- "msg.archiveSkipped": "IPA gebaut, Archiv übersprungen: kein %@/v*/RomFS",+ "msg.archiveSkipped": "Spieldaten übersprungen: kein %@/v*/RomFS","msg.archiveFailed": "Archiv fehlgeschlagen (Exit-Code %d)","msg.archiveNoStart": "romfs_image.py konnte nicht gestartet werden",- "msg.archiveIpaOnly": "IPA gebaut, aber das Archiv ist fehlgeschlagen",- "msg.done": "Fertig: Die IPA und das romfs-Archiv sind bereit. Drei Schritte unten","prog.archiveDone": "Spieldaten bereit: %@/romfs.img","prog.archiveReused": "vorheriges Image wiederverwendet (%d Dateien unverändert)","msg.archiveReused": "Archiv unverändert, %@ wird wiederverwendet",@@ -2886,8 +2850,6 @@ enum L10n {"engine.fail.download": "Die Engine konnte nicht geladen werden. Prüfe die Verbindung und versuche es erneut.","engine.fail.digest": "Die geladene Engine passt nicht zu ihrer Prüfsumme. Es wurde nichts installiert.","engine.fail.install": "Die Engine konnte nicht installiert werden. Prüfe den freien Speicher und versuche es erneut.",- "build.shell": "iPhone oder iPad (eine App für alle Spiele)",- "build.shellNote": "Eine App auf dem Gerät enthält jedes Spiel, das du hinzufügst. Die Daten jedes Spiels werden einmal kopiert.","shell.projectStage": "Gemeinsame App vorbereiten","shell.projectFailed": "Die gemeinsame App konnte nicht vorbereitet werden: %@","shell.checkStage": "Spieldaten auf %@ vergleichen",diff --git a/frontend/Tests/NSPortBuilderTests/BuildTargetTests.swift b/frontend/Tests/NSPortBuilderTests/BuildTargetTests.swiftnew file mode 100644index 00000000..acc9a9df--- /dev/null+++ b/frontend/Tests/NSPortBuilderTests/BuildTargetTests.swift@@ -0,0 +1,100 @@+import XCTest+@testable import NSPortBuilder++/// The launcher builds for this Mac or for the one shared app on an iPhone or iPad. Settings and library files written+/// when one IPA per game was a target still load, and older single-IPA builds stay in the library.+final class BuildTargetTests: XCTestCase {+ private var temporary: URL!++ override func setUpWithError() throws {+ temporary = FileManager.default.temporaryDirectory.appendingPathComponent("nxnative-target-" + UUID().uuidString)+ try FileManager.default.createDirectory(at: temporary, withIntermediateDirectories: true)+ }++ override func tearDownWithError() throws {+ try? FileManager.default.removeItem(at: temporary)+ }++ func testAnyStoredValueButMacIsTheIPhoneTarget() {+ XCTAssertEqual(BuildTarget.normalized(nil), BuildTarget.ios)+ XCTAssertEqual(BuildTarget.normalized("ios"), BuildTarget.ios)+ XCTAssertEqual(BuildTarget.normalized("ios-shell"), BuildTarget.ios)+ XCTAssertEqual(BuildTarget.normalized("something else"), BuildTarget.ios)+ XCTAssertEqual(BuildTarget.normalized("mac-app"), BuildTarget.mac)+ }++ func testTheSavedChoiceIsMigratedAndStoredAgain() throws {+ let defaults = try XCTUnwrap(UserDefaults(suiteName: "nspb-target-" + UUID().uuidString))+ XCTAssertEqual(BuildTarget.saved(defaults), BuildTarget.ios, "nothing stored yet")+ XCTAssertNil(defaults.string(forKey: "buildTarget"))+ defaults.set("ios-shell", forKey: "buildTarget")+ XCTAssertEqual(BuildTarget.saved(defaults), "ios")+ XCTAssertEqual(defaults.string(forKey: "buildTarget"), "ios")+ defaults.set("mac-app", forKey: "buildTarget")+ XCTAssertEqual(BuildTarget.saved(defaults), "mac-app")+ XCTAssertEqual(defaults.string(forKey: "buildTarget"), "mac-app")+ }++ func testALibraryGameKeepsOnlyTheTwoTargets() throws {+ let id = UUID()+ for (stored, expected) in [("ios-shell", "ios"), ("ios", "ios"), ("mac-app", "mac-app")] {+ let json = #"{"id":"\#(id.uuidString)","titleID":"0100535012974000","name":"Hades","lastTarget":"\#(stored)"}"#+ let game = try JSONDecoder().decode(LibraryGame.self, from: Data(json.utf8))+ XCTAssertEqual(game.lastTarget, expected, stored)+ }+ let none = try JSONDecoder().decode(LibraryGame.self, from: Data(#"{"id":"\#(id.uuidString)","titleID":"1","name":"H"}"#.utf8))+ XCTAssertEqual(none.lastTarget, "ios")+ }++ private func app(named name: String, at folder: String) throws -> URL {+ let url = temporary.appendingPathComponent(folder).appendingPathComponent(name)+ try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)+ try Data("plist".utf8).write(to: url.appendingPathComponent("Info.plist"))+ return url+ }++ func testASingleIPAOrAnAppOfItsOwnIsAnOlderBuildAndTheSharedAppIsNot() throws {+ let ipa = temporary.appendingPathComponent("Hades.ipa")+ try Data([0]).write(to: ipa)+ let single = LibraryGame(titleID: "0100535012974000", name: "Hades", ipaPath: ipa.path)+ XCTAssertTrue(single.hasIOSBuild)+ XCTAssertTrue(single.isOlderIOSBuild)+ XCTAssertEqual(single.primary, .build, "Build makes the game again for the shared app")++ let own = try app(named: "DmIOS.app", at: "0100_build/xcode-derived-data/Build/Products/Release-iphoneos")+ XCTAssertTrue(LibraryGame(titleID: "1", name: "H", iosAppPath: own.path, installedDevice: "UDID").isOlderIOSBuild)++ let shared = try app(named: "DmShell.app", at: "shell/derived-data/Build/Products/Release-iphoneos")+ let current = LibraryGame(titleID: "1", name: "H", iosAppPath: shared.path, installedDevice: "UDID")+ XCTAssertFalse(current.isOlderIOSBuild)+ XCTAssertFalse(LibraryGame(titleID: "1", name: "H").isOlderIOSBuild, "nothing built for iPhone")+ }++ func testABuildForTheSharedAppReplacesTheListedIPA() throws {+ let file = temporary.appendingPathComponent("library.json")+ let ipa = temporary.appendingPathComponent("Hades.ipa")+ try Data([0]).write(to: ipa)+ let game = LibraryGame(titleID: "0100535012974000", name: "Hades", ipaPath: ipa.path)+ try JSONEncoder().encode([game]).write(to: file)+ let library = GameLibrary(file: file)+ let shared = try app(named: "DmShell.app", at: "shell/derived-data/Build/Products/Release-iphoneos")+ library.recordCompletedIOS(archive: "", app: shared.path, device: "UDID", for: game.id)+ let stored = try XCTUnwrap(GameLibrary(file: file).games.first)+ XCTAssertEqual(stored.ipaPath, "")+ XCTAssertEqual(stored.iosAppPath, shared.path)+ XCTAssertFalse(stored.isOlderIOSBuild)+ XCTAssertTrue(FileManager.default.fileExists(atPath: ipa.path), "the old file is not deleted")+ library.recordCompletedIOS(archive: "", app: temporary.path + "/none.app", for: game.id)+ XCTAssertEqual(GameLibrary(file: file).games.first?.iosAppPath, shared.path, "a build that made no app records nothing")+ }++ func testEveryLanguageTellsAnOlderBuildAndTheTwoTargets() {+ for key in ["library.olderIOS", "dev.resignOlder", "build.ios", "build.iosNote"] {+ XCTAssertNotNil(L10n.table[key], key)+ XCTAssertNotNil(L10n.de[key], key)+ }+ for key in ["library.olderIOS", "build.iosNote"] { XCTAssertNotNil(L10n.sv[key], key) }+ XCTAssertEqual(L10n.string("build.ios", .en), "iPhone / iPad")+ XCTAssertEqual(L10n.string("build.iosNote", .de), "Eine App auf deinem iPhone oder iPad für alle deine Spiele.")+ }+}diff --git a/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift b/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swiftindex 9af4d014..557d6291 100644--- a/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift+++ b/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift@@ -377,7 +377,7 @@ final class CheatFilesTests: XCTestCase {model.deps = [BuildModel.Dep(id: "test", name: "Xcode", hint: "", present: true, installCmd: [])]let library = GameLibrary(file: temporary.appendingPathComponent("preview.json"))let id = try library.addApp(app)- library.recordCompletedIOS(ipa: "", archive: "", app: ios.path, device: "00008150-AAAA", for: id)+ library.recordCompletedIOS(archive: "", app: ios.path, device: "00008150-AAAA", for: id)let support = temporary.appendingPathComponent("Application Support")let folder = CheatFiles.macFolder(titleID: game, support: support)try write("""diff --git a/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift b/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swiftindex 41d8d54c..d882a82e 100644--- a/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift+++ b/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift@@ -11,7 +11,7 @@ final class GermanLocalizationTests: XCTestCase {"onboarding.demo.mario", "console.kind.gamepad", "console.brand", "console.platform.mac","console.platform.iphone", "console.version", "console.fps30", "console.fps60", "saves.toDevice","saves.toMac", "cheats.title", "section.app", "app.version", "nav.builds", "settings.language.zh",- "settings.language.en", "settings.language.sv", "settings.language.de", "library.ok", "build.ios", "data.update", "data.keys", "msg.ipaAt",+ "settings.language.en", "settings.language.sv", "settings.language.de", "library.ok", "build.ios", "data.update", "data.keys","dep.iossdk", "dep.tool.xcodegen", "dep.tool.zstd", "dep.tool.spirv-cross", "dep.tool.glslangValidator","dep.glslang", "dep.xcode", "dep.metal", "dep.brew", "dep.xcodegen", "dep.zstd", "dep.spirv.win","dep.zstd.win", "dep.spirv", "dep.dotnet", "dep.phase.download", "dep.python.hint",diff --git a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift b/frontend/Tests/NSPortBuilderTests/LibraryTests.swiftindex 71ef6f63..6dbb8076 100644--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift@@ -351,189 +351,17 @@ final class LibraryTests: XCTestCase {XCTAssertNil(DeviceTools.team(fromSubject: "subject=CN=Something"))}- /// An iPhone build with a device and a team: the script prepares the Xcode project, romfs.img is packed as for- /// sideloading, xcodebuild signs the app without the game files for the device (the first try fails on a taken- /// App ID, so the retry under the team's own bundle ID runs too), devicectl installs it, the game files go over- /// once the player answered the transfer question, and the library opens it there. The tools are stand-ins; nothing is signed.- @MainActor private func runInstallFlow(transfer: Bool) throws -> (BuildModel, [String], URL, URL) {- guard FileManager.default.isExecutableFile(atPath: "/usr/bin/python3") else { throw XCTSkip("System Python is required for the process fixture") }- let saved = ["repoPath", "buildTarget", "buildOutputDirectory", "installDevice", "signingTeam"].map { ($0, UserDefaults.standard.object(forKey: $0)) }- defer { for (key, value) in saved { UserDefaults.standard.set(value, forKey: key) } }- let model = BuildModel()- model.repoPath = temporary.path- model.target = "ios"- model.outDir = temporary.path- model.pythonPath = "/usr/bin/python3"- model.dotnetPath = "/usr/bin/true"- model.depsChecked = true- model.deps = [BuildModel.Dep(id: "test", name: "test", hint: "", present: true, installCmd: [])]- model.installDevice = "00008150-AAAA"- model.signingTeam = "TEAM123456"- let marker = temporary.appendingPathComponent("dm/tools/nx_extract/Program.cs")- try FileManager.default.createDirectory(at: marker.deletingLastPathComponent(), withIntermediateDirectories: true)- try Data().write(to: marker)- let calls = temporary.appendingPathComponent("calls.txt")- try BuildModel.requiredTools.filter { $0 != BuildModel.buildScript }.forEach { tool in // the other files the build checks for (#87)- let url = temporary.appendingPathComponent(tool)- try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)- try Data().write(to: url)- }- let script = temporary.appendingPathComponent("scripts/build_ipa_from_nsp.py")- try FileManager.default.createDirectory(at: script.deletingLastPathComponent(), withIntermediateDirectories: true)- try """- import sys, json, pathlib # stand-in for the NSP script; it takes '--work-dir'- open('\(calls.path)', 'a').write('script ' + ' '.join(sys.argv[1:]) + '\\n')- work = pathlib.Path(sys.argv[sys.argv.index('--work-dir') + 1])- (work / 'xcode/DmIOS.xcodeproj').mkdir(parents=True)- (work / 'extract/v0/RomFS').mkdir(parents=True); (work / 'extract/v0/RomFS/data.bin').write_bytes(b'game')- def ev(**e): print(json.dumps(e), flush=True)- ev(ev='stage', k=1, n=1, name='prepare Xcode')- ev(ev='say', msg='[12:00:00] app name: Test; version: 1.0; bundle ID: org.nxnative.test')- ev(ev='stage_end', k=1, name='prepare Xcode', ok=True, summary='', elapsed=1)- """.write(to: script, atomically: true, encoding: .utf8)- let packer = temporary.appendingPathComponent("dm/tools/romfs_image.py") // stand-in: --reuse <RomFS> <image> writes the image- try FileManager.default.createDirectory(at: packer.deletingLastPathComponent(), withIntermediateDirectories: true)- try """- import sys- open('\(calls.path)', 'a').write('romfs_image ' + ' '.join(sys.argv[1:]) + '\\n')- open(sys.argv[3], 'wb').write(b'image')- """.write(to: packer, atomically: true, encoding: .utf8)- let xcrun = temporary.appendingPathComponent("xcrun")- try """- #!/usr/bin/python3- import sys, json, pathlib, plistlib # stand-in for xcrun: xcodebuild -list / build, devicectl install / launch- a = sys.argv[1:]- open('\(calls.path)', 'a').write(' '.join(a) + '\\n')- if a[0] == 'xcodebuild' and '-list' in a:- print('Command line invocation:'); print(json.dumps({'project': {'schemes': ['DmIOS', 'Test (0100535012974000)']}}))- elif a[0] == 'xcodebuild':- if 'PRODUCT_BUNDLE_IDENTIFIER=' not in ' '.join(a):- # App IDs are global: the plain one is registered to another team, and the app retries under a team variant- print('error: "iOS Team Provisioning Profile" cannot be registered to your development team', flush=True)- sys.exit(1)- app = pathlib.Path(a[a.index('-derivedDataPath') + 1]) / 'Build/Products/Release-iphoneos/DmIOS.app'- app.mkdir(parents=True, exist_ok=True) # a re-sign rebuilds over the app the install left there- with (app / 'Info.plist').open('wb') as f: plistlib.dump({'CFBundleIdentifier': 'org.nxnative.test'}, f)- print('CodeSign ' + str(app), flush=True)- elif a[:3] == ['devicectl', 'device', 'install']:- print('45%', flush=True); print('App installed', flush=True)- elif a[:4] == ['devicectl', 'device', 'copy', 'to']:- print('60%', flush=True); print('Copied', flush=True)- """.write(to: xcrun, atomically: true, encoding: .utf8)- try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: xcrun.path)- model.xcrunPath = xcrun.path- let base = temporary.appendingPathComponent("Test [\(titleID)].nsp"), keys = temporary.appendingPathComponent("prod.keys")- try Data([0]).write(to: base); try Data().write(to: keys)- model.slots[0].paths = [base.path]; model.slots[3].paths = [keys.path]- let finished = expectation(description: "Signed and installed")- let token = model.$done.filter { $0 }.prefix(1).sink { _ in finished.fulfill() }- let asked = model.$transferAsk.filter { $0 }.prefix(1).sink { _ in model.transferAnswer(transfer) }- model.startBuild()- wait(for: [finished], timeout: 20)- withExtendedLifetime(token) {} ; withExtendedLifetime(asked) {}- let log = try String(contentsOf: calls, encoding: .utf8).split(separator: "\n").map(String.init)- return (model, log, calls, base)- }-- /// The player may rather hand the game files to the device themselves (a fast external drive in Files):- /// a skipped copy still counts as installed, and nothing is sent over USB.- @MainActor func testSkippingTheTransferInstallsWithoutCopying() throws {- let (model, log, _, _) = try runInstallFlow(transfer: false)- XCTAssertFalse(log.contains { $0.hasPrefix("devicectl device copy") })- XCTAssertEqual(model.installedOn, "00008150-AAAA")- XCTAssertEqual(model.doneNote, String(format: model.t("dev.copySkipped"), "iPhone"))- XCTAssertEqual(model.stages.filter { $0.id >= 1000 }.map(\.state), [.done, .done, .done]) // pack, sign, install — no copy row- }-- @MainActor func testBuildSignsAndInstallsOnTheChosenDevice() throws {- let (model, log, calls, base) = try runInstallFlow(transfer: true)- let work = temporary.appendingPathComponent(titleID + "_build").path- XCTAssertTrue(log[0].contains("--prepare-xcode --keep-extracted --team-id TEAM123456"))- XCTAssertFalse(log[0].contains(" -o ")) // no IPA: the project goes to the device- let build = try XCTUnwrap(log.first { $0.hasPrefix("xcodebuild -project") })- for part in ["-scheme Test (0100535012974000)", "-destination id=00008150-AAAA", "-derivedDataPath \(work)/xcode-derived-data",- "-allowProvisioningUpdates", "DEVELOPMENT_TEAM=TEAM123456", "DM_COPY_ROMFS=NO"] { XCTAssertTrue(build.contains(part), part) }- // The first sign failed on the taken App ID; the retry ran under the team's bundle ID and kept the same stage row.- let signs = log.filter { $0.hasPrefix("xcodebuild -project") }- XCTAssertEqual(signs.count, 2)- XCTAssertTrue(signs[1].contains("PRODUCT_BUNDLE_IDENTIFIER=org.nxnative.\(titleID).TEAM123456"), String(signs[1]))- XCTAssertEqual(Set(model.stages.filter { $0.id >= 1000 }.map(\.id)).count, 4) // a retried stage keeps its row instead of piling up duplicates- let app = work + "/xcode-derived-data/Build/Products/Release-iphoneos/DmIOS.app"- let archive = temporary.path + "/games/\(titleID)"- // the archive is packed before signing, the app installed before the archive goes into its Documents- let order = ["romfs_image --reuse", "xcodebuild -project", "devicectl device install", "devicectl device copy"].map { step in log.firstIndex { $0.hasPrefix(step) } }- XCTAssertEqual(order.compactMap { $0 }, order.compactMap { $0 }.sorted())- XCTAssertEqual(order.compactMap { $0 }.count, 4)- XCTAssertTrue(log.contains("devicectl device install app --device 00008150-AAAA \(app)"))- XCTAssertTrue(log.contains("devicectl device copy to --device 00008150-AAAA --source \(archive) --destination Documents/games/\(titleID) --domain-type appDataContainer --domain-identifier org.nxnative.test"))- XCTAssertTrue(FileManager.default.fileExists(atPath: archive + "/romfs.img"))- XCTAssertEqual(model.archivePath, archive)- XCTAssertEqual(model.installedOn, "00008150-AAAA")- XCTAssertEqual(model.stages.filter { $0.id >= 1000 }.map(\.state), [.done, .done, .done, .done])- let library = GameLibrary(file: temporary.appendingPathComponent("library.json"))- model.slots[0].paths = [base.path]- let id = try XCTUnwrap(library.rememberInputs(model))- library.recordCompletedIOS(ipa: model.ipaPath, archive: model.archivePath, app: model.installedAppPath, device: model.installedOn, for: id)- XCTAssertTrue(library.games[0].onDevice)- let opened = expectation(description: "Opened on the device")- model.openOnDevice(udid: model.installedOn, app: model.installedAppPath) { error in XCTAssertNil(error); opened.fulfill() }- wait(for: [opened], timeout: 10)- XCTAssertTrue(try String(contentsOf: calls, encoding: .utf8).contains("devicectl device process launch --device 00008150-AAAA org.nxnative.test"))- }-- /// A deleted app comes back without unpacking, signing or packing anything again: the signed app already in- /// derived data is installed as it is, and the device keeps the game data (the bundle ID does not change).- @MainActor func testReinstallInstallsTheSignedAppWithoutBuildingAgain() throws {- let (model, _, calls, _) = try runInstallFlow(transfer: true)- let app = model.installedAppPath- let buildsBefore = try String(contentsOf: calls, encoding: .utf8).split(separator: "\n").filter { $0.hasPrefix("xcodebuild") }.count- let done = expectation(description: "Reinstalled")- model.reinstallOnDevice { done.fulfill() }- wait(for: [done], timeout: 20)- let log = try String(contentsOf: calls, encoding: .utf8).split(separator: "\n").map(String.init)- XCTAssertEqual(log.filter { $0.hasPrefix("devicectl device install app") }.count, 2)- XCTAssertEqual(log.last { $0.hasPrefix("devicectl device install app") }, "devicectl device install app --device 00008150-AAAA \(app)")- XCTAssertEqual(log.filter { $0.hasPrefix("xcodebuild") }.count, buildsBefore) // no second build- XCTAssertEqual(log.filter { $0.hasPrefix("romfs_image") }.count, 1) // the game files are not re-packed- XCTAssertEqual(model.stages.last?.id, 1004)- XCTAssertEqual(model.stages.last?.state, .done)- XCTAssertEqual(model.doneNote, String(format: model.t("dev.reinstalled"), "iPhone"))- XCTAssertFalse(model.running)- }-- /// The saved package is an ordinary IPA — Payload/DmIOS.app/… at the archive's root, no __MACOSX — so a- /// sideloader or another Mac installs it while the signature lasts, without building the game again.- @MainActor func testSaveIPAWritesAnOrdinaryPayloadArchive() throws {- let (model, _, _, _) = try runInstallFlow(transfer: true)- XCTAssertEqual(model.defaultIPAName(), "DmIOS.ipa")- let ipa = temporary.appendingPathComponent("Test Game.ipa")- let saved = expectation(description: "Saved the IPA")- model.saveIPA(to: ipa) { saved.fulfill() }- wait(for: [saved], timeout: 30)- XCTAssertTrue(FileManager.default.fileExists(atPath: ipa.path))- let unzip = Process(), out = Pipe()- unzip.executableURL = URL(fileURLWithPath: "/usr/bin/unzip")- unzip.arguments = ["-l", ipa.path]- unzip.standardOutput = out- try unzip.run(); unzip.waitUntilExit()- let listing = String(decoding: out.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self)- XCTAssertEqual(unzip.terminationStatus, 0, listing)- XCTAssertTrue(listing.contains("Payload/DmIOS.app/Info.plist"), listing)- XCTAssertFalse(listing.contains("__MACOSX"), listing)- XCTAssertEqual(model.doneNote, String(format: model.t("dev.savedIPA"), model.shortPath(ipa.path)))- XCTAssertFalse(model.running)- }-- /// Both actions name what is missing instead of doing nothing, and a failed reinstall is a note on the installed- /// app, not a failed build (the app is still on the device).+ /// An action on the installed app names what is missing instead of doing nothing, and a failed reinstall is a note on+ /// the installed app, not a failed build (the app is still on the device).@MainActor func testReinstallAndSaveReportAMissingSignedApp() throws {- let (model, _, _, _) = try runInstallFlow(transfer: true)- try FileManager.default.removeItem(atPath: model.installedAppPath)+ let model = BuildModel()+ model.xcrunPath = "/usr/bin/true"+ model.installedOn = "00008150-AAAA"+ model.installedAppPath = temporary.path + "/gone/DmShell.app"var reported = expectation(description: "Reinstall says what is missing")model.reinstallOnDevice { reported.fulfill() }wait(for: [reported], timeout: 10)XCTAssertEqual(model.doneNote, String(format: model.t("dev.reinstallMissing"), model.shortPath(model.installedAppPath)))- XCTAssertTrue(model.done)reported = expectation(description: "Save says what is missing")let ipa = temporary.appendingPathComponent("missing.ipa")model.saveIPA(to: ipa) { reported.fulfill() }@@ -563,50 +391,38 @@ final class LibraryTests: XCTestCase {["/usr/bin/ditto", "-c", "-k", "--norsrc", "--keepParent", "/t/Payload", "/o/Game.ipa"])}- /// A re-sign is the install's xcodebuild line (same project, derived data, team) plus the installed app's own bundle- /// ID, so Xcode reuses the compiled game and the device keeps the app's Documents; then the app is installed again,- /// with no second romfs pack.- @MainActor func testResignSignsAgainAndInstallsWithoutRepacking() throws {- let (model, _, calls, _) = try runInstallFlow(transfer: true)- let app = model.installedAppPath- let done = expectation(description: "Re-signed")- model.resignOnDevice(app: app, device: "00008150-AAAA") { done.fulfill() }- wait(for: [done], timeout: 30)- let log = try String(contentsOf: calls, encoding: .utf8).split(separator: "\n").map(String.init)- let resign = try XCTUnwrap(log.last { $0.hasPrefix("xcodebuild -project") })- for part in ["-derivedDataPath \(temporary.path)/\(titleID)_build/xcode-derived-data", "-allowProvisioningUpdates",- "DEVELOPMENT_TEAM=TEAM123456", "DM_COPY_ROMFS=NO", "PRODUCT_BUNDLE_IDENTIFIER=org.nxnative.test", "build"] {- XCTAssertTrue(resign.contains(part), part)- }- XCTAssertEqual(log.filter { $0.hasPrefix("xcodebuild -project") }.count, 3) // the install's two signs, then this one- XCTAssertEqual(log.filter { $0.hasPrefix("romfs_image") }.count, 1) // the game files are not packed again- XCTAssertEqual(log.last { $0.hasPrefix("devicectl device install app") },- "devicectl device install app --device 00008150-AAAA \(app)")- XCTAssertEqual(model.doneNote, String(format: model.t("dev.resigned"), "iPhone"))- XCTAssertFalse(model.running)- }-- /// A re-sign that cannot work says what to do: a missing cached project, or no signing team chosen.- @MainActor func testResignReportsAMissingProjectOrTeam() throws {- let (model, _, _, _) = try runInstallFlow(transfer: true)+ /// An app from before the shared app has no project to sign again: the note says to build the game again. Without a team+ /// the note asks for one first.+ @MainActor func testResignOfAnOlderAppAsksForANewBuild() throws {let savedTeam = UserDefaults.standard.string(forKey: "signingTeam")defer { UserDefaults.standard.set(savedTeam, forKey: "signingTeam") }- // An app with a bundle ID but no project beside it: the cached build was moved or removed.- let orphan = temporary.appendingPathComponent("orphan/xcode-derived-data/Build/Products/Release-iphoneos/DmIOS.app")- try FileManager.default.createDirectory(at: orphan, withIntermediateDirectories: true)- try PropertyListSerialization.data(fromPropertyList: ["CFBundleIdentifier": bundleID], format: .xml, options: 0)- .write(to: orphan.appendingPathComponent("Info.plist"))- var reported = expectation(description: "Missing project reported")- model.resignOnDevice(app: orphan.path, device: "00008150-AAAA") { reported.fulfill() }+ let model = BuildModel()+ let older = temporary.appendingPathComponent("0100_build/xcode-derived-data/Build/Products/Release-iphoneos/DmIOS.app").path+ model.signingTeam = "TEAM123456"+ var reported = expectation(description: "Older app reported")+ model.resignOnDevice(app: older, device: "00008150-AAAA") { reported.fulfill() }wait(for: [reported], timeout: 10)- XCTAssertEqual(model.doneNote, String(format: model.t("dev.resignNoProject"),- model.shortPath(temporary.path + "/orphan/xcode/DmIOS.xcodeproj")))+ XCTAssertEqual(model.doneNote, model.t("dev.resignOlder"))+ XCTAssertFalse(model.running)model.signingTeam = ""reported = expectation(description: "Missing team reported")- model.resignOnDevice(app: model.installedAppPath, device: "00008150-AAAA") { reported.fulfill() }+ model.resignOnDevice(app: older, device: "00008150-AAAA") { reported.fulfill() }wait(for: [reported], timeout: 10)XCTAssertEqual(model.doneNote, model.t("dev.resignNoTeam"))- XCTAssertFalse(model.running)+ }++ /// The shared app's project is gone (the shell folder was removed): the note names it.+ @MainActor func testResignReportsAMissingSharedProject() throws {+ let savedTeam = UserDefaults.standard.string(forKey: "signingTeam")+ defer { UserDefaults.standard.set(savedTeam, forKey: "signingTeam") }+ let model = BuildModel()+ model.signingTeam = "TEAM123456"+ let shared = temporary.appendingPathComponent("shell/derived-data/Build/Products/Release-iphoneos/DmShell.app")+ let reported = expectation(description: "Missing project reported")+ model.resignOnDevice(app: shared.path, device: "00008150-AAAA") { reported.fulfill() }+ wait(for: [reported], timeout: 10)+ let project = try XCTUnwrap(ShellInstall.paths(ofApp: shared.path)).project+ XCTAssertEqual(model.doneNote, String(format: model.t("dev.resignNoProject"), model.shortPath(project)))}func testCorruptLibraryIsReportedWithoutOverwritingIt() throws {@@ -1194,7 +1010,7 @@ final class LibraryTests: XCTestCase {try FileManager.default.createDirectory(at: installed, withIntermediateDirectories: true)try PropertyListSerialization.data(fromPropertyList: ["CFBundleIdentifier": "com.example.hades"], format: .xml, options: 0).write(to: installed.appendingPathComponent("Info.plist"))- library.recordCompletedIOS(ipa: "", archive: "", app: installed.path, device: "00008150-AAAA", for: game.id)+ library.recordCompletedIOS(archive: "", app: installed.path, device: "00008150-AAAA", for: game.id)let support = temporary.appendingPathComponent("Application Support")let save = SaveTransfer.legacyMacSave(titleID: game.titleID, support: support).appendingPathComponent("data.bin")try FileManager.default.createDirectory(at: save.deletingLastPathComponent(), withIntermediateDirectories: true)diff --git a/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swift b/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swiftindex 46c807fe..18a95622 100644--- a/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swift+++ b/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swift@@ -138,11 +138,12 @@ final class OlderToolsTests: XCTestCase {let library = GameLibrary(file: file)XCTAssertNil(library.error)XCTAssertEqual(library.games.first?.toolsCommit, "")- let ipa = temporary.appendingPathComponent("Hades.ipa")- try Data("ipa".utf8).write(to: ipa)- library.recordCompletedIOS(ipa: ipa.path, archive: "", commit: "abc123", for: id)+ let app = temporary.appendingPathComponent("DmShell.app")+ try FileManager.default.createDirectory(at: app, withIntermediateDirectories: true)+ try Data("plist".utf8).write(to: app.appendingPathComponent("Info.plist"))+ library.recordCompletedIOS(archive: "", app: app.path, commit: "abc123", for: id)XCTAssertEqual(GameLibrary(file: file).games.first?.toolsCommit, "abc123")- library.recordCompletedIOS(ipa: ipa.path, archive: "", for: id) // a build from a checkout without git: nothing to compare+ library.recordCompletedIOS(archive: "", app: app.path, for: id) // a build from a checkout without git: nothing to compareXCTAssertEqual(GameLibrary(file: file).games.first?.toolsCommit, "")}}diff --git a/frontend/Tests/NSPortBuilderTests/RepoToolsTests.swift b/frontend/Tests/NSPortBuilderTests/RepoToolsTests.swiftindex 2d63c873..9a0b8807 100644--- a/frontend/Tests/NSPortBuilderTests/RepoToolsTests.swift+++ b/frontend/Tests/NSPortBuilderTests/RepoToolsTests.swift@@ -69,6 +69,7 @@ final class RepoToolsTests: XCTestCase {try write(["dm/tools/nx_extract/Program.cs", BuildModel.buildScript], in: repo)let m = BuildModel()m.repoPath = repo.path+ m.target = BuildTarget.macm.startBuild()XCTAssertFalse(m.running, "no build was started")XCTAssertTrue(m.doneNote.contains(BuildModel.romfsImageTool), m.doneNote)diff --git a/frontend/Tests/NSPortBuilderTests/ShellInstallTests.swift b/frontend/Tests/NSPortBuilderTests/ShellInstallTests.swiftindex bde2bb45..5a193a9a 100644--- a/frontend/Tests/NSPortBuilderTests/ShellInstallTests.swift+++ b/frontend/Tests/NSPortBuilderTests/ShellInstallTests.swift@@ -154,7 +154,7 @@ final class ShellInstallTests: XCTestCase {}func testEveryLanguageHasTheShellTexts() {- for key in ["build.shell", "build.shellNote", "shell.projectStage", "shell.projectFailed", "shell.checkStage", "shell.dataAlready",+ for key in ["build.iosNote", "shell.projectStage", "shell.projectFailed", "shell.checkStage", "shell.dataAlready","shell.noFramework", "shell.needsDevice", "shell.copySize", "shell.copyWired", "shell.copyWifi", "shell.copyWifiOne","shell.copyWifiMinute", "shell.copyNotConnected", "shell.copyWaiting", "shell.copyTitle", "shell.copyContinue","shell.copyWaitCable", "shell.copySkip", "shell.copyStopWaiting", "shell.retry", "shell.notPaired",@@ -167,7 +167,7 @@ final class ShellInstallTests: XCTestCase {XCTAssertFalse(text.contains(";") || text.contains(";"), key)}}- XCTAssertEqual(L10n.string("build.shell", .en), "iPhone or iPad (one app for all games)")+ XCTAssertEqual(L10n.string("build.iosNote", .en), "One app on your iPhone or iPad for all your games.")}// ---- the stand-ins ----@@ -627,7 +627,7 @@ final class ShellInstallTests: XCTestCase {UserDefaults.standard.set(f.root, forKey: "shellRoot")let model = BuildModel()model.repoPath = f.repo- model.target = "ios-shell"+ model.target = "ios"model.outDir = path("out")model.pythonPath = "/usr/bin/python3"model.dotnetPath = "/usr/bin/true"@@ -691,7 +691,7 @@ final class ShellInstallTests: XCTestCase {@MainActor private func makeModel(_ f: Fixture) throws -> BuildModel {let model = BuildModel()model.repoPath = f.repo- model.target = "ios-shell"+ model.target = "ios"model.outDir = path("out")model.pythonPath = "/usr/bin/python3"model.dotnetPath = "/usr/bin/true"@@ -767,7 +767,7 @@ final class ShellInstallTests: XCTestCase {let model = BuildModel()model.repoPath = temporary.pathtry write(temporary.path + "/dm/tools/nx_extract/Program.cs", "")- model.target = "ios-shell"+ model.target = "ios"model.installDevice = ""model.startBuild()XCTAssertFalse(model.running)diff --git a/frontend/Tests/NSPortBuilderTests/SignatureTests.swift b/frontend/Tests/NSPortBuilderTests/SignatureTests.swiftindex 49970e7d..4922c6b1 100644--- a/frontend/Tests/NSPortBuilderTests/SignatureTests.swift+++ b/frontend/Tests/NSPortBuilderTests/SignatureTests.swift@@ -64,24 +64,4 @@ final class SignatureTests: XCTestCase {XCTAssertEqual(AppSignature.short(inThree, { L10n.string($0, .en) }, now: now), "3 days of signature left")XCTAssertEqual(AppSignature.short(yesterday, { L10n.string($0, .en) }, now: now), "signature expired")}-- /// The re-sign is the install's xcodebuild line plus the installed app's own bundle ID: the same derived data makes- /// Xcode reuse the compiled game, and the identifier keeps the app's Documents.- func testTheResignCommandMatchesTheInstallPlusTheBundleID() {- let command = BuildModel.resignCommand(xcrun: "/x", project: "/w/xcode/DmIOS.xcodeproj", scheme: "Test (0100)",- device: "UDID", derived: "/w/xcode-derived-data", team: "TEAM123456",- bundle: "org.nxnative.test")- XCTAssertEqual(command, ["/x", "xcodebuild", "-project", "/w/xcode/DmIOS.xcodeproj", "-scheme", "Test (0100)",- "-configuration", "Release", "-destination", "id=UDID", "-derivedDataPath", "/w/xcode-derived-data",- "-allowProvisioningUpdates", "DEVELOPMENT_TEAM=TEAM123456", "DM_COPY_ROMFS=NO",- "PRODUCT_BUNDLE_IDENTIFIER=org.nxnative.test", "build"])- }-- /// An installed app's path names its work folder, and with it the project and derived data a re-sign must reuse.- func testBuildPathsComeFromTheInstalledApp() {- let paths = BuildModel.buildPaths(ofApp: "/Users/x/0100_build/xcode-derived-data/Build/Products/Release-iphoneos/DmIOS.app")- XCTAssertEqual(paths?.project, "/Users/x/0100_build/xcode/DmIOS.xcodeproj")- XCTAssertEqual(paths?.derived, "/Users/x/0100_build/xcode-derived-data")- XCTAssertNil(BuildModel.buildPaths(ofApp: "/elsewhere/DmIOS.app"))- }}