Skip to content

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

Shared app handoff: say which game's framework is missing and what to try (#491)

v0lumehic42cdd8426e2
diff --git a/frontend/Sources/NXCore/ShellExport.swift b/frontend/Sources/NXCore/ShellExport.swift
index 38c44059..7179f96f 100644
--- a/frontend/Sources/NXCore/ShellExport.swift
+++ b/frontend/Sources/NXCore/ShellExport.swift
@@ -101,7 +101,7 @@ extension ShellInstaller {
/// The export: the library and the project, the unsigned build, the entitlements, the IPA. Needs no device and no team.
package func export(framework: String, titleID: String, name: String) -> Outcome {
let fm = FileManager.default
- guard fm.fileExists(atPath: framework) else { return Outcome(ok: false, message: fmt("shell.noFramework", framework)) }
+ guard fm.fileExists(atPath: framework) else { return missingFramework(framework, name: name) }
let prepared = prepareShell(framework: framework, titleID: titleID, name: name)
guard let library = prepared.library else { return prepared.failure! }
diff --git a/frontend/Sources/NXCore/ShellInstall.swift b/frontend/Sources/NXCore/ShellInstall.swift
index 6b355542..01e4a95b 100644
--- a/frontend/Sources/NXCore/ShellInstall.swift
+++ b/frontend/Sources/NXCore/ShellInstall.swift
@@ -477,9 +477,18 @@ package struct ShellInstaller {
}
}
+ /// The framework the build should have written is not there: the build steps passed, but a framework deleted by hand, a
+ /// cancelled build, a moved work folder or an old build folder leaves nothing to hand off (#491). The message names the game and the
+ /// folder by its short name and says what to do. The full path goes to the log.
+ func missingFramework(_ framework: String, name: String) -> Outcome {
+ log("framework: not found at \(framework)\n")
+ let folder = ((framework as NSString).deletingLastPathComponent as NSString).lastPathComponent
+ return Outcome(ok: false, message: fmt("shell.noFramework", name, folder.isEmpty ? "shell-framework" : folder))
+ }
+
package func install(framework: String, titleID: String, name: String, archive: String) -> Outcome {
guard FileManager.default.fileExists(atPath: framework) else {
- return Outcome(ok: false, message: fmt("shell.noFramework", framework))
+ return missingFramework(framework, name: name)
}
// A device this Mac never paired is found out now, not after the signing: nothing is built for it
if let refused = pairingRefusal() { return refused }
diff --git a/frontend/Tests/NX2AppleTests/MissingFrameworkCaptureTests.swift b/frontend/Tests/NX2AppleTests/MissingFrameworkCaptureTests.swift
new file mode 100644
index 00000000..f6e101cd
--- /dev/null
+++ b/frontend/Tests/NX2AppleTests/MissingFrameworkCaptureTests.swift
@@ -0,0 +1,45 @@
+import XCTest
+import SwiftUI
+import AppKit
+@testable import NX2Apple
+@testable import NXCore
+import NXModel
+@testable import NXLauncher
+
+/// Visual QA of the missing-framework message (LNPANDY/NX2Apple#491, matched by --filter testRenderMissingFrameworkForVisualQA).
+/// The Builds page's action card with the note a handoff leaves when the game's framework is not in the build folder.
+final class MissingFrameworkCaptureTests: XCTestCase {
+ @MainActor func testRenderMissingFrameworkForVisualQA() throws {
+ guard let directory = ProcessInfo.processInfo.environment["NX_LAUNCHER_CAPTURE_DIR"] else { throw XCTSkip("Set NX_LAUNCHER_CAPTURE_DIR to capture native views") }
+ let output = URL(fileURLWithPath: directory)
+ try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)
+ let lang = ProcessInfo.processInfo.environment["NX_CAPTURE_LANG"].flatMap { Lang.find($0) } ?? .en
+ let stores = LauncherStores(); let model = stores.build
+ stores.localizer.lang = lang
+ var installer = ShellInstaller(xcrun: "/usr/bin/xcrun", repo: "/nonexistent", python: "/usr/bin/python3", root: "/nonexistent",
+ device: "", team: "")
+ installer.lang = lang
+ let missing = "/Users/me/Library/Application Support/NX2Apple/builds/Super Mario Odyssey/shell-framework/DmGame0100000000010000.framework"
+ // NX_CAPTURE_NOTE puts a note of the old wording into the card for the "before" image
+ model.doneNote = ProcessInfo.processInfo.environment["NX_CAPTURE_NOTE"]
+ ?? installer.export(framework: missing, titleID: "0100000000010000", name: "Super Mario Odyssey").message
+ let card = ActionCard(build: model, dependencies: stores.dependencies, repo: stores.repo)
+ .environmentObject(stores.localizer).padding(24).frame(width: 760)
+ .background(Color(white: 0.09)).environment(\.colorScheme, .dark)
+ NSApplication.shared.setActivationPolicy(.accessory)
+ let host = NSHostingView(rootView: card)
+ host.frame = NSRect(origin: .zero, size: host.fittingSize)
+ host.wantsLayer = true
+ host.layer?.backgroundColor = NSColor(white: 0.09, alpha: 1).cgColor
+ let window = OffscreenWindow(size: host.frame.size)
+ window.contentView = host
+ window.orderFront(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))
+ host.layoutSubtreeIfNeeded()
+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))
+ host.cacheDisplay(in: host.bounds, to: rep)
+ let name = ProcessInfo.processInfo.environment["NX_CAPTURE_NAME"] ?? "missing-framework"
+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent("\(name)-\(lang.code).png"))
+ window.orderOut(nil)
+ }
+}
diff --git a/frontend/Tests/NX2AppleTests/ShellExportTests.swift b/frontend/Tests/NX2AppleTests/ShellExportTests.swift
index 75153f96..d2aa68f1 100644
--- a/frontend/Tests/NX2AppleTests/ShellExportTests.swift
+++ b/frontend/Tests/NX2AppleTests/ShellExportTests.swift
@@ -219,6 +219,24 @@ import NXModel
XCTAssertFalse(fm.fileExists(atPath: state + "/shell-env.txt"))
}
+ /// #491: the build steps were green and the Builds page ended in "The game's framework was not found: <path>", cut off.
+ func testAMissingFrameworkNamesTheGameAndKeepsThePathInTheLogOnly() throws {
+ let f = try makeFixture()
+ let missing = path("work/shell-framework/DmGame\(titleID).framework.gone")
+ var logged = ""
+ var i = installer(f)
+ i.log = { logged += $0 }
+ let outcome = i.export(framework: missing, titleID: titleID, name: "Test Game")
+ XCTAssertFalse(outcome.ok)
+ XCTAssertEqual(outcome.message, String(format: L10n.string("shell.noFramework", .en), "Test Game", "shell-framework"))
+ XCTAssertTrue(outcome.message.contains("Test Game"), outcome.message)
+ XCTAssertFalse(outcome.message.contains("/"), outcome.message)
+ XCTAssertTrue(logged.contains(missing), logged)
+ // the install path says the same
+ let installed = i.install(framework: missing, titleID: titleID, name: "Test Game", archive: "")
+ XCTAssertEqual(installed.message, outcome.message)
+ }
+
// ---- a framework that a cut-off delete or copy left incomplete ----
/// v1.0.2-rc1: the launcher was quit while the stale prompt deleted Breath of the Wild's framework (a minute for its shader files).
diff --git a/frontend/Tests/NX2AppleTests/ShellInstallTests.swift b/frontend/Tests/NX2AppleTests/ShellInstallTests.swift
index ceb3c3dc..96954dc1 100644
--- a/frontend/Tests/NX2AppleTests/ShellInstallTests.swift
+++ b/frontend/Tests/NX2AppleTests/ShellInstallTests.swift
@@ -614,7 +614,7 @@ import NXModel
output = ""
XCTAssertEqual(ShellCLI.run(f.args(extra: ["--framework", path("missing.framework")]),
defaults: UserDefaults(suiteName: "nspb-shell-" + UUID().uuidString)!) { output += $0 }, 1)
- XCTAssertTrue(output.contains("framework was not found"), output)
+ XCTAssertTrue(output.contains("its framework is not in the"), output)
}
// ---- the lead's three: memory capability, free space, the shell's log ----
diff --git a/frontend/l10n/de.json b/frontend/l10n/de.json
index 95a8fce3..dd99f91e 100644
--- a/frontend/l10n/de.json
+++ b/frontend/l10n/de.json
@@ -1042,7 +1042,7 @@
"shell.modeInstall": "Auf Gerät installieren",
"shell.modeTitle": "Installieren oder exportieren",
"shell.needsDevice": "Die gemeinsame App braucht ein Gerät und ein Signier-Team. Wähle sie zuerst unter Installieren auf.",
- "shell.noFramework": "Das Framework des Spiels wurde nicht gefunden: %@",
+ "shell.noFramework": "Der Build von %1$@ ist fertig, aber sein Framework liegt nicht im Ordner %2$@. Baue das Spiel erneut.",
"shell.noSpace": "Nicht genug Platz auf %@: Die Spieldaten brauchen %.1f GB und auf dem Gerät sind %.1f GB frei. Gib Speicher frei und installiere dann erneut",
"shell.notPaired": "%@ ist nicht mit diesem Mac gekoppelt. Schließe es mit einem Kabel an, tippe auf dem Gerät auf Vertrauen und gib den Code ein. Starte dann erneut.",
"shell.oneGameDone": "%@, nicht signiert. Die Spieldaten sind enthalten.",
diff --git a/frontend/l10n/en.json b/frontend/l10n/en.json
index 5e2be2b3..cb6ae4a9 100644
--- a/frontend/l10n/en.json
+++ b/frontend/l10n/en.json
@@ -1166,7 +1166,7 @@
"shell.modeInstall": "Install on device",
"shell.modeTitle": "Install or export",
"shell.needsDevice": "The shared app needs a device and a signing team. Choose them under Install on first.",
- "shell.noFramework": "The game's framework was not found: %@",
+ "shell.noFramework": "The build of %1$@ finished, but its framework is not in the %2$@ folder. Build the game again.",
"shell.noSpace": "Not enough space on %@: the game data needs %.1f GB and the device has %.1f GB free. Free up space, then install again",
"shell.notPaired": "%@ is not paired with this Mac. Connect it with a cable, tap Trust on the device and enter its passcode. Then start again.",
"shell.oneGameDone": "%@, unsigned. The game data is inside.",
diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.json
index 9415c6ae..ea2890bd 100644
--- a/frontend/l10n/fr.json
+++ b/frontend/l10n/fr.json
@@ -1041,7 +1041,7 @@
"shell.modeInstall": "Installer sur l’appareil",
"shell.modeTitle": "Installer ou exporter",
"shell.needsDevice": "L’app partagée a besoin d’un appareil et d’une équipe de signature. Choisissez-les d’abord sous Installer sur.",
- "shell.noFramework": "Le framework du jeu est introuvable : %@",
+ "shell.noFramework": "La compilation de %1$@ est terminée, mais son framework n'est pas dans le dossier %2$@. Reconstruisez le jeu.",
"shell.noSpace": "Pas assez d’espace sur %@ : les données du jeu demandent %.1f Go et l’appareil en a %.1f Go de libres. Libérez de l’espace, puis réinstallez",
"shell.notPaired": "%@ n’est pas associé à ce Mac. Branchez-le avec un câble, touchez Se fier sur l’appareil et saisissez son code. Puis recommencez.",
"shell.oneGameDone": "%@, non signé. Les données du jeu sont incluses.",
diff --git a/frontend/l10n/it.json b/frontend/l10n/it.json
index 22bf9f00..870a92a3 100644
--- a/frontend/l10n/it.json
+++ b/frontend/l10n/it.json
@@ -1041,7 +1041,7 @@
"shell.modeInstall": "Installa sul dispositivo",
"shell.modeTitle": "Installa o esporta",
"shell.needsDevice": "L’app condivisa richiede un dispositivo e un team di firma. Prima sceglili in Installa su.",
- "shell.noFramework": "Framework del gioco non trovato: %@",
+ "shell.noFramework": "La compilazione di %1$@ è terminata, ma il suo framework non è nella cartella %2$@. Compila di nuovo il gioco.",
"shell.noSpace": "Spazio insufficiente su %@: i dati di gioco richiedono %.1f GB e il dispositivo ha %.1f GB liberi. Libera spazio, poi installa di nuovo",
"shell.notPaired": "%@ non è abbinato a questo Mac. Collegalo con un cavo, tocca Autorizza sul dispositivo e inserisci il codice. Poi ricomincia.",
"shell.oneGameDone": "%@, non firmata. I dati di gioco sono inclusi.",
diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.json
index 2de63c69..305da61c 100644
--- a/frontend/l10n/sv.json
+++ b/frontend/l10n/sv.json
@@ -878,7 +878,7 @@
"shell.modeInstall": "Installera på enheten",
"shell.modeTitle": "Installera eller exportera",
"shell.needsDevice": "Den gemensamma appen behöver en enhet och ett signeringsteam. Välj dem först under Installera på.",
- "shell.noFramework": "Spelets ramverk hittades inte: %@",
+ "shell.noFramework": "Bygget av %1$@ är klart, men spelets ramverk finns inte i mappen %2$@. Bygg spelet igen.",
"shell.noSpace": "Inte tillräckligt med utrymme på %@: speldatan behöver %.1f GB och enheten har %.1f GB ledigt. Frigör utrymme och installera igen",
"shell.notPaired": "%@ är inte ihopparad med den här Mac-datorn. Anslut den med kabel, tryck på Lita på i enheten och ange enhetens lösenkod. Starta sedan om.",
"shell.oneGameDone": "%@, osignerad. Speldata finns med.",
diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.json
index 32fbdb37..f5fdde33 100644
--- a/frontend/l10n/zh.json
+++ b/frontend/l10n/zh.json
@@ -1167,7 +1167,7 @@
"shell.modeInstall": "安装到设备",
"shell.modeTitle": "安装或导出",
"shell.needsDevice": "共用应用需要一台设备和一个签名团队。请先在“安装到”里选择。",
- "shell.noFramework": "没有找到游戏的框架:%@",
+ "shell.noFramework": "%1$@ 已构建完成,但它的框架不在 %2$@ 文件夹里。请重新构建这个游戏。",
"shell.noSpace": "%@ 上空间不足:游戏数据需要 %.1f GB,设备只剩 %.1f GB。请先释放空间再安装",
"shell.notPaired": "这台 Mac 还没有与 %@ 配对。请用数据线连接,在设备上点「信任」并输入设备密码,然后重新开始。",
"shell.oneGameDone": "%@,未签名。已包含游戏数据。",