Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

vphone-cli: Add --headless boot option

zqxwced405b12d6486
diff --git a/sources/vphone-cli/VPhoneCLI.swift b/sources/vphone-cli/VPhoneCLI.swift
index e2e61d99..cfc0eb65 100644
--- a/sources/vphone-cli/VPhoneCLI.swift
+++ b/sources/vphone-cli/VPhoneCLI.swift
@@ -43,6 +43,9 @@ struct VPhoneBootCLI: ParsableCommand {
@Flag(name: .shortAndLong, help: "Boot into DFU mode")
var dfu: Bool = false
+ @Flag(name: .customLong("headless"), help: "Boot without a VM window or menu bar")
+ var headless: Bool = false
+
@Option(help: "Kernel GDB debug stub port on host (omit for system-assigned port; valid: 6000...65535)")
var kernelDebugPort: Int?
@@ -61,9 +64,9 @@ struct VPhoneBootCLI: ParsableCommand {
@Flag(name: .customLong("no-vphoned"), help: "Exclude vphoned usage (patchless-only).")
var noVphoned: Bool = false
- /// DFU mode runs headless (no GUI).
+ /// DFU mode is always headless.
var noGraphics: Bool {
- dfu
+ dfu || headless
}
var installPackageURL: URL? {
diff --git a/sources/vphone-cli/VPhoneCreateOrchestrator.swift b/sources/vphone-cli/VPhoneCreateOrchestrator.swift
index 284dd04e..76be07e3 100644
--- a/sources/vphone-cli/VPhoneCreateOrchestrator.swift
+++ b/sources/vphone-cli/VPhoneCreateOrchestrator.swift
@@ -534,6 +534,8 @@ public struct VPhoneCreateOrchestrator {
let configURL = bundleURL.appendingPathComponent("config.plist")
var args = ["--config", configURL.path]
if isLess { args += ["--variant", "less"] }
+ // --interactive keeps the window: it is the operator's only boot-progress cue.
+ if !options.interactive { args.append("--headless") }
if options.interactive {
print("[*] press Enter to start VM, after the VM has finished booting, press Enter again to finish last stage")
@@ -580,9 +582,9 @@ public struct VPhoneCreateOrchestrator {
private func runBootAnalysis(bundleURL: URL, verbosity v: VPhoneVerbosity) throws {
let configURL = bundleURL.appendingPathComponent("config.plist")
- trace("spawn \(selfExecutable.path) --config \(configURL.path) (guest serial: off)", v)
+ trace("spawn \(selfExecutable.path) --config \(configURL.path) --headless (guest serial: off)", v)
let vm = VPhoneManagedProcess(
- selfExecutable, ["--config", configURL.path], cwd: bundleURL, echo: false)
+ selfExecutable, ["--config", configURL.path, "--headless"], cwd: bundleURL, echo: false)
try vm.start()
defer { vm.terminate() }
diff --git a/sources/vphone-cli/VPhoneVMLaunchCLI.swift b/sources/vphone-cli/VPhoneVMLaunchCLI.swift
index da6b7a89..b69940a9 100644
--- a/sources/vphone-cli/VPhoneVMLaunchCLI.swift
+++ b/sources/vphone-cli/VPhoneVMLaunchCLI.swift
@@ -9,6 +9,7 @@ struct VPhoneVMLaunchCommand: ParsableCommand {
@OptionGroup var lib: VPhoneLibraryOption
@Argument(help: "VM name") var name: String?
@Flag(name: .shortAndLong, help: "Boot into DFU mode (headless)") var dfu = false
+ @Flag(name: .customLong("headless"), help: "Boot without a VM window or menu bar") var headless = false
@Option(name: [.customShort("V"), .long], help: "Firmware variant") var variant: String?
@Flag(name: .customLong("no-vphoned"), help: "Do not stage/use vphoned") var noVphoned = false
@Option(help: "Kernel GDB debug stub port on host (omit for system-assigned; valid: 6000...65535)")
@@ -61,6 +62,7 @@ struct VPhoneVMLaunchCommand: ParsableCommand {
var args = ["--config", bundle.configURL.path]
if dfu { args.append("--dfu") }
+ if headless { args.append("--headless") }
if let variant { args += ["--variant", variant] }
if noVphoned { args.append("--no-vphoned") }
if let kernelDebugPort { args += ["--kernel-debug-port", String(kernelDebugPort)] }