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 PR #84 into main: the controller-layouts capture joins the diagnostics and Saves captures
LNPANDY427335f5843c
diff --cc frontend/Tests/NSPortBuilderTests/LibraryTests.swiftindex cc336939,8ef6f0fe..337a4d7b--- a/frontend/Tests/NSPortBuilderTests/LibraryTests.swift+++ b/frontend/Tests/NSPortBuilderTests/LibraryTests.swift@@@ -762,32 -813,61 +813,87 @@@ final class LibraryTests: XCTestCasetry capture("building", activeID: library.games[1].id)model.running = false+ // ---- Controller layouts (#70): the Controls sheet scrolled to the layout by the controller's focus, Auto with a+ // stand-in Xbox controller, then By label with none connected (a suite of its own; no real controller is read) ----+ do {+ let suite = "nxnative-visual-qa-control-presets"+ let defaults = try XCTUnwrap(UserDefaults(suiteName: suite))+ defaults.removePersistentDomain(forName: suite)+ defer { defaults.removePersistentDomain(forName: suite) }+ for (name, mode, category) in [("controls-layout-auto", PadMode.auto, "Xbox One" as String?), ("controls-layout-bylabel", .byLabel, nil)] {+ let layout = ControlLayout(defaults: defaults)+ layout.controllerCategory = { category }+ layout.setPadMode(mode)+ let focus = PadFocus()+ let host = NSHostingView(rootView: ControlsView(m: model, layout: layout).environmentObject(focus))+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 700), styleMask: [.titled], backing: .buffered, defer: false)+ window.contentView = host+ window.orderFront(nil)+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))+ focus.scope = "controls"+ focus.show(default: "pad.mode")+ RunLoop.main.run(until: Date().addingTimeInterval(0.6))+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))+ host.cacheDisplay(in: host.bounds, to: rep)+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent(name + ".png"))+ window.orderOut(nil)+ }+ }+ // ---- Copy diagnostics (#69): Settings with its row, and the button's Copied confirmation (nothing is copied) ----+ do {+ try capture("settings-diagnostics", height: 1500, page: .settings)+ let buttons = NSHostingView(rootView: HStack(spacing: 14) {+ DiagnosticsButton(m: model, width: BuilderView.settingsButtonWidth)+ DiagnosticsButton(m: model, width: BuilderView.settingsButtonWidth, showCopied: true)+ }.padding(24).background(LauncherPalette.background).environmentObject(PadFocus()))+ buttons.frame = NSRect(x: 0, y: 0, width: 420, height: 90)+ let window = NSWindow(contentRect: buttons.frame, styleMask: [.titled], backing: .buffered, defer: false)+ window.contentView = buttons+ window.orderFront(nil)+ RunLoop.main.run(until: Date().addingTimeInterval(0.3))+ let rep = try XCTUnwrap(buttons.bitmapImageRepForCachingDisplay(in: buttons.bounds))+ buttons.cacheDisplay(in: buttons.bounds, to: rep)+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent("diagnostics-copied.png"))+ window.orderOut(nil)+ }+ // ---- Saves (#66): the sheet with a stand-in devicectl and a temporary Mac folder, then its question, reached by the controller ----+ do {+ let game = library.games[0]+ let installed = temporary.appendingPathComponent("DmIOS.app")+ 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)+ 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)+ try Data("mac".utf8).write(to: save)+ try FileManager.default.setAttributes([.modificationDate: Date(timeIntervalSinceNow: -3 * 86_400)], ofItemAtPath: save.path)+ let device = DeviceControl { args in // a device whose save is from an hour ago+ guard let i = args.firstIndex(of: "--json-output") else { return (false, "ERROR: not in the visual QA") }+ let files = args.contains("--recurse") ? [["name": "data.bin", "fileType": "file", "modificationDate": ISO8601DateFormatter().string(from: Date(timeIntervalSinceNow: -3600))]] : []+ try? JSONSerialization.data(withJSONObject: ["result": ["files": files]]).write(to: URL(fileURLWithPath: args[i + 1]))+ return (true, "")+ }+ let focus = PadFocus()+ let host = NSHostingView(rootView: SavesView(m: model, library: library, gameID: game.id, devicectl: device, support: support).environmentObject(focus))+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 520), styleMask: [.titled], backing: .buffered, defer: false)+ window.contentView = host+ window.orderFront(nil)+ RunLoop.main.run(until: Date().addingTimeInterval(0.6))+ func shot(_ name: String) throws {+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))+ host.cacheDisplay(in: host.bounds, to: rep)+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent(name + ".png"))+ }+ try shot("saves")+ focus.scope = "saves"+ focus.show(default: "saves.toDevice")+ focus.activate()+ RunLoop.main.run(until: Date().addingTimeInterval(0.4))+ try shot("saves-confirm")+ window.orderOut(nil)+ }}/// Issue #52: the failure note names the last real line, not just the exit code.