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: a cut-off framework delete no longer breaks the next build

v0lumehi5f0350e2d5a4
diff --git a/frontend/Sources/NXCore/ShellExport.swift b/frontend/Sources/NXCore/ShellExport.swift
index 4e262670..38c44059 100644
--- a/frontend/Sources/NXCore/ShellExport.swift
+++ b/frontend/Sources/NXCore/ShellExport.swift
@@ -48,15 +48,23 @@ extension ShellInstaller {
package static let exportBuildStageID = 1012, exportPackStageID = 1013
/// Steps 3 and 4 of the install, which the export shares: the library with this game, and the shell's project.
- /// Exactly one of `failure` and (`library`, `env`) is set.
+ /// Exactly one of `failure` and (`library`, `env`) is set. `notes` name the games left out because their framework is incomplete.
func prepareShell(framework: String, titleID: String, name: String)
- -> (library: ShellLibrary?, env: [String: String]?, failure: Outcome?) {
+ -> (library: ShellLibrary?, env: [String: String]?, failure: Outcome?, notes: [String]) {
// 3: the library
+ ShellInstall.sweepDiscarded(in: ShellInstall.frameworksMirror(root: root))
var library = ShellLibrary.load(root: root)
if !team.isEmpty { library.team = team } // the export has no team: keep the one an install stored
library.add(.init(titleID: titleID, name: name, framework: framework))
mirrorFrameworks(&library)
library.dropMissing()
+ let checked = leaveOutIncomplete(&library, titleID: titleID, name: name) // ShellFrameworks.swift
+ if let why = checked.failure {
+ let projectName = t("shell.projectStage")
+ begin(Self.projectStageID, projectName)
+ end(Self.projectStageID, projectName, ok: false, detail: why)
+ return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", why)), [])
+ }
// The 16:9 banner of the shell's library for every game in it (ShellHost reads <framework>/banner.<ext>, the square
// icon.png is the fallback): a game rebuilt since its last install gets its banner back too
for game in library.games {
@@ -66,13 +74,13 @@ extension ShellInstaller {
}
}
do { try library.save(root: root) } catch {
- return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", error.localizedDescription)))
+ return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", error.localizedDescription)), [])
}
// 4: the project
guard let package = ShellInstall.shellPackage(resources: resources, repo: repo) else {
let looked = ([resources, repo].compactMap { $0 }.filter { !$0.isEmpty }).map { $0 + "/frontend-ios" }.joined(separator: ", ")
- return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", "no frontend-ios Swift package (Package.swift) in " + looked)))
+ return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", "no frontend-ios Swift package (Package.swift) in " + looked)), [])
}
var env = ShellInstall.projectEnvironment(root: root, frameworks: library.games.map(\.framework), bundleID: library.bundleID,
team: team, python: python, path: toolPath, home: NSHomeDirectory(), user: NSUserName(),
@@ -84,10 +92,10 @@ extension ShellInstaller {
if project.status != 0 {
let why = ShellInstall.scriptFailure(project.output) ?? fmt("msg.exitCode", project.status)
end(Self.projectStageID, projectName, ok: false, detail: why)
- return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", why)))
+ return (nil, nil, Outcome(ok: false, message: fmt("shell.projectFailed", why)), [])
}
end(Self.projectStageID, projectName, ok: true)
- return (library, env, nil)
+ return (library, env, nil, checked.notes)
}
/// The export: the library and the project, the unsigned build, the entitlements, the IPA. Needs no device and no team.
@@ -146,7 +154,7 @@ extension ShellInstaller {
return Outcome(ok: false, message: fmt("shell.exportFailed", why))
}
end(Self.exportPackStageID, packName, ok: true)
- var outcome = Outcome(ok: true, message: fmt("shell.exportDone", ipa), bundleID: library.bundleID)
+ var outcome = Outcome(ok: true, message: ([fmt("shell.exportDone", ipa)] + prepared.notes).joined(separator: "\n"), bundleID: library.bundleID)
outcome.ipaPath = ipa
return outcome
}
diff --git a/frontend/Sources/NXCore/ShellFrameworks.swift b/frontend/Sources/NXCore/ShellFrameworks.swift
new file mode 100644
index 00000000..13f6b0a9
--- /dev/null
+++ b/frontend/Sources/NXCore/ShellFrameworks.swift
@@ -0,0 +1,64 @@
+import Foundation
+
+// A game framework of the shared app is one folder with tens of thousands of shader files. A copy or a delete of it takes a minute
+// on an external disk, and a launcher that is quit in that minute must not leave half a framework where the shell library names it:
+// build_shell.sh then refused the whole shared app at "Prepare the shared app", naming a path and not the game. So a framework is
+// only ever replaced or taken away by a rename, which cannot stop halfway, and the slow delete runs afterwards in the background on
+// a hidden folder that nothing reads. The check below also keeps a framework that is incomplete anyway out of the shared app.
+
+extension ShellInstall {
+ /// The hidden folder a framework is renamed to before its files are deleted. It sits next to the framework (one volume, so the
+ /// rename is one step), starts with a dot and has no `.framework` suffix, so no listing of frameworks takes it for one.
+ package static let discardPrefix = ".discarded-"
+
+ /// Renames `path` out of the way and deletes it in the background. True when nothing is left at `path` (it was not there either).
+ /// A folder that cannot be renamed stays where it was, whole.
+ @discardableResult
+ package static func discard(_ path: String, fm: FileManager = .default, background: Bool = true) -> Bool {
+ guard fm.fileExists(atPath: path) else { return true }
+ let parent = (path as NSString).deletingLastPathComponent
+ let aside = parent + "/" + discardPrefix + UUID().uuidString
+ do { try fm.moveItem(atPath: path, toPath: aside) } catch { return !fm.fileExists(atPath: path) }
+ if background { DispatchQueue.global(qos: .utility).async { try? FileManager.default.removeItem(atPath: aside) } }
+ else { try? fm.removeItem(atPath: aside) }
+ return true
+ }
+
+ /// Deletes what an earlier `discard` renamed but could not finish deleting (the launcher was quit), in the background.
+ package static func sweepDiscarded(in folder: String, fm: FileManager = .default) {
+ let leftovers = ((try? fm.contentsOfDirectory(atPath: folder)) ?? []).filter { $0.hasPrefix(discardPrefix) }.map { folder + "/" + $0 }
+ guard !leftovers.isEmpty else { return }
+ DispatchQueue.global(qos: .utility).async { for path in leftovers { try? FileManager.default.removeItem(atPath: path) } }
+ }
+
+ /// The file a framework lacks for build_shell.sh, nil when it is complete: its readable `game.manifest.json`, then the executable
+ /// the manifest names (`DmGame<title ID>` when it names none). The script's other checks (the shader chain, a title ID twice) stay its own.
+ package static func missingFile(inFramework framework: String, titleID: String, fm: FileManager = .default) -> String? {
+ let manifest = "game.manifest.json"
+ guard let data = fm.contents(atPath: framework + "/" + manifest),
+ let json = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any] else { return manifest }
+ let executable = (json["framework_executable"] as? String).flatMap { $0.isEmpty ? nil : $0 } ?? "DmGame\(titleID)"
+ return fm.fileExists(atPath: framework + "/" + executable) ? nil : executable
+ }
+}
+
+extension ShellInstaller {
+ /// Before build_shell.sh: every framework of the library must be whole. Another game's framework that is not (a delete or a copy
+ /// that was cut off) is left out of this shared app and out of shell.json, with a note that names the game and the file. Building
+ /// that game again brings it back. Its mirror is taken away, a framework in a build folder stays (the build script owns it).
+ /// Returns the notes, or the failure when the framework of the game being built is the incomplete one.
+ func leaveOutIncomplete(_ library: inout ShellLibrary, titleID: String, name: String) -> (notes: [String], failure: String?) {
+ var notes: [String] = [], gone = Set<String>()
+ for game in library.games {
+ guard let missing = ShellInstall.missingFile(inFramework: game.framework, titleID: game.titleID) else { continue }
+ if game.titleID == titleID { return ([], fmt("shell.frameworkIncomplete", name, missing)) }
+ let note = fmt("shell.gameLeftOut", game.name.isEmpty ? game.titleID : game.name, missing)
+ log("library: " + note + " (" + game.framework + ")\n")
+ notes.append(note)
+ gone.insert(game.titleID)
+ if game.framework == ShellInstall.mirroredFramework(root: root, titleID: game.titleID) { ShellInstall.discard(game.framework) }
+ }
+ library.games.removeAll { gone.contains($0.titleID) }
+ return (notes, nil)
+ }
+}
diff --git a/frontend/Sources/NXCore/ShellInstall.swift b/frontend/Sources/NXCore/ShellInstall.swift
index 5ffc6054..bafa35c6 100644
--- a/frontend/Sources/NXCore/ShellInstall.swift
+++ b/frontend/Sources/NXCore/ShellInstall.swift
@@ -115,15 +115,20 @@ package enum ShellInstall {
/// Mirrors a framework into the shell folder as a copy. On APFS the copy is a clone: it costs no space, and a later write to
/// the build folder does not reach it. On another volume it is a real copy. It replaces the previous mirror, so a rebuilt
- /// game's mirror follows, and a failed copy leaves no half mirror behind.
+ /// game's mirror follows. The copy goes to a hidden folder first and is renamed into place when it is whole, so a failed or
+ /// interrupted copy never leaves a half mirror where shell.json points (ShellFrameworks.swift).
package static func mirrorFramework(framework: String, root: String, titleID: String? = nil) throws {
let fm = FileManager.default
let mirror = mirroredFramework(root: root, titleID: titleID ?? Self.titleID(ofFramework: framework))
- try fm.createDirectory(atPath: (mirror as NSString).deletingLastPathComponent, withIntermediateDirectories: true)
- try? fm.removeItem(atPath: mirror)
- do { try fm.copyItem(atPath: framework, toPath: mirror) }
- catch {
- try? fm.removeItem(atPath: mirror)
+ let folder = (mirror as NSString).deletingLastPathComponent
+ try fm.createDirectory(atPath: folder, withIntermediateDirectories: true)
+ let copy = folder + "/" + discardPrefix + UUID().uuidString
+ do {
+ try fm.copyItem(atPath: framework, toPath: copy)
+ guard discard(mirror) else { throw CocoaError(.fileWriteNoPermission, userInfo: [NSFilePathErrorKey: mirror]) }
+ try fm.moveItem(atPath: copy, toPath: mirror)
+ } catch {
+ try? fm.removeItem(atPath: copy)
throw error
}
}
@@ -507,7 +512,9 @@ package struct ShellInstaller {
// 7: the game data, only what the device does not have yet
var outcome = Outcome(ok: true, message: fmt("dev.installed", deviceName), appPath: app, bundleID: bundleID)
outcome.noMemoryCapability = noMemoryCapability
- return copyGameData(titleID: titleID, archive: archive, app: app, bundleID: bundleID, outcome: outcome)
+ var result = copyGameData(titleID: titleID, archive: archive, app: app, bundleID: bundleID, outcome: outcome)
+ if result.ok, !prepared.notes.isEmpty { result.message = ([result.message] + prepared.notes).joined(separator: "\n") }
+ return result
}
/// Step 7 on its own, for a Retry after a copy that failed midway: the listing, the diff and the copy, nothing else. The app
diff --git a/frontend/Sources/NXCore/StaleFrameworks.swift b/frontend/Sources/NXCore/StaleFrameworks.swift
index 7c6a156e..a2cd3eb9 100644
--- a/frontend/Sources/NXCore/StaleFrameworks.swift
+++ b/frontend/Sources/NXCore/StaleFrameworks.swift
@@ -66,15 +66,14 @@ package enum StaleFrameworks {
? String(name.dropFirst("DmGame".count).dropLast(".framework".count)) : name
}
- /// Deletes the stale frameworks' folders and nothing else. Returns the folders it could not delete.
+ /// Takes the stale frameworks' folders away and nothing else. Returns the folders it could not take away.
+ /// A framework holds tens of thousands of shader files: deleting them in place took a minute on an external disk, on the main
+ /// thread, and a launcher quit in that minute left a framework without its manifest and executable that the shell library
+ /// still named (the next build failed at "Prepare the shared app"). So each folder is first renamed out of the way, which is
+ /// one step that cannot stop halfway, and the files are deleted afterwards in the background (`ShellInstall.discard`).
@discardableResult
package static func remove(_ entries: [Entry]) -> [String] {
- var failed: [String] = []
- for path in entries.flatMap(\.paths) {
- do { try FileManager.default.removeItem(atPath: path) }
- catch { if FileManager.default.fileExists(atPath: path) { failed.append(path) } }
- }
- return failed
+ entries.flatMap(\.paths).filter { !ShellInstall.discard($0) }
}
/// The names the prompt lists, one per line.
diff --git a/frontend/Tests/NX2AppleTests/ShellExportTests.swift b/frontend/Tests/NX2AppleTests/ShellExportTests.swift
index 42919ace..8e9e5ffa 100644
--- a/frontend/Tests/NX2AppleTests/ShellExportTests.swift
+++ b/frontend/Tests/NX2AppleTests/ShellExportTests.swift
@@ -124,6 +124,7 @@ import NXModel
guard fm.isExecutableFile(atPath: "/usr/bin/python3") else { throw XCTSkip("System Python is required for the process fixture") }
let framework = path("work/shell-framework/DmGame\(titleID).framework")
try write(framework + "/game.manifest.json", "{}")
+ try write(framework + "/DmGame\(titleID)", "executable")
return Fixture(xcrun: try makeXcrun(), repo: try makeRepo(entitlements: entitlements), framework: framework, root: path("NX2Apple-shell"))
}
@@ -218,6 +219,75 @@ import NXModel
XCTAssertFalse(fm.fileExists(atPath: state + "/shell-env.txt"))
}
+ // ---- 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).
+ /// shell.json still named the half framework, and the next build of Hades failed at "Prepare the shared app" with only its path.
+ func testAnotherGamesIncompleteFrameworkIsLeftOutNamedAndNotShipped() throws {
+ let f = try makeFixture()
+ let otherID = "01007EF00011E000"
+ let half = ShellInstall.mirroredFramework(root: f.root, titleID: otherID)
+ try write(half + "/Info.plist", "plist")
+ try write(half + "/msl/b-e65a4ebd3322/0000.metallib", "shader")
+ var library = ShellLibrary()
+ library.add(.init(titleID: otherID, name: "Zelda Breath of the Wild", framework: half))
+ try library.save(root: f.root)
+ var logged = ""
+ var i = installer(f)
+ i.log = { logged += $0 }
+ i.banners = URL(fileURLWithPath: path("banners"))
+ let outcome = i.export(framework: f.framework, titleID: titleID, name: "Hades")
+ XCTAssertTrue(outcome.ok, outcome.message)
+ let env = try String(contentsOfFile: state + "/shell-env.txt", encoding: .utf8)
+ XCTAssertFalse(env.contains(otherID), "the half framework does not go into the app: " + env)
+ XCTAssertEqual(ShellLibrary.load(root: f.root).games.map(\.titleID), [titleID])
+ let note = String(format: L10n.string("shell.gameLeftOut", .en), "Zelda Breath of the Wild", "game.manifest.json")
+ XCTAssertTrue(outcome.message.hasSuffix(note), outcome.message)
+ XCTAssertTrue(logged.contains(note), logged)
+ XCTAssertFalse(fm.fileExists(atPath: half), "the half mirror is taken away")
+ }
+
+ func testTheBuiltGamesOwnIncompleteFrameworkStopsWithItsNameAndTheMissingFile() throws {
+ let f = try makeFixture()
+ try fm.removeItem(atPath: f.framework + "/DmGame\(titleID)")
+ var stages: [ShellStage] = []
+ var i = installer(f)
+ i.stage = { stages.append($0) }
+ i.lang = .de
+ let outcome = i.export(framework: f.framework, titleID: titleID, name: "Hades")
+ XCTAssertFalse(outcome.ok)
+ let why = String(format: L10n.string("shell.frameworkIncomplete", .de), "Hades", "DmGame\(titleID)")
+ XCTAssertEqual(outcome.message, String(format: L10n.string("shell.projectFailed", .de), why))
+ XCTAssertEqual(stages.last?.id, ShellInstaller.projectStageID)
+ XCTAssertEqual(stages.last?.state, .failed)
+ XCTAssertEqual(stages.last?.detail, why)
+ XCTAssertFalse(fm.fileExists(atPath: state + "/shell-env.txt"), "build_shell.sh never runs")
+ }
+
+ func testTheCheckNamesTheManifestThenTheExecutableTheManifestNames() throws {
+ let fw = path("check/DmGame\(titleID).framework")
+ try fm.createDirectory(atPath: fw, withIntermediateDirectories: true)
+ XCTAssertEqual(ShellInstall.missingFile(inFramework: fw, titleID: titleID), "game.manifest.json")
+ try write(fw + "/game.manifest.json", "not json")
+ XCTAssertEqual(ShellInstall.missingFile(inFramework: fw, titleID: titleID), "game.manifest.json")
+ try write(fw + "/game.manifest.json", #"{"framework_executable": "Other"}"#)
+ XCTAssertEqual(ShellInstall.missingFile(inFramework: fw, titleID: titleID), "Other")
+ try write(fw + "/Other", "executable")
+ XCTAssertNil(ShellInstall.missingFile(inFramework: fw, titleID: titleID))
+ try write(fw + "/game.manifest.json", "{}")
+ XCTAssertEqual(ShellInstall.missingFile(inFramework: fw, titleID: titleID), "DmGame\(titleID)")
+ }
+
+ func testTheNewTextsNameGameAndFileInEveryLanguage() {
+ for lang in Lang.all {
+ for key in ["shell.frameworkIncomplete", "shell.gameLeftOut"] {
+ let text = L10n.string(key, lang)
+ XCTAssertTrue(text.contains("%1$@") && text.contains("%2$@"), "\(key) in \(lang)")
+ XCTAssertFalse(text.contains(";") || text.contains(";") || text.contains("—"), "\(key) in \(lang)")
+ }
+ }
+ }
+
// ---- step 3: the game data to the device ----
private func makeArchive() throws -> String {
@@ -524,7 +594,7 @@ import NXModel
open('\(state)/script.txt', 'w').write(' '.join(sys.argv[1:]))
work = pathlib.Path(sys.argv[sys.argv.index('--work-dir') + 1])
fw = pathlib.Path(sys.argv[sys.argv.index('--shell-framework') + 1]) / 'DmGame\(titleID).framework'
- fw.mkdir(parents=True); (fw / 'game.manifest.json').write_text('{}')
+ fw.mkdir(parents=True); (fw / 'game.manifest.json').write_text('{}'); (fw / 'DmGame\(titleID)').write_text('executable')
(work / 'extract/v0/RomFS').mkdir(parents=True); (work / 'extract/v0/RomFS/data.bin').write_bytes(b'game')
print(json.dumps(dict(ev='stage', k=1, n=1, name='framework')), flush=True)
print(json.dumps(dict(ev='stage_end', k=1, name='framework', ok=True, summary='', elapsed=1)), flush=True)
diff --git a/frontend/Tests/NX2AppleTests/ShellInstallTests.swift b/frontend/Tests/NX2AppleTests/ShellInstallTests.swift
index 29a0a314..b7ce5d57 100644
--- a/frontend/Tests/NX2AppleTests/ShellInstallTests.swift
+++ b/frontend/Tests/NX2AppleTests/ShellInstallTests.swift
@@ -371,6 +371,7 @@ import NXModel
guard fm.isExecutableFile(atPath: "/usr/bin/python3") else { throw XCTSkip("System Python is required for the process fixture") }
let framework = path("work/shell-framework/DmGame\(titleID).framework")
try write(framework + "/game.manifest.json", "{}")
+ try write(framework + "/DmGame\(titleID)", "executable")
let archive = path("out/games", titleID)
try write(archive + "/romfs.img", "0123456789")
try write(archive + "/aoc/1.img", "abcd")
@@ -434,7 +435,8 @@ import NXModel
let f = try makeFixture()
let otherID = "0100AAAA00000000"
let other = path("work2/shell-framework/DmGame\(otherID).framework")
- try write(other + "/game.manifest.json", "other")
+ try write(other + "/game.manifest.json", #"{"name": "other"}"#)
+ try write(other + "/DmGame\(otherID)", "executable")
var library = ShellLibrary()
library.add(.init(titleID: otherID, name: "Other", framework: other)) // what an install before the mirror wrote
try library.save(root: f.root)
@@ -442,13 +444,14 @@ import NXModel
XCTAssertEqual(r.status, 0, r.output)
let saved = ShellLibrary.load(root: f.root)
XCTAssertEqual(Set(saved.games.map(\.framework)), [mirrored(f.root), mirrored(f.root, otherID)])
- XCTAssertEqual(try String(contentsOfFile: mirrored(f.root, otherID) + "/game.manifest.json"), "other")
+ XCTAssertEqual(try String(contentsOfFile: mirrored(f.root, otherID) + "/game.manifest.json"), #"{"name": "other"}"#)
}
func testGameWithoutBuildFolderPlaysFromItsMirrorAndOneWithNeitherIsDropped() throws {
let f = try makeFixture()
let keptID = "0100BBBB00000000", lostID = "0100CCCC00000000"
- try write(mirrored(f.root, keptID) + "/game.manifest.json", "kept")
+ try write(mirrored(f.root, keptID) + "/game.manifest.json", #"{"name": "kept"}"#)
+ try write(mirrored(f.root, keptID) + "/DmGame\(keptID)", "executable")
var library = ShellLibrary()
library.add(.init(titleID: keptID, name: "Kept", framework: path("gone/DmGame\(keptID).framework")))
library.add(.init(titleID: lostID, name: "Lost", framework: path("gone/DmGame\(lostID).framework")))
@@ -791,7 +794,7 @@ import NXModel
open('\(state)/script.txt', 'w').write(' '.join(sys.argv[1:]))
work = pathlib.Path(sys.argv[sys.argv.index('--work-dir') + 1])
fw = pathlib.Path(sys.argv[sys.argv.index('--shell-framework') + 1]) / 'DmGame\(titleID).framework'
- fw.mkdir(parents=True); (fw / 'game.manifest.json').write_text('{}')
+ fw.mkdir(parents=True); (fw / 'game.manifest.json').write_text('{}'); (fw / 'DmGame\(titleID)').write_text('executable')
(work / 'extract/v0/RomFS').mkdir(parents=True); (work / 'extract/v0/RomFS/data.bin').write_bytes(b'game')
print(json.dumps(dict(ev='stage', k=1, n=1, name='framework')), flush=True)
print(json.dumps(dict(ev='stage_end', k=1, name='framework', ok=True, summary='', elapsed=1)), flush=True)
diff --git a/frontend/Tests/NX2AppleTests/StaleFrameworksTests.swift b/frontend/Tests/NX2AppleTests/StaleFrameworksTests.swift
index 36d9f086..2227ad8b 100644
--- a/frontend/Tests/NX2AppleTests/StaleFrameworksTests.swift
+++ b/frontend/Tests/NX2AppleTests/StaleFrameworksTests.swift
@@ -100,6 +100,33 @@ import NXModel
XCTAssertEqual(found(), [], "the shared app now holds only games of the current chain")
}
+ /// v1.0.2-rc1: deleting a framework's shader files in place took a minute, and a launcher quit in that minute left half of it
+ /// where shell.json pointed. Now the folder is renamed away in one step and its files go in the background.
+ func testContinueTakesTheFrameworkAwayInOneStepAndLeavesNoHalfFramework() throws {
+ let (stale, fresh) = try shell()
+ for i in 0..<300 { try "shader".write(toFile: stale + "/msl-\(i).metallib", atomically: false, encoding: .utf8) }
+ XCTAssertEqual(BuildStore.removeStaleFrameworks(found(), root: tmp + "/shell"), [])
+ XCTAssertFalse(exists(stale))
+ XCTAssertTrue(exists(fresh))
+ let left = try FileManager.default.contentsOfDirectory(atPath: tmp + "/shell/frameworks")
+ XCTAssertTrue(left.allSatisfy { $0 == "DmGame\(newID).framework" || $0.hasPrefix(ShellInstall.discardPrefix) }, "\(left)")
+ XCTAssertFalse(left.contains { $0.hasPrefix(ShellInstall.discardPrefix) && $0.hasSuffix(".framework") })
+ XCTAssertEqual(found(), [])
+ }
+
+ func testWhatACutOffDeleteLeftIsSweptAndNeverTakenForAFramework() throws {
+ _ = try framework(newID, name: "Fresh Game", chain: current)
+ let leftover = tmp + "/shell/frameworks/" + ShellInstall.discardPrefix + "cut-off"
+ try FileManager.default.createDirectory(atPath: leftover + "/msl", withIntermediateDirectories: true)
+ try JSONSerialization.data(withJSONObject: ["title_id": oldID, "chain": old]).write(to: URL(fileURLWithPath: leftover + "/game.manifest.json"))
+ XCTAssertEqual(found(), [])
+ ShellInstall.sweepDiscarded(in: tmp + "/shell/frameworks")
+ let deadline = Date().addingTimeInterval(10)
+ while exists(leftover), Date() < deadline { RunLoop.current.run(until: Date().addingTimeInterval(0.05)) }
+ XCTAssertFalse(exists(leftover))
+ XCTAssertTrue(exists(tmp + "/shell/frameworks/DmGame\(newID).framework"))
+ }
+
func testContinueStartsTheBuildAndTheModelEndsWithoutAPrompt() throws {
_ = try shell()
let modelStores = LauncherStores(); let model = modelStores.build
diff --git a/frontend/l10n/de.json b/frontend/l10n/de.json
index f14be72e..2d9a1e30 100644
--- a/frontend/l10n/de.json
+++ b/frontend/l10n/de.json
@@ -974,6 +974,8 @@
"shell.exportDone": "Die IPA-Datei ist fertig: %@",
"shell.exportFailed": "Die IPA-Datei konnte nicht erstellt werden: %@",
"shell.exportPackStage": "IPA-Datei packen",
+ "shell.frameworkIncomplete": "Die Dateien von %1$@ sind unvollständig, %2$@ fehlt. Baue das Spiel erneut.",
+ "shell.gameLeftOut": "%1$@ ist nicht in der gemeinsamen App, weil seine Dateien unvollständig sind (%2$@ fehlt). Baue dieses Spiel erneut, um es wieder hinzuzufügen.",
"shell.modeExport": "Als IPA exportieren",
"shell.modeInstall": "Auf Gerät installieren",
"shell.modeTitle": "Installieren oder exportieren",
diff --git a/frontend/l10n/en.json b/frontend/l10n/en.json
index 5eb19a39..84294c5d 100644
--- a/frontend/l10n/en.json
+++ b/frontend/l10n/en.json
@@ -1098,6 +1098,8 @@
"shell.exportDone": "The IPA is ready: %@",
"shell.exportFailed": "The IPA could not be made: %@",
"shell.exportPackStage": "Pack the IPA",
+ "shell.frameworkIncomplete": "The files of %1$@ are incomplete, %2$@ is missing. Build the game again.",
+ "shell.gameLeftOut": "%1$@ was left out of the shared app because its files are incomplete (%2$@ is missing). Build that game again to add it back.",
"shell.modeExport": "Export as IPA",
"shell.modeInstall": "Install on device",
"shell.modeTitle": "Install or export",
diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.json
index 0cdfb40e..4ae18465 100644
--- a/frontend/l10n/fr.json
+++ b/frontend/l10n/fr.json
@@ -973,6 +973,8 @@
"shell.exportDone": "L’IPA est prêt : %@",
"shell.exportFailed": "L’IPA n’a pas pu être créé : %@",
"shell.exportPackStage": "Empaqueter l’IPA",
+ "shell.frameworkIncomplete": "Les fichiers de %1$@ sont incomplets, %2$@ manque. Reconstruisez le jeu.",
+ "shell.gameLeftOut": "%1$@ a été laissé hors de l’app partagée car ses fichiers sont incomplets (%2$@ manque). Reconstruisez ce jeu pour le rajouter.",
"shell.modeExport": "Exporter en IPA",
"shell.modeInstall": "Installer sur l’appareil",
"shell.modeTitle": "Installer ou exporter",
diff --git a/frontend/l10n/it.json b/frontend/l10n/it.json
index 843d252d..611c32c7 100644
--- a/frontend/l10n/it.json
+++ b/frontend/l10n/it.json
@@ -973,6 +973,8 @@
"shell.exportDone": "L’IPA è pronta: %@",
"shell.exportFailed": "Impossibile creare l’IPA: %@",
"shell.exportPackStage": "Crea il pacchetto IPA",
+ "shell.frameworkIncomplete": "I file di %1$@ sono incompleti, manca %2$@. Compila di nuovo il gioco.",
+ "shell.gameLeftOut": "%1$@ è stato escluso dall’app condivisa perché i suoi file sono incompleti (manca %2$@). Compila di nuovo quel gioco per aggiungerlo.",
"shell.modeExport": "Esporta come IPA",
"shell.modeInstall": "Installa sul dispositivo",
"shell.modeTitle": "Installa o esporta",
diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.json
index bbc615a2..8d1b6ce6 100644
--- a/frontend/l10n/sv.json
+++ b/frontend/l10n/sv.json
@@ -810,6 +810,8 @@
"shell.exportDone": "IPA-filen är klar: %@",
"shell.exportFailed": "IPA-filen kunde inte skapas: %@",
"shell.exportPackStage": "Paketera IPA-filen",
+ "shell.frameworkIncomplete": "Filerna för %1$@ är ofullständiga, %2$@ saknas. Bygg spelet igen.",
+ "shell.gameLeftOut": "%1$@ togs inte med i den gemensamma appen eftersom dess filer är ofullständiga (%2$@ saknas). Bygg spelet igen för att lägga till det.",
"shell.modeExport": "Exportera som IPA",
"shell.modeInstall": "Installera på enheten",
"shell.modeTitle": "Installera eller exportera",
diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.json
index e2f6c1d4..abaf234c 100644
--- a/frontend/l10n/zh.json
+++ b/frontend/l10n/zh.json
@@ -1099,6 +1099,8 @@
"shell.exportDone": "IPA 已就绪:%@",
"shell.exportFailed": "无法生成 IPA:%@",
"shell.exportPackStage": "打包 IPA",
+ "shell.frameworkIncomplete": "%1$@ 的文件不完整,缺少 %2$@。请重新构建这个游戏。",
+ "shell.gameLeftOut": "%1$@ 的文件不完整(缺少 %2$@),已从共用应用中移除。重新构建这个游戏即可将它加回来。",
"shell.modeExport": "导出为 IPA",
"shell.modeInstall": "安装到设备",
"shell.modeTitle": "安装或导出",