Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Demo: HOST_DEFAULT build flag starts in host mode without launch arguments

v0lumehi2e65f4371b60
diff --git a/frontend-ios/README.md b/frontend-ios/README.md
index 832675a6..2a6ed668 100644
--- a/frontend-ios/README.md
+++ b/frontend-ios/README.md
@@ -78,7 +78,7 @@ Play on a playable game builds a `LaunchableGame` (title ID, name, manifest, bun
### Host mode of the demo
-`--host` runs `ShellHostView` on the fixture bundles in `Tests/ShellHostTests/Fixtures/Games` (the Xcode app carries them as its `Games` folder, the package executable takes `--games-dir <folder>`): playable, needs game data, app update (another chain and a newer OS) and broken (no framework, damaged manifest, manifest without keys, damaged settings list). They hold no game data and no pictures (`.gitignore` keeps images out, the tests draw their own). Marker files in a temporary app-data folder make most of them playable, and launching is the stub. `--select <title ID>` picks the first game.
+`--host` runs `ShellHostView` on the fixture bundles in `Tests/ShellHostTests/Fixtures/Games` (the Xcode app carries them as its `Games` folder, the package executable takes `--games-dir <folder>`): playable, needs game data, app update (another chain and a newer OS) and broken (no framework, damaged manifest, manifest without keys, damaged settings list). They hold no game data and no pictures (`.gitignore` keeps images out, the tests draw their own). Marker files in a temporary app-data folder make most of them playable, and launching is the stub. `--select <title ID>` picks the first game. A build with `SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) HOST_DEFAULT'` starts in host mode without arguments (for installing on a device), and `--samples` brings the sample games back.
## Layouts
diff --git a/frontend-ios/Sources/ShellDemo/ShellDemoApp.swift b/frontend-ios/Sources/ShellDemo/ShellDemoApp.swift
index e8e7aef4..5a8f195e 100644
--- a/frontend-ios/Sources/ShellDemo/ShellDemoApp.swift
+++ b/frontend-ios/Sources/ShellDemo/ShellDemoApp.swift
@@ -3,9 +3,17 @@ import ShellUI
import ShellControllers
@main struct ShellDemoApp: App {
+ /// `--host`, or always when built with `-D HOST_DEFAULT` (a build to install, where no launch arguments can be passed).
+ private var hostMode: Bool {
+ #if HOST_DEFAULT
+ !ProcessInfo.processInfo.arguments.contains("--samples")
+ #else
+ ProcessInfo.processInfo.arguments.contains("--host")
+ #endif
+ }
var body: some Scene {
WindowGroup {
- if ProcessInfo.processInfo.arguments.contains("--host") { HostDemoScreen() } else { DemoScreen() }
+ if hostMode { HostDemoScreen() } else { DemoScreen() }
}
}
}