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
Let explicit iOS pipeline archive settings override discovery
thehobbit85fe3b8e21dde3
diff --git a/frontend-ios/README.md b/frontend-ios/README.mdindex becf8454..da11eba9 100644--- a/frontend-ios/README.md+++ b/frontend-ios/README.md@@ -80,6 +80,8 @@ ShellHostView(model: model)public protocol GameLauncher: Sendable { @MainActor func launch(_ game: LaunchableGame) async throws }```+To disable an offline pipeline archive for one game, set `DM_PSO_BUNDLE=off` in `Documents/games/<title ID>/env.txt`. The shared `Documents/env.txt` can set it for every game. An explicit launch setting wins over both files, then the game's file wins over the shared file. When none sets `DM_PSO_BUNDLE`, the shell uses the game's `pso/` folder, then the framework's `pso/` folder. This override does not diagnose or repair an incompatible archive.+Play on a playable game builds a `LaunchableGame` (title ID, name, manifest, bundle folder, framework URL, data folder, the app's `Documents/games/<title ID>/`, every `DM_*` value as a dictionary, the picked cloud-save folder) and calls `launch`. A thrown error is shown as the notice. `StubGameLauncher` only logs and throws `GameLaunchError.notAvailable` ("Launching is not available yet."). Route C's M2 (#144) plugs in the real launcher: it sets the environment from `environment` and the folders (`DM_PROFILE`, `DM_ROMFS`, `DM_SAVE`, `DM_TEMP`, `DM_SAVE_SYNC` from `cloudSavesURL`), `dlopen`s `frameworkURL` and starts the host with the manifest's modules. Nothing else in the host changes: pass it as `launcher:`. The engine and `dm/` are not part of this package.### Host mode of the demodiff --git a/frontend-ios/Sources/ShellHost/EngineLaunchPlan.swift b/frontend-ios/Sources/ShellHost/EngineLaunchPlan.swiftindex 092fcf64..039c6ff6 100644--- a/frontend-ios/Sources/ShellHost/EngineLaunchPlan.swift+++ b/frontend-ios/Sources/ShellHost/EngineLaunchPlan.swift@@ -24,7 +24,8 @@ public struct EngineLaunchPlan: Equatable, Sendable {/// (#557), read from `game.appFolder` when it is nil. A key in the game's file wins over the shared file, and the launch/// environment (the player's settings, the paths above) wins over both. The game's own `mods/` folder sets/// `DM_ROMFS_OVERLAY` (`GameMods`) when the game's env file does not, and it wins over the shared file. The order is: launch- /// environment, game env.txt, game mods folder, shared env.txt.+ /// environment, game env.txt, game mods folder, shared env.txt. Automatic `DM_PSO_BUNDLE` discovery is a fallback+ /// after both env files, so an explicit archive path or `off` can override it.public static func make(game: LaunchableGame, appResources: URL, documents: URL, envFileText: String?, gameEnvFileText: String? = nil,fileManager fm: FileManager = .default) -> EngineLaunchPlan {let manifest = game.manifest, fw = game.frameworkURL, gdir = game.appFolder@@ -45,7 +46,6 @@ public struct EngineLaunchPlan: Equatable, Sendable {let bundledMSL = game.shaderResourcesURL ?? fw.appendingPathComponent("msl", isDirectory: true)env["DM_MSL_DIR"] = (isDirectory(ownMSL) ? ownMSL : bundledMSL).pathlet ownPSO = gdir.appendingPathComponent("pso", isDirectory: true), fwPSO = fw.appendingPathComponent("pso", isDirectory: true)- if isDirectory(ownPSO) { env["DM_PSO_BUNDLE"] = ownPSO.path } else if isDirectory(fwPSO) { env["DM_PSO_BUNDLE"] = fwPSO.path }let dataAOC = game.dataURL.appendingPathComponent("aoc", isDirectory: true), ownAOC = gdir.appendingPathComponent("aoc", isDirectory: true)if isDirectory(dataAOC) { env["DM_AOC_DIR"] = dataAOC.path } else if isDirectory(ownAOC) { env["DM_AOC_DIR"] = ownAOC.path }env["DM_CHEATS"] = gdir.appendingPathComponent("cheats", isDirectory: true).path@@ -70,6 +70,9 @@ public struct EngineLaunchPlan: Equatable, Sendable {}apply(envFileText)env["DM_ENV_FILE_KEYS"] = fromFile.joined(separator: " ")+ if env["DM_PSO_BUNDLE"] == nil {+ if isDirectory(ownPSO) { env["DM_PSO_BUNDLE"] = ownPSO.path } else if isDirectory(fwPSO) { env["DM_PSO_BUNDLE"] = fwPSO.path }+ }return EngineLaunchPlan(environment: env,diff --git a/frontend-ios/Tests/ShellHostTests/EngineLaunchPlanTests.swift b/frontend-ios/Tests/ShellHostTests/EngineLaunchPlanTests.swiftindex 1123b812..0d26f421 100644--- a/frontend-ios/Tests/ShellHostTests/EngineLaunchPlanTests.swift+++ b/frontend-ios/Tests/ShellHostTests/EngineLaunchPlanTests.swift@@ -58,6 +58,38 @@ import Testing#expect(rig.plan().environment["DM_PSO_BUNDLE"] == rig.fw.path + "/pso")}+ @Test(arguments: [false, true]) func sharedEnvCanDisableADiscoveredPipelineArchive(perGameArchive: Bool) throws {+ let rig = try Rig()+ try rig.box.makeFolder(rig.fw.appendingPathComponent("pso"))+ if perGameArchive { try rig.box.makeFolder(rig.gdir.appendingPathComponent("pso")) }+ let env = rig.plan(envFile: "DM_PSO_BUNDLE=off\n").environment+ #expect(env["DM_PSO_BUNDLE"] == "off")+ #expect(env["DM_ENV_FILE_KEYS"] == "DM_PSO_BUNDLE")+ }++ @Test func gameArchiveOverrideWinsOverSharedFileAndStaysWithItsGame() throws {+ let rig = try Rig()+ try rig.box.makeFolder(rig.fw.appendingPathComponent("pso"))+ try rig.box.write("DM_PSO_BUNDLE=off\n", to: rig.gdir.appendingPathComponent("env.txt"))+ let env = rig.plan(envFile: "DM_PSO_BUNDLE=/shared/archive\n").environment+ #expect(env["DM_PSO_BUNDLE"] == "off")+ #expect(env["DM_ENV_FILE_KEYS"] == "DM_PSO_BUNDLE")+ var other = rig.game+ other.appFolder = rig.box.documents.appendingPathComponent("games/0100000000000000")+ let otherPlan = EngineLaunchPlan.make(game: other, appResources: rig.box.resources, documents: rig.box.documents, envFileText: nil)+ #expect(otherPlan.environment["DM_PSO_BUNDLE"] == rig.fw.path + "/pso")+ #expect(otherPlan.environment["DM_ENV_FILE_KEYS"] == "")+ }++ @Test func explicitLaunchArchiveWinsOverEnvFilesAndDiscoveredArchives() throws {+ let rig = try Rig(environment: ["DM_PSO_BUNDLE": "/launch/archive"])+ try rig.box.makeFolder(rig.fw.appendingPathComponent("pso"))+ try rig.box.write("DM_PSO_BUNDLE=off\n", to: rig.gdir.appendingPathComponent("env.txt"))+ let env = rig.plan(envFile: "DM_PSO_BUNDLE=/shared/archive\n").environment+ #expect(env["DM_PSO_BUNDLE"] == "/launch/archive")+ #expect(env["DM_ENV_FILE_KEYS"] == "")+ }+@Test func romfsImageIsMatchedCaseInsensitively() throws {let rig = try Rig()try rig.box.write("x", to: rig.data.appendingPathComponent("Romfs.IMG"))