Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

boot: validate --install-ipa before startup

tastyheadphonesa36b797a6e5c
diff --git a/sources/vphone-cli/VPhoneCLI.swift b/sources/vphone-cli/VPhoneCLI.swift
index 7c29932f..520153fa 100644
--- a/sources/vphone-cli/VPhoneCLI.swift
+++ b/sources/vphone-cli/VPhoneCLI.swift
@@ -45,7 +45,7 @@ struct VPhoneBootCLI: ParsableCommand {
var vphonedBin: String = ".vphoned.signed"
@Option(
- help: "Automatically install the given IPA/TIPA after the guest control channel connects.",
+ help: "Automatically install the given IPA/TIPA after the guest control channel connects. Unavailable with --dfu.",
transform: URL.init(fileURLWithPath:)
)
var installIPA: URL?
@@ -59,6 +59,26 @@ struct VPhoneBootCLI: ParsableCommand {
installIPA?.standardizedFileURL
}
+ mutating func validate() throws {
+ if dfu, let packageURL = installPackageURL {
+ throw ValidationError(
+ "`--install-ipa` is unavailable with `--dfu` because DFU mode does not start the guest control channel: \(packageURL.path)"
+ )
+ }
+
+ guard let packageURL = installPackageURL else { return }
+
+ guard FileManager.default.fileExists(atPath: packageURL.path) else {
+ throw ValidationError("`--install-ipa` file does not exist: \(packageURL.path)")
+ }
+
+ guard VPhoneInstallPackage.isSupportedFile(packageURL) else {
+ throw ValidationError(
+ "`--install-ipa` only supports .ipa or .tipa packages: \(packageURL.lastPathComponent)"
+ )
+ }
+ }
+
/// Resolve final options by merging manifest values.
func resolveOptions() throws -> VPhoneVirtualMachine.Options {
let manifest = try VPhoneVirtualMachineManifest.load(from: config)