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: say which games were built with older tools, and offer a rebuild (#65)
v0lumehi5bba748ba3b8
diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swiftindex 3fcd6c63..fb3db34d 100644--- a/frontend/Sources/NSPortBuilder/LauncherView.swift+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift@@ -39,12 +39,15 @@ struct ContentView: View {@StateObject private var gamepad = LauncherGamepad()@StateObject private var padFocus = PadFocus()@StateObject private var row = RowScroller()+ @StateObject private var toolsAge: ToolsAge+ @State private var buildCommit = "" // the checkout's commit when the running build started (ToolsAge)private var performStartupChecks: Bool@Environment(\.scenePhase) private var scenePhaseinit(model: BuildModel? = nil, library: GameLibrary? = nil, initialPage: LauncherPage = .library,- activeBuildID: UUID? = nil, performStartupChecks: Bool = true, search: String? = nil) {+ activeBuildID: UUID? = nil, performStartupChecks: Bool = true, search: String? = nil, olderTools: Set<UUID> = []) {if let search { _search = State(initialValue: search); _searching = State(initialValue: true) } // visual QA: the bar with its field open+ _toolsAge = StateObject(wrappedValue: ToolsAge(older: olderTools)) // visual QA: games marked without a checkout to compare_m = StateObject(wrappedValue: model ?? BuildModel())_library = StateObject(wrappedValue: library ?? GameLibrary())_page = State(initialValue: initialPage)@@ -82,7 +85,7 @@ struct ContentView: View {.onAppear {gamepad.perform = padActionrefreshArtwork()- if performStartupChecks { library.discover(); fetchArtwork(); m.refreshDevices() }+ if performStartupChecks { library.discover(); fetchArtwork(); m.refreshDevices(); checkTools() }if performStartupChecks {m.checkDeps()if m.repoOK && m.repoIsGit { m.checkRepoUpdates(silent: true) }@@ -93,9 +96,19 @@ struct ContentView: View {refreshArtwork()if performStartupChecks { fetchArtwork() }}- .onChange(of: m.repoPath) { _ in refreshArtwork() }+ .onChange(of: m.repoPath) { _ in refreshArtwork(); if performStartupChecks { checkTools() } }+ // A clone, pull or update check has finished (the automatic pull at launch among them): the checkout may have moved+ .onReceive(m.$repoBusy.removeDuplicates().dropFirst()) { busy in if !busy && performStartupChecks { checkTools() } }.onReceive(m.$running.removeDuplicates()) { running inif running && activeBuildID == nil { activeBuildID = library.rememberInputs(m) }+ if running && activeBuildID != nil { // the tools this build runs: a pull waits for the build (pullRepo, autoPull)+ buildCommit = ""+ let repo = m.repoPath+ DispatchQueue.global(qos: .utility).async {+ let commit = ToolsAge.head(repo: repo) ?? ""+ DispatchQueue.main.async { buildCommit = commit }+ }+ }if !running {DispatchQueue.main.async {if m.done { recordBuild() }@@ -283,7 +296,21 @@ struct ContentView: View {startPoint: .top, endPoint: .bottom)LinearGradient(colors: [.black.opacity(0.24), .clear], startPoint: .leading, endPoint: .trailing)VStack(alignment: .leading, spacing: 14) {- status(game, prominent: true)+ HStack(spacing: 14) {+ status(game, prominent: true)+ if toolsAge.older.contains(game.id) && !(m.running && activeBuildID == game.id) {+ Button { configureBuild(game) } label: {+ Label(m.t("library.rebuildShort"), systemImage: "arrow.clockwise")+ .font(.manrope(12, .semibold)).foregroundStyle(LauncherPalette.cream)+ .padding(.horizontal, 10).padding(.vertical, 4)+ .overlay(Capsule().strokeBorder(LauncherPalette.cream.opacity(0.35)))+ .contentShape(Capsule())+ }+ .buttonStyle(.plain).disabled(m.running || game.inputs["base", default: []].isEmpty)+ .help(m.t("library.olderToolsHelp"))+ .padTarget("hero.rebuild", scope: "main", radius: 12) { if !m.running { configureBuild(game) } }+ }+ }Text(game.name).font(.manrope(min(68, width * 0.052), .heavy)).tracking(-1.6).lineLimit(2).shadow(color: .black.opacity(0.25), radius: 12)HStack(spacing: 18) {@@ -311,7 +338,7 @@ struct ContentView: View {.padTarget("hero.options", scope: "main", radius: 24) { optionsFor = game.id }}Menu {- Button(m.t("library.buildAgain")) { configureBuild(game) }.disabled(m.running || game.inputs["base", default: []].isEmpty)+ Button(m.t(toolsAge.older.contains(game.id) ? "library.rebuild" : "library.buildAgain")) { configureBuild(game) }.disabled(m.running || game.inputs["base", default: []].isEmpty)if game.isReady { Button(m.t("launch.title")) { optionsFor = game.id } }Button(m.t("library.changeArtwork")) { chooseArtwork(game) }if !game.artworkPath.isEmpty {@@ -433,6 +460,11 @@ struct ContentView: View {.font(prominent ? .manrope(12, .bold) : .manrope(13, .medium)).tracking(prominent ? 1.3 : 0) // the eyebrow: the same face, in tracked capitals.foregroundStyle(color)+ if !building && toolsAge.older.contains(game.id) { // a quiet note beside the status, not a warning+ Text("· " + m.t(prominent ? "library.olderTools" : "library.olderToolsShort"))+ .font(.manrope(prominent ? 13 : 12)).foregroundStyle(.secondary).lineLimit(1)+ .help(m.t("library.olderToolsHelp"))+ }}.accessibilityElement(children: .combine)}@@ -598,11 +630,14 @@ struct ContentView: View {private func recordBuild() {guard m.done, let id = activeBuildID else { return }- if m.target == "mac-app" { library.recordCompletedApp(path: m.macAppPath, for: id) }- else { library.recordCompletedIOS(ipa: m.ipaPath, archive: m.archivePath, app: m.installedAppPath, device: m.installedOn, for: id) }+ 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) }refreshArtwork()+ if performStartupChecks { checkTools() }}+ private func checkTools() { toolsAge.check(games: library.games, repo: m.repoPath) }+private func refreshArtwork() {artwork = Dictionary(uniqueKeysWithValues: library.games.compactMap { game inGameLibrary.artwork(for: game, repo: m.repoPath).map { (game.id, $0) }diff --git a/frontend/Sources/NSPortBuilder/Library.swift b/frontend/Sources/NSPortBuilder/Library.swiftindex 2b546105..11fc1b54 100644--- a/frontend/Sources/NSPortBuilder/Library.swift+++ b/frontend/Sources/NSPortBuilder/Library.swift@@ -17,6 +17,8 @@ struct LibraryGame: Codable, Identifiable, Equatable {var mods: [String] = [] // the mods (folder names in the game's mods folder) switched onvar iosAppPath = ""var installedDevice = ""+ /// The repository checkout's commit the last finished build used (ToolsAge); empty for a build from before it was recorded.+ var toolsCommit = ""var isReady: Bool {guard let app = try? MacGameBundle.read(URL(fileURLWithPath: appPath)) else { return false }@@ -49,6 +51,7 @@ extension LibraryGame {mods = try c.decodeIfPresent([String].self, forKey: .mods) ?? []iosAppPath = try c.decodeIfPresent(String.self, forKey: .iosAppPath) ?? ""installedDevice = try c.decodeIfPresent(String.self, forKey: .installedDevice) ?? ""+ toolsCommit = try c.decodeIfPresent(String.self, forKey: .toolsCommit) ?? ""}}@@ -367,23 +370,25 @@ final class GameLibrary: ObservableObject {return game.id}- func recordCompletedApp(path: String, for id: UUID) {+ func recordCompletedApp(path: String, commit: String = "", for id: UUID) {guard var game = games.first(where: { $0.id == id }),let app = try? MacGameBundle.read(URL(fileURLWithPath: path)),app.titleID == game.titleID || game.titleID.hasPrefix("/") else { return }game.titleID = app.titleIDgame.appPath = pathgame.name = app.name+ game.toolsCommit = commit // empty for a checkout without git: nothing to compare, rather than an older build's commitupsert(game)}- func recordCompletedIOS(ipa: String, archive: String, app: String = "", device: String = "", for id: UUID) {+ func recordCompletedIOS(ipa: String, 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 noneif !ipa.isEmpty { game.ipaPath = ipa }if !archive.isEmpty { game.archivePath = archive }if !app.isEmpty { game.iosAppPath = app; game.installedDevice = device }+ game.toolsCommit = commitupsert(game)}diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex f4323d17..26e5667a 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -118,6 +118,11 @@ enum L10n {"library.building": ("\u{6b63}\u{5728}\u{6784}\u{5efa}", "Building"),"library.notBuilt": ("\u{5c1a}\u{672a}\u{6784}\u{5efa}", "Not built yet"),"library.play": ("\u{5f00}\u{59cb}\u{6e38}\u{620f}", "Play"),+ "library.olderTools": ("用旧版构建工具构建", "Built with older tools"),+ "library.olderToolsShort": ("工具较旧", "Older tools"),+ "library.olderToolsHelp": ("这个游戏构建之后,构建工具有了会影响它的更改。重新构建即可用上这些更改。", "The build tools changed in ways that affect this game since it was built. Rebuild it to get the changes."),+ "library.rebuild": ("用当前工具重新构建…", "Rebuild with current tools…"),+ "library.rebuildShort": ("重新构建", "Rebuild"),"library.buildForMac": ("\u{4e3a} Mac \u{6784}\u{5efa}", "Build for Mac"),"library.newBuild": ("\u{6784}\u{5efa}\u{6e38}\u{620f}", "Build game"),"library.firstBuild": ("\u{6784}\u{5efa}\u{7b2c}\u{4e00}\u{4e2a}\u{6e38}\u{620f}", "Build your first game"),diff --git a/frontend/Sources/NSPortBuilder/OlderTools.swift b/frontend/Sources/NSPortBuilder/OlderTools.swiftnew file mode 100644index 00000000..16a432fb--- /dev/null+++ b/frontend/Sources/NSPortBuilder/OlderTools.swift@@ -0,0 +1,72 @@+import Foundation++/// Which library games were built with older build tools (LNPANDY/NX2Apple#65, after seedds/nxnative#209): a finished build+/// records the checkout's commit (LibraryGame.toolsCommit); once the checkout has moved on, a game is marked when files a+/// build uses changed between that commit and HEAD. Only a change that can alter the built game counts, so a docs-only+/// pull marks nothing. A game built before the commit was recorded, or in a checkout that is not a git one, is never marked.+final class ToolsAge: ObservableObject {+ /// The games whose build is older than the tools in the checkout now.+ @Published private(set) var older: Set<UUID> = []+ private var generation = 0++ init(older: Set<UUID> = []) { self.older = older }++ /// Runs git off the main thread; a check started later wins over one still running (the repository may move in between).+ func check(games: [LibraryGame], repo: String) {+ generation += 1+ let mine = generation+ let builds = games.map { (id: $0.id, titleID: $0.titleID, commit: $0.toolsCommit) }+ DispatchQueue.global(qos: .utility).async {+ let result = Self.olderGames(builds, repo: repo)+ DispatchQueue.main.async {+ guard mine == self.generation, result != self.older else { return }+ self.older = result+ }+ }+ }++ /// The repository's folders and files a build reads (scripts/build_ipa_from_nsp.py's `repo / …` paths): the host, the+ /// graphics layers and their shader chain, the rewriter and extraction tools, the iOS and Mac app shells, the vendored+ /// libraries, the build script itself, and the profile code (game.py, profile_guess.py, the launch settings).+ nonisolated static let buildInputs = ["dm/host/", "dm/gfx/", "dm/tools/", "dm/ios/", "dm/mac/", "dm/third_party/",+ "scripts/build_ipa_from_nsp.py", "dm/games/game.py", "dm/games/profile_guess.py",+ "dm/games/settings."]++ /// Whether a changed file (a path relative to the repository) can change what a build of this game makes: a build input,+ /// or a file of the game's own profile (dm/games/<title ID>/). Notes (*.md) and tests are read by no build.+ nonisolated static func affects(_ path: String, titleID: String) -> Bool {+ if path.hasSuffix(".md") || path.contains("/tests/") { return false }+ if path.hasPrefix("dm/games/" + titleID + "/") { return true }+ return buildInputs.contains { path.hasPrefix($0) }+ }++ /// The checkout's commit, for a git checkout only (a ZIP copy has no history to compare against).+ nonisolated static func head(repo: String) -> String? {+ guard !repo.isEmpty, FileManager.default.fileExists(atPath: repo + "/.git"), let git = BuildModel.gitBinary() else { return nil }+ let r = BuildModel.runQuiet([git, "-C", repo, "rev-parse", "HEAD"], env: BuildModel.gitEnv())+ let commit = r.out.trimmingCharacters(in: .whitespacesAndNewlines)+ return r.ok && !commit.isEmpty ? commit : nil+ }++ /// The files changed between a recorded commit and HEAD; nil when git cannot tell (a commit the checkout does not have,+ /// as after a fresh shallow clone), which marks nothing rather than everything.+ nonisolated static func changedFiles(since commit: String, repo: String) -> [String]? {+ guard let git = BuildModel.gitBinary() else { return nil }+ let r = BuildModel.runQuiet([git, "-C", repo, "diff", "--name-only", "--no-renames", commit, "HEAD", "--"], env: BuildModel.gitEnv())+ guard r.ok else { return nil }+ return r.out.split(separator: "\n").map(String.init).filter { !$0.isEmpty }+ }++ /// The games marked: one `git diff` per distinct recorded commit, then each game's files are filtered by its title ID.+ nonisolated static func olderGames(_ builds: [(id: UUID, titleID: String, commit: String)], repo: String) -> Set<UUID> {+ let recorded = builds.filter { !$0.commit.isEmpty }+ guard !recorded.isEmpty, let head = head(repo: repo) else { return [] }+ var diffs: [String: [String]] = [:]+ var marked: Set<UUID> = []+ for build in recorded where build.commit != head {+ if diffs[build.commit] == nil { diffs[build.commit] = changedFiles(since: build.commit, repo: repo) ?? [] }+ if diffs[build.commit]!.contains(where: { affects($0, titleID: build.titleID) }) { marked.insert(build.id) }+ }+ return marked+ }+}diff --git a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift b/frontend/Tests/NSPortBuilderTests/LibraryTests.swiftindex 7d2b3eca..02fb72e5 100644--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift@@ -637,9 +637,10 @@ final class LibraryTests: XCTestCase {model.slots[0].paths = []library.selectedID = library.games.first?.idfunc capture(_ name: String, width: CGFloat = 1440, height: CGFloat = 1024, page: LauncherPage = .library, activeID: UUID? = nil, empty: Bool = false,- search: String? = nil) throws {+ search: String? = nil, older: Set<UUID> = []) throws {let store = empty ? GameLibrary(file: temporary.appendingPathComponent("empty.json")) : library- let view = ContentView(model: model, library: store, initialPage: page, activeBuildID: activeID, performStartupChecks: false, search: search)+ let view = ContentView(model: model, library: store, initialPage: page, activeBuildID: activeID, performStartupChecks: false, search: search,+ olderTools: older)let host = NSHostingView(rootView: view)let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: width, height: height),styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false)@@ -674,6 +675,12 @@ final class LibraryTests: XCTestCase {try capture("settings-update-ready", page: .settings)try capture("library-update-ready")}+ // Games built with older build tools (ToolsAge): the selected one rebuilt from its own inputs, as a recorded build has them+ model.slots[0].paths = ["/preview/Hades [\(titleID)].nsp"]+ _ = library.rememberInputs(model)+ model.slots[0].paths = []+ try capture("library-older-tools", older: [library.games[0].id, library.games[1].id])+ try capture("library-older-tools-small", width: 900, height: 680, older: [library.games[0].id, library.games[1].id])// An iPhone build with a paired device and a team (example values)let previousTarget = model.targetmodel.target = "ios"diff --git a/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swift b/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swiftnew file mode 100644index 00000000..ddf68ad0--- /dev/null+++ b/frontend/Tests/NSPortBuilderTests/OlderToolsTests.swift@@ -0,0 +1,130 @@+import XCTest+@testable import NSPortBuilder++/// Games built with older build tools (ToolsAge, #65): a local git repository stands in for the checkout; a game is marked+/// only when files a build uses changed since the commit its build recorded.+final class OlderToolsTests: XCTestCase {+ private var temporary: URL!+ private let titleID = "0100535012974000"++ override func setUpWithError() throws {+ guard FileManager.default.isExecutableFile(atPath: "/usr/bin/git") else { throw XCTSkip("git is required for the fixture") }+ temporary = FileManager.default.temporaryDirectory.appendingPathComponent("nxnative-tools-" + UUID().uuidString)+ try FileManager.default.createDirectory(at: temporary, withIntermediateDirectories: true)+ }++ override func tearDownWithError() throws {+ try? FileManager.default.removeItem(at: temporary)+ }++ @discardableResult private func git(_ args: String..., in dir: URL) throws -> String {+ let r = BuildModel.runQuiet(["/usr/bin/git", "-C", dir.path] + args, env: BuildModel.gitEnv())+ guard r.ok else { throw NSError(domain: "git", code: 1, userInfo: [NSLocalizedDescriptionKey: "git \(args.joined(separator: " ")): \(r.out)"]) }+ return r.out.trimmingCharacters(in: .whitespacesAndNewlines)+ }++ @discardableResult private func commit(_ files: [String: String], in repo: URL) throws -> String {+ for (path, text) in files {+ let url = repo.appendingPathComponent(path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try text.write(to: url, atomically: true, encoding: .utf8)+ }+ try git("add", ".", in: repo)+ try git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-m", "change", in: repo)+ return try git("rev-parse", "HEAD", in: repo)+ }++ /// A checkout with the folders a build reads and a note; returns it and its first commit (the one the game was built with).+ private func fixture() throws -> (repo: URL, built: String) {+ let repo = temporary.appendingPathComponent("checkout")+ try FileManager.default.createDirectory(at: repo, withIntermediateDirectories: true)+ try git("init", "-b", "main", in: repo)+ let built = try commit(["dm/tools/nx_extract/Program.cs": "one", "dm/host/hle_fs.c": "one", "docs/development.md": "one",+ "dm/games/\(titleID)/game.tsv": "name\tHades", "dm/games/01007EF00011E000/game.tsv": "name\tZelda"], in: repo)+ return (repo, built)+ }++ private func game(_ commit: String) -> (id: UUID, titleID: String, commit: String) { (UUID(), titleID, commit) }++ func testAChangeToTheHostMarksTheGame() throws {+ let (repo, built) = try fixture()+ try commit(["dm/host/hle_fs.c": "two"], in: repo)+ let hades = game(built)+ XCTAssertEqual(ToolsAge.olderGames([hades], repo: repo.path), [hades.id])+ }++ func testAChangeOnlyInTheDocsMarksNothing() throws {+ let (repo, built) = try fixture()+ try commit(["docs/development.md": "two", "dm/host/README.md": "notes"], in: repo)+ XCTAssertEqual(ToolsAge.olderGames([game(built)], repo: repo.path), [])+ }++ func testAGameWithNoRecordedCommitIsNotMarked() throws {+ let (repo, _) = try fixture()+ try commit(["dm/host/hle_fs.c": "two"], in: repo)+ XCTAssertEqual(ToolsAge.olderGames([game("")], repo: repo.path), [])+ }++ func testOnlyTheGamesOwnProfileCounts() throws {+ let (repo, built) = try fixture()+ try commit(["dm/games/01007EF00011E000/game.tsv": "name\tZelda 2"], in: repo)+ XCTAssertEqual(ToolsAge.olderGames([game(built)], repo: repo.path), [], "another game's profile")+ try commit(["dm/games/\(titleID)/game.tsv": "name\tHades 2"], in: repo)+ let hades = game(built)+ XCTAssertEqual(ToolsAge.olderGames([hades], repo: repo.path), [hades.id])+ }++ func testABuildAtHeadOrFromAnUnknownCommitIsNotMarked() throws {+ let (repo, _) = try fixture()+ let head = try commit(["dm/host/hle_fs.c": "two"], in: repo)+ XCTAssertEqual(ToolsAge.olderGames([game(head)], repo: repo.path), [])+ XCTAssertEqual(ToolsAge.olderGames([game(String(repeating: "0", count: 40))], repo: repo.path), [], "a commit the checkout does not have")+ }++ func testAFolderThatIsNotAGitCheckoutMarksNothing() throws {+ let zip = temporary.appendingPathComponent("zip")+ try FileManager.default.createDirectory(at: zip.appendingPathComponent("dm/host"), withIntermediateDirectories: true)+ XCTAssertNil(ToolsAge.head(repo: zip.path))+ XCTAssertEqual(ToolsAge.olderGames([game("abc")], repo: zip.path), [])+ }++ func testWhatABuildReads() {+ for path in ["dm/host/hle_fs.c", "dm/gfx/nvn/dmsh_chain.h", "dm/tools/patch_nso.py", "dm/ios/tools/build_ipa.sh", "dm/mac/pack_app.py",+ "scripts/build_ipa_from_nsp.py", "dm/games/game.py", "dm/games/settings.tsv", "dm/games/\(titleID)/shader_map.tsv"] {+ XCTAssertTrue(ToolsAge.affects(path, titleID: titleID), path)+ }+ for path in ["README.md", "docs/agents/04-graphics.md", "dm/games/\(titleID)/README.md", "dm/tools/tests/test_docs.py",+ "dm/games/01007EF00011E000/game.tsv", "frontend/Sources/NSPortBuilder/LauncherView.swift", "scripts/regress.py"] {+ XCTAssertFalse(ToolsAge.affects(path, titleID: titleID), path)+ }+ }++ /// The check runs off the main thread and publishes the marked games.+ func testTheCheckPublishesTheMarkedGames() throws {+ let (repo, built) = try fixture()+ try commit(["dm/gfx/nvn/nvn.c": "new"], in: repo)+ let marked = LibraryGame(titleID: titleID, name: "Hades", toolsCommit: built)+ let unmarked = LibraryGame(titleID: titleID, name: "Old build")+ let age = ToolsAge()+ age.check(games: [marked, unmarked], repo: repo.path)+ let done = XCTNSPredicateExpectation(predicate: NSPredicate { _, _ in !age.older.isEmpty }, object: nil)+ wait(for: [done], timeout: 10)+ XCTAssertEqual(age.older, [marked.id])+ }++ /// A library file from before the commit was recorded still loads; a finished build records its commit.+ func testTheCommitIsRecordedAndOldLibrariesLoad() throws {+ let file = temporary.appendingPathComponent("library.json")+ let id = UUID()+ try #"{"games":[{"id":"\#(id.uuidString)","titleID":"\#(titleID)","name":"Hades"}],"folder":""}"#.write(to: file, atomically: true, encoding: .utf8)+ 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)+ 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+ XCTAssertEqual(GameLibrary(file: file).games.first?.toolsCommit, "")+ }+}