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
Merge branch 'fix-device-store' into s3-build-store
v0lumehia0245af1ac68
diff --cc frontend/Tests/NX2AppleTests/BuildNotificationsTests.swiftindex f86f59cd,847c3508..2100aa61--- a/frontend/Tests/NX2AppleTests/BuildNotificationsTests.swift+++ b/frontend/Tests/NX2AppleTests/BuildNotificationsTests.swift@@@ -58,13 -57,13 +58,13 @@@ import NXModelet temporary = FileManager.default.temporaryDirectory.appendingPathComponent("nxnative-notify-" + UUID().uuidString)try FileManager.default.createDirectory(at: temporary, withIntermediateDirectories: true)defer { try? FileManager.default.removeItem(at: temporary) }- let model = BuildModel()+ let modelStores = LauncherStores(); let model = modelStores.buildmodel.lang = CaptureLanguage.current(.en)- MainActor.assumeIsolated { model.dependencies.checked = true }- MainActor.assumeIsolated { model.dependencies.deps = [Dep(id: "test", name: "Xcode", hint: "", present: true, installCmd: [])] }+ MainActor.assumeIsolated { modelStores.dependencies.checked = true }+ MainActor.assumeIsolated { modelStores.dependencies.deps = [Dep(id: "test", name: "Xcode", hint: "", present: true, installCmd: [])] }let library = GameLibrary(file: temporary.appendingPathComponent("preview.json"))- let host = NSHostingView(rootView: ContentView(model: model, library: library, initialPage: .settings, performStartupChecks: false))+ let host = NSHostingView(rootView: ContentView(stores: modelStores, library: library, initialPage: .settings, performStartupChecks: false))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1440, height: 1500), styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 1440, height: 1500), styleMask: [.titled, .closable, .resizable])window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.5))diff --cc frontend/Tests/NX2AppleTests/ConsoleTests.swiftindex 4491cc77,260b35a6..13381b4b--- a/frontend/Tests/NX2AppleTests/ConsoleTests.swift+++ b/frontend/Tests/NX2AppleTests/ConsoleTests.swift@@@ -212,10 -211,9 +212,9 @@@ import NXModelet library = GameLibrary(file: output.appendingPathComponent("unused-library.json"))let driver = MockConsoleDriver(scenario: .controllersMixed, lang: lang, animated: false)driver.back()- let view = ContentView(model: model, library: library, performStartupChecks: false, controllerDriver: AnyConsoleDriver(driver))+ let view = ContentView(stores: modelStores, library: library, performStartupChecks: false, controllerDriver: AnyConsoleDriver(driver))let host = NSHostingView(rootView: view)- let window = NSWindow(contentRect: NSRect(x: -10000, y: 0, width: width, height: 800), styleMask: [.borderless], backing: .buffered, defer: false)- window.isReleasedWhenClosed = false+ let window = OffscreenWindow(size: NSSize(width: width, height: 800), styleMask: [.borderless])window.contentView = hostwindow.orderBack(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.2))diff --cc frontend/Tests/NX2AppleTests/FrameTimesTests.swiftindex 2a3d9a35,b05d4d43..fc4ebf29--- a/frontend/Tests/NX2AppleTests/FrameTimesTests.swift+++ b/frontend/Tests/NX2AppleTests/FrameTimesTests.swift@@@ -177,10 -176,10 +177,10 @@@ import NXModelet saved = UserDefaults.standard.object(forKey: key)defer { UserDefaults.standard.set(saved, forKey: key) }FrameTimes.setEnabled(true, titleID: titleID)- let model = BuildModel()+ let modelStores = LauncherStores(); let model = modelStores.buildmodel.lang = .en- let host = NSHostingView(rootView: LaunchOptionsView(m: model, library: library, gameID: library.games[0].id).environmentObject(PadFocus()).environmentObject(model.localizer))+ let host = NSHostingView(rootView: LaunchOptionsView(m: model, library: library, gameID: library.games[0].id).environmentObject(PadFocus()).environmentObject(modelStores.localizer))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 900, height: 1300), styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 900, height: 1300), styleMask: [.titled, .closable, .resizable])window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(1.0))diff --cc frontend/Tests/NX2AppleTests/KeyCheckTests.swiftindex bbb4d4f0,c820183d..243d9e28--- a/frontend/Tests/NX2AppleTests/KeyCheckTests.swift+++ b/frontend/Tests/NX2AppleTests/KeyCheckTests.swift@@@ -183,8 -182,8 +183,8 @@@ import NXModemodel.slots[0].paths = [base]model.slots[1].paths = withUpdate ? [update] : []model.slots[3].paths = [try keysFile(keys)]- let host = NSHostingView(rootView: ContentView(model: model, library: library, initialPage: .builds, performStartupChecks: false))+ let host = NSHostingView(rootView: ContentView(stores: modelStores, library: library, initialPage: .builds, performStartupChecks: false))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1440, height: 1024), styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 1440, height: 1024), styleMask: [.titled, .closable, .resizable])window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.8))diff --cc frontend/Tests/NX2AppleTests/LauncherPerformanceTests.swiftindex 854ced6a,ff67d4f7..3c7a053f--- a/frontend/Tests/NX2AppleTests/LauncherPerformanceTests.swift+++ b/frontend/Tests/NX2AppleTests/LauncherPerformanceTests.swift@@@ -140,10 -139,8 +140,8 @@@ import NXModelet library = GameLibrary(file: world.libraryFile)library.selectedID = world.selectedlet pad = LauncherGamepad()- let host = NSHostingView(rootView: ContentView(model: model, library: library, performStartupChecks: false, gamepad: pad))+ let host = NSHostingView(rootView: ContentView(stores: modelStores, library: library, performStartupChecks: false, gamepad: pad))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1280, height: 900), styleMask: [.titled, .closable, .resizable],- backing: .buffered, defer: false)- window.isReleasedWhenClosed = false+ let window = OffscreenWindow(size: NSSize(width: 1280, height: 900), styleMask: [.titled, .closable, .resizable])window.contentView = hostwindow.orderFront(nil)defer { window.orderOut(nil) }diff --cc frontend/Tests/NX2AppleTests/LibraryTests.swiftindex 45190827,87295df3..f4d15263--- a/frontend/Tests/NX2AppleTests/LibraryTests.swift+++ b/frontend/Tests/NX2AppleTests/LibraryTests.swift@@@ -612,8 -611,8 +612,8 @@@ import NXModemodel.slots[0].paths = [base.path]model.slots[3].paths = [keys.path]let library = GameLibrary(file: temporary.appendingPathComponent("library.json"))- let host = NSHostingView(rootView: ContentView(model: model, library: library, initialPage: .builds, performStartupChecks: false))+ let host = NSHostingView(rootView: ContentView(stores: modelStores, library: library, initialPage: .builds, performStartupChecks: false))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1100, height: 800), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 1100, height: 800))window.contentView = hostwindow.orderFront(nil)defer { window.orderOut(nil) }@@@ -788,11 -787,10 +788,10 @@@func capture(_ name: String, width: CGFloat = 1440, height: CGFloat = 1024, page: LauncherPage = .library, activeID: UUID? = nil, empty: Bool = false,search: String? = nil, older: Set<UUID> = [], manageOpen: Bool = false, padRing: Bool = false, only: GameLibrary? = nil) throws {let store = only ?? (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(stores: modelStores, library: store, initialPage: page, activeBuildID: activeID, performStartupChecks: false, search: search,olderTools: older, manageOpen: manageOpen, padRing: padRing)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)+ let window = OffscreenWindow(size: NSSize(width: width, height: height), styleMask: [.titled, .closable, .resizable])window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.5))@@@ -891,8 -889,8 +890,8 @@@for (name, running) in [("free-space", false), ("free-space-running", true)] {model.running = runninglet sheet = NSHostingView(rootView: FreeSpaceView(m: model, game: library.games[0], survey: measured, chosen: [.extracted, .oldShaders])- .environmentObject(PadFocus()).environmentObject(model.localizer))+ .environmentObject(PadFocus()).environmentObject(modelStores.localizer))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 560, height: 690), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 560, height: 690))window.contentView = sheetwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.4))@@@ -908,8 -906,8 +907,8 @@@try FileManager.default.createDirectory(at: dm, withIntermediateDirectories: true)try FileManager.default.copyItem(at: URL(fileURLWithPath: json), to: dm.appendingPathComponent("launcher.json"))if let fps = LaunchSetting.read(app: first.appPath)?.first(where: { $0.env == "DM_FPS_TARGET" }) { SavedChoices(app: first.appPath, titleID: first.titleID).set(fps, "60") }- let host = NSHostingView(rootView: LaunchOptionsView(m: model, library: library, gameID: first.id).environmentObject(PadFocus()).environmentObject(model.localizer))+ let host = NSHostingView(rootView: LaunchOptionsView(m: model, library: library, gameID: first.id).environmentObject(PadFocus()).environmentObject(modelStores.localizer))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 700), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 600, height: 700))window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.5))@@@ -939,8 -937,8 +938,8 @@@let layout = ControlLayout(defaults: defaults)if let up = ControlLayout.functions.first(where: { $0.id == "RUp" }) { layout.assign(up, key: 34) }layout.setSends("A", "B"); layout.setSends("B", "A")- let host = NSHostingView(rootView: ControlsView(layout: layout).environmentObject(PadFocus()).environmentObject(model.localizer))+ let host = NSHostingView(rootView: ControlsView(layout: layout).environmentObject(PadFocus()).environmentObject(modelStores.localizer))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 700), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 600, height: 700))window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.5))@@@ -955,9 -953,9 +954,9 @@@_ = crowded.rememberInputs(model)}model.slots[0].paths = []- let view = ContentView(model: model, library: crowded, performStartupChecks: false)+ let view = ContentView(stores: modelStores, library: crowded, performStartupChecks: false)let crowdedHost = NSHostingView(rootView: view)- let crowdedWindow = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1280, height: 900), styleMask: [.titled], backing: .buffered, defer: false)+ let crowdedWindow = OffscreenWindow(size: NSSize(width: 1280, height: 900))crowdedWindow.contentView = crowdedHostcrowdedWindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.5))@@@ -1005,8 -1003,8 +1004,8 @@@layout.controllerCategory = { category }layout.setPadMode(mode)let focus = PadFocus()- let host = NSHostingView(rootView: ControlsView(layout: layout).environmentObject(focus).environmentObject(model.localizer))+ let host = NSHostingView(rootView: ControlsView(layout: layout).environmentObject(focus).environmentObject(modelStores.localizer))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 700), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 600, height: 700))window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.4))@@@ -1023,11 -1021,11 +1022,11 @@@do {try capture("settings-diagnostics", height: 1500, page: .settings)let buttons = NSHostingView(rootView: HStack(spacing: 14) {- DiagnosticsButton(m: model)- DiagnosticsButton(m: model, showCopied: true)- }.launcherRowControls().padding(24).background(LauncherPalette.background).environmentObject(PadFocus()).environmentObject(model.localizer))+ DiagnosticsButton(report: modelStores.diagnostics)+ DiagnosticsButton(report: modelStores.diagnostics, showCopied: true)+ }.launcherRowControls().padding(24).background(LauncherPalette.background).environmentObject(PadFocus()).environmentObject(modelStores.localizer))buttons.frame = NSRect(x: 0, y: 0, width: 420, height: 90)- let window = NSWindow(contentRect: buttons.frame, styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: buttons.frame.size)window.contentView = buttonswindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.3))@@@ -1063,8 -1061,8 +1062,8 @@@let host = NSHostingView(rootView: SavesView(m: model, library: library, gameID: game.id, devicectl: device, support: support, listDevices: {[AppleDevice(id: "00008150-AAAA", name: "Zijad\u{2019}s iPhone", model: "iPhone 17", os: "27.0", reachable: true),AppleDevice(id: "00008150-BBBB", name: "Zijad\u{2019}s iPad", model: "iPad Pro", os: "27.0", reachable: true)]- }).environmentObject(focus).environmentObject(model.localizer))+ }).environmentObject(focus).environmentObject(modelStores.localizer))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 520), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: 600, height: 520))window.contentView = hostwindow.orderFront(nil)RunLoop.main.run(until: Date().addingTimeInterval(0.6))diff --cc frontend/Tests/NX2AppleTests/ReleaseNotesTests.swiftindex 7b80aab3,e683f6d8..4d3a0572--- a/frontend/Tests/NX2AppleTests/ReleaseNotesTests.swift+++ b/frontend/Tests/NX2AppleTests/ReleaseNotesTests.swift@@@ -203,12 -202,12 +203,12 @@@ import NXModefor (name, lang, notes, tag) in [("update-sheet-notes-v072-en", Lang.en, body072, "v0.7.2"), ("update-sheet-notes-v072-zh", Lang.zh, body072, "v0.7.2")]+ [("update-sheet-notes-en", Lang.en, body, "v0.7.0"), ("update-sheet-notes-zh", Lang.zh, body, "v0.7.0"),("update-sheet-notes-middle-en", Lang.en, middle, "v0.7.0"), ("update-sheet-notes-middle-zh", Lang.zh, middle, "v0.7.0")] {- let m = BuildModel()+ let mStores = LauncherStores(); let m = mStores.buildm.lang = lang- m.appUpdates.update = AppUpdate.Release(tag: tag, url: "", digest: nil, notes: notes)+ mStores.appUpdates.update = AppUpdate.Release(tag: tag, url: "", digest: nil, notes: notes)let width: CGFloat = 560, height: CGFloat = 640- let host = NSHostingView(rootView: UpdateSheet(updates: m.appUpdates).environmentObject(m.localizer).frame(width: width, height: height))+ let host = NSHostingView(rootView: UpdateSheet(updates: mStores.appUpdates).environmentObject(mStores.localizer).frame(width: width, height: height))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: width, height: height), styleMask: [.titled], backing: .buffered, defer: false)+ let window = OffscreenWindow(size: NSSize(width: width, height: height))window.contentView = hostwindow.appearance = NSAppearance(named: .darkAqua)window.orderFront(nil)