Run a virtual iPhone on an Apple Silicon Mac.
Swift
iPhone XS Max guests on the research board's iOS 18 kernels
Maximilian Paß818736929a27
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swiftindex d28dbf88..c6b1dc50 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreeGuestDevicePatches.swift@@ -600,6 +600,33 @@ extension DeviceTreePatcher {}}+ // MARK: - Notched iPhone++ static let islandNotchLocationPatch = "devicetree-cfw-island_notch_location"++ /// Removes `/product/island-notch-location` for a guest whose userland has+ /// no Dynamic Island layout (`VPhoneGuestDevice.notchedArtworkSubtype`),+ /// under the patch that otherwise sets it.+ func removeIslandNotchLocation(root: DTNode) throws {+ guard gateAllows(Self.islandNotchLocationPatch),+ let product = Self.optionalChild(of: root, named: "product"),+ let index = product.properties.firstIndex(where: { $0.name == "island-notch-location" })+ else { return }+ let removed = product.properties.remove(at: index)+ patches.append(PatchRecord(+ patchID: Self.islandNotchLocationPatch,+ component: component,+ fileOffset: removed.valueOffset,+ virtualAddress: nil,+ originalBytes: removed.value,+ patchedBytes: Data(),+ description: "Remove the island notch location: \(device.productName) has no Dynamic Island",+ ))+ if verbose {+ print(" -prop : /product/island-notch-location, no Dynamic Island on \(device.productName) [\(Self.islandNotchLocationPatch)]")+ }+ }+// MARK: - Watch Companion/// Give an iPhone guest's `/product/watch-companion` the value 1, adding itdiff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swiftindex bbb37639..7893bb8d 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/DeviceTree/DeviceTreePatcher.swift@@ -342,6 +342,26 @@ public final class DeviceTreePatcher: BufferedPatcher {if presentsGuest {patchesToApply.removeAll { !Self.deviceNeutralPatches.contains($0.patchID) }}+ // An XS-family userland has its own artwork and no Dynamic Island: the+ // artwork patch writes its subtype, and the island patch removes the+ // property instead of setting it.+ if let subtype = device.notchedArtworkSubtype {+ patchesToApply = patchesToApply.compactMap { patch in+ switch patch.patchID {+ case Self.islandNotchLocationPatch:+ return nil+ case "devicetree-cfw-artwork_device_subtype":+ return PropertyPatch(+ nodePath: patch.nodePath, property: patch.property, length: patch.length, flags: patch.flags,+ value: .integer(UInt64(subtype)), patchID: patch.patchID,+ description: "Set artwork device subtype to \(subtype) (\(device.productName))",+ )+ default:+ return patch+ }+ }+ try removeIslandNotchLocation(root: root)+ }for patch in patchesToApply {// Before the property is rewritten, not after: the tree is serialised// from these nodes, so a skipped record with a mutated node woulddiff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/DeviceTreeGuestDeviceTests.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/DeviceTreeGuestDeviceTests.swiftindex fb49fca0..dfe4961e 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/DeviceTreeGuestDeviceTests.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/DeviceTreeGuestDeviceTests.swift@@ -383,6 +383,27 @@ struct DeviceTreeGuestDeviceTests {#expect(Self.integer(installed["device-tree/product"]?["island-notch-location"]) == 144)}+ @Test func `an iPhone XS Max keeps the iPhone17,3 presentation with its own artwork and no island`() throws {+ #expect(!VPhoneGuestDevice.iPhone11_6.presentsBoard)+ #expect(VPhoneGuestDevice.named("iPhone11,4") == .iPhone11_6)+ let shared = try Self.patch(device: .iPhone11_6, role: .shared)+ let product = try #require(shared["device-tree/product"])+ #expect(Self.integer(product["artwork-device-subtype"]) == 2688)+ #expect(product["island-notch-location"] == nil)+ #expect(Self.string(product["artwork-device-idiom"]) == "phone")++ let patcher = DeviceTreePatcher(data: Self.tree.serialized(), verbose: false, device: .iPhone11_6, role: .shared)+ let records = try patcher.findAll()+ #expect(records.contains { $0.patchID == "devicetree-cfw-island_notch_location" && $0.patchedBytes.isEmpty })++ // The island patch's gate decides the removal, as it decides the value.+ let gated = DeviceTreePatcher(data: Self.tree.serialized(), verbose: false, device: .iPhone11_6, role: .shared)+ let declared = Set(FirmwareDeviceTreePatchSet.manifest.patches.map(\.identifier))+ gated.gate = VPhonePatchGate(declared: declared, enabled: declared.subtracting(["devicetree-cfw-island_notch_location"]))+ _ = try gated.findAll()+ #expect(Self.read(gated.patchedData)["device-tree/product"]?["island-notch-location"] != nil)+ }+@Test func `a 13-inch M-series board keeps Stage Manager and its own identity`() throws {let board = Self.board(model: "iPad17,3", unique: "J820AP", subtype: 2752, disablesStageManager: false)let tree = try Self.patch(device: .iPad17_3, role: .installed, board: board)diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwareCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwareCommand.swiftindex 5f2b421b..71cab716 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwareCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwareCommand.swift@@ -179,7 +179,8 @@ struct VPhoneFirmwareCatalogCommand: ParsableCommand {var device: String?func run() throws {- let report = VPhoneFirmwareCatalog.report+ // Launchpad reads the JSON; the listing names the CLI-only devices too.+ let report = json ? VPhoneFirmwareCatalog.report : VPhoneFirmwareCatalog.report(includingCLIOnly: true)if json {try print(String(decoding: JSONEncoder().encode(report), as: UTF8.self))returndiff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreateCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreateCommand.swiftindex 7281ccbc..8d64047c 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreateCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreateCommand.swift@@ -101,13 +101,16 @@ struct VPhoneVirtualMachineCreateCommand: ParsableCommand {/// An Apple TV takes the TV preset; one whose userland comes from an OTA/// takes the arm64e one, with the GPU driver and the userland swap. An- /// Apple Watch takes the watch preset.+ /// Apple Watch takes the watch preset, an iPhone XS Max `minimal`: its iOS 18+ /// research board kernel boots no other.private var defaultPreset: String {switch VPhoneGuestDevice.named(device) {case let guest? where guest.family == .appleTV:guest.restoreBase == nil ? VPhonePatchPreset.tvOSIdentifier : VPhonePatchPreset.tvOS4KIdentifiercase let guest? where guest.family == .watch:VPhonePatchPreset.watchOSIdentifier+ case let guest? where guest.notchedArtworkSubtype != nil:+ VPhonePatchPreset.minimalIdentifierdefault:VPhonePatchPreset.standardIdentifier}diff --git a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swiftindex 17aa2124..ce3fc07c 100644--- a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift+++ b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift@@ -467,6 +467,27 @@ public enum VPhoneFirmwareCatalog {]),]+ /// iPhone XS Max releases, each paired with its own release's research board+ /// cloudOS: the 18.x kernelcache recipes rebuild that iOS 18 kernel with the+ /// cloudOS 26.1 vphone600 kexts. Kernel-first, so macOS 26.4 and later link+ /// it over ssh on an older Mac (`VPHONE_KMUTIL_SSH`), and only `minimal` boots it.+ static let iOS18ResearchBoardReleases: [(version: String, url: String, cloudOS: VPhoneCloudOSOption)] = [+ ("18.1", "https://updates.cdn-apple.com/2024FallFCS/fullrestores/072-12814/E17284F9-4885-4E16-840A-40DF173142B3/iPhone11,2,iPhone11,4,iPhone11,6_18.1_22B83_Restore.ipsw",+ .init(name: "cloudOS 18.1 (22B83)", url: "https://updates.cdn-apple.com/private-cloud-compute/729b85b9b89b4383e7dfafdf0f5867b8cd2f3e4e69b279c8785dc7d044e377b7")),+ ("18.2.1", "https://updates.cdn-apple.com/2024FallFCS/fullrestores/072-56807/7999846C-76E5-42DC-A3F0-96E5FD27FF44/iPhone11,2,iPhone11,4,iPhone11,6_18.2.1_22C161_Restore.ipsw",+ .init(name: "cloudOS 18.2.1 (22C161)", url: "https://updates.cdn-apple.com/private-cloud-compute/0aadbf7c7e768c73e1f0a6331fbcc96e3792a9f2176509f6225059fbad0bb6b6")),+ ("18.3.1", "https://updates.cdn-apple.com/2025WinterFCS/fullrestores/072-84318/BE724963-525E-4B8D-8E9F-018395E81BA2/iPhone11,2,iPhone11,4,iPhone11,6_18.3.1_22D72_Restore.ipsw",+ .init(name: "cloudOS 18.3.1 (22D72)", url: "https://updates.cdn-apple.com/private-cloud-compute/0ce2ff6ad1af4052bbabf38a4627506613ca5c2061e198888391a430357f0b39")),+ ("18.5", "https://updates.cdn-apple.com/2025SpringFCS/fullrestores/082-45658/0CEE897C-AD56-4422-BD70-FA3CB060E23C/iPhone11,2,iPhone11,4,iPhone11,6_18.5_22F76_Restore.ipsw",+ .init(name: "cloudOS 18.5 (22F76)", url: "https://updates.cdn-apple.com/private-cloud-compute/ceb5e5bde2427bf7a227b61ff307f79c4b9c701f46023262abd763758aea6453")),+ ("18.6", "https://updates.cdn-apple.com/2025SummerFCS/fullrestores/082-99059/7A2E93FF-79D9-4AD7-862B-5A4B812ADD90/iPhone11,2,iPhone11,4,iPhone11,6_18.6_22G86_Restore.ipsw",+ .init(name: "cloudOS 18.6 (22G86)", url: "https://updates.cdn-apple.com/private-cloud-compute/8b2181f68080c42ae57bb8bf516715841060ee3aaf8c0ff06e1cf627169ef574")),+ ("18.7", "https://updates.cdn-apple.com/2025FallFCS/fullrestores/082-75719/D271E370-84A4-494D-8547-BDBE20AC1EEA/iPhone11,2,iPhone11,4,iPhone11,6_18.7_22H20_Restore.ipsw",+ .init(name: "cloudOS 18.7 (22H20)", url: "https://updates.cdn-apple.com/private-cloud-compute/9b0acae06a068476c5bf0c1ecdf686cf1ff4ead5a9dcf7429c7d86d01033ef9b")),+ ("18.7.2", "https://updates.cdn-apple.com/2025FallFCS/fullrestores/089-18690/1C111BF6-B55E-460B-AE63-5343B163CAE4/iPhone11,2,iPhone11,4,iPhone11,6_18.7.2_22H124_Restore.ipsw",+ .init(name: "cloudOS 18.7.2 (22H43)", url: "https://updates.cdn-apple.com/private-cloud-compute/d425a03c76f1ddb92a65a27d56e80beffe399605018d4d268f5ef8889d0ec9e7")),+ ]+/// Full OTAs of devices without an IPSW, oldest first. Each has a/// `tvReleases` entry of its `baseVersion` for its `restoreBase`. The keys/// are AppleDB's.@@ -522,6 +543,17 @@ public enum VPhoneFirmwareCatalog {/// gets none.public static func pairings(for device: String) -> [VPhoneFirmwarePairing] {guard let guest = VPhoneGuestDevice.named(device) else { return [] }+ if guest.notchedArtworkSubtype != nil {+ return iOS18ResearchBoardReleases.map { release in+ VPhoneFirmwarePairing(+ device: guest.productType,+ iosName: "iOS \(release.version)",+ iosURL: release.url,+ cloudosName: release.cloudOS.name,+ cloudosURL: release.cloudOS.url,+ )+ }+ }guard guest.presentsBoard else { return pairings }let restored = guest.restoreBase ?? guestvar releases = (iPhoneReleases + iPadReleases + tvReleases + watchReleases).first { $0.devices.contains(restored.productType) }?.releases ?? []@@ -571,6 +603,11 @@ public enum VPhoneFirmwareCatalog {/// JSON-friendly projection of the catalog: each build with its recommended/// cloudOS, for the iPhone and then per guest device.public static var report: VPhoneFirmwareCatalogReport {+ report(includingCLIOnly: false)+ }++ /// The catalog, with the devices only the CLI creates when `includingCLIOnly`.+ public static func report(includingCLIOnly: Bool) -> VPhoneFirmwareCatalogReport {func entries(_ pairings: [VPhoneFirmwarePairing]) -> [VPhoneFirmwareCatalogReport.Entry] {pairings.map {let ota = otaRelease(source: $0.iosURL)@@ -591,6 +628,10 @@ public enum VPhoneFirmwareCatalog {device: device,pairings: entries(pairings),devices: VPhoneGuestDevice.known.compactMap { guest in+ // The iOS 18 research board releases link kernel-first, over ssh+ // on an older Mac from macOS 26.4 on, which Launchpad's root link+ // does not: `vphone-cli fw catalog --device` lists them.+ guard includingCLIOnly || guest.notchedArtworkSubtype == nil else { return nil }let pairings = pairings(for: guest.productType)guard !pairings.isEmpty else { return nil }return .init(diff --git a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swiftindex 6656915c..72a813cd 100644--- a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift+++ b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift@@ -61,10 +61,19 @@ public struct VPhoneGuestDevice: Sendable, Equatable {/// Whether the guest boots a device tree of its own that presents this/// board, built by `fw patch` from the board's tree in the IPSW. Every- /// device but the iPhone17,3 does; that one keeps the fixed D47 identity- /// `cfw install` writes into the restored tree.+ /// device but the iPhone17,3 and the iPhone XS Max does; those keep the+ /// fixed D47 identity `cfw install` writes into the restored tree.public var presentsBoard: Bool {- productType != Self.iPhone17_3.productType+ productType != Self.iPhone17_3.productType && notchedArtworkSubtype == nil+ }++ /// The artwork subtype of a guest presented as the iPhone17,3 whose own+ /// userland has none of the iPhone 16's: the XS family's asset catalogs+ /// only carry 2436 and 2688 artwork, and its SpringBoard no Dynamic Island+ /// layout. Without it Hello and the wallpaper stay empty and the home+ /// gesture breaks. Nil for every other device.+ public var notchedArtworkSubtype: Int? {+ productType == "iPhone11,6" ? 2688 : nil}// MARK: - Known Devices@@ -115,6 +124,19 @@ public struct VPhoneGuestDevice: Sendable, Equatable {/// iPhone 18 Pro (V63AP): 1206x2622, 402x874 points.public static let iPhone19_2 = iPhone("iPhone19,2", "v63ap", "iPhone 18 Pro", width: 1206, height: 2622)+ /// iPhone XS Max: 1242x2688 at 458 ppi, 414x896 points. Its IPSW carries the+ /// iOS 18 releases after 18.6, which the iPhone 16 never got; the research+ /// board's own iOS 18 kernel boots it (the 18.x kernelcache recipes, `minimal`+ /// only). It is presented as the iPhone17,3 with its own artwork+ /// (`notchedArtworkSubtype`).+ public static let iPhone11_6 = VPhoneGuestDevice(+ family: .iPhone,+ productType: "iPhone11,6",+ deviceClass: "d331pap",+ productName: "iPhone XS Max",+ screen: .init(width: 1242, height: 2688, pixelsPerInch: 458, scale: 3.0),+ )+private static func iPad(_ productType: String,_ deviceClass: String,@@ -205,6 +227,7 @@ public struct VPhoneGuestDevice: Sendable, Equatable {iPhone17_4, iPhone17_1, iPhone17_2, iPhone17_5,iPhone18_3, iPhone18_4, iPhone18_1, iPhone18_2, iPhone18_5,iPhone19_2,+ iPhone11_6,iPad16_1,iPad15_7,iPad15_3, iPad15_5,@@ -217,6 +240,7 @@ public struct VPhoneGuestDevice: Sendable, Equatable {/// Cellular models that ship in the same IPSW as a known Wi-Fi model and map/// onto it: the VM has no baseband, so it gets the Wi-Fi identity.static let aliases: [String: String] = [+ "iPhone11,4": "iPhone11,6","iPad16,2": "iPad16,1","iPad15,4": "iPad15,3","iPad15,6": "iPad15,5",diff --git a/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift b/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swiftindex 6be298b6..0cdd5de7 100644--- a/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift@@ -50,7 +50,9 @@ struct FirmwareCatalogReportTests {@Test func `lists every curated guest`() {let report = VPhoneFirmwareCatalog.report- #expect(report.devices.map(\.productType) == VPhoneGuestDevice.known.map(\.productType))+ // Launchpad's list leaves out the CLI-only iPhone XS Max.+ #expect(report.devices.map(\.productType) == VPhoneGuestDevice.known.map(\.productType).filter { $0 != "iPhone11,6" })+ #expect(VPhoneFirmwareCatalog.report(includingCLIOnly: true).devices.map(\.productType) == VPhoneGuestDevice.known.map(\.productType))#expect(report.devices.first?.pairings == report.pairings)for device in report.devices.dropFirst() {#expect(device.family == VPhoneGuestDevice.named(device.productType)?.family.rawValue)@@ -148,6 +150,21 @@ struct FirmwareCatalogReportTests {#expect(VPhoneFirmwareCatalog.pairings(for: "iPhone18,1") != VPhoneFirmwareCatalog.pairings)}+ @Test func `an i phone XS max pairs each iOS 18 release with its own research board cloud OS, for the CLI only`() {+ let pairings = VPhoneFirmwareCatalog.pairings(for: "iPhone11,6")+ #expect(pairings.map(\.iosName) == ["iOS 18.1", "iOS 18.2.1", "iOS 18.3.1", "iOS 18.5", "iOS 18.6", "iOS 18.7", "iOS 18.7.2"])+ for p in pairings {+ let version = p.iosName.dropFirst("iOS ".count)+ #expect(p.device == "iPhone11,6")+ #expect((p.iosURL as NSString).lastPathComponent.hasPrefix("iPhone11,2,iPhone11,4,iPhone11,6_\(version)_"))+ #expect(p.cloudosName.hasPrefix("cloudOS \(version) ("))+ #expect(p.cloudosURL.contains("/private-cloud-compute/"))+ }+ #expect(VPhoneFirmwareCatalog.pairings(for: "iPhone11,4") == pairings)+ #expect(!VPhoneFirmwareCatalog.report.devices.contains { $0.productType == "iPhone11,6" })+ #expect(VPhoneFirmwareCatalog.report(includingCLIOnly: true).devices.contains { $0.productType == "iPhone11,6" })+ }+@Test func `cellular i pad gets its wi fi model's pairings`() {#expect(VPhoneFirmwareCatalog.pairings(for: "iPad17,4") == VPhoneFirmwareCatalog.pairings(for: "iPad17,3"))#expect(VPhoneFirmwareCatalog.pairings(for: "iPad17,3").first?.device == "iPad17,3")diff --git a/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift b/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swiftindex 172e52e0..0001c4ff 100644--- a/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift@@ -119,10 +119,21 @@ struct GuestDeviceTests {#expect(VPhoneGuestDevice.iPad17_3.screen == .init(width: 2064, height: 2752, pixelsPerInch: 264, scale: 2.0))}+ @Test+ func `an iPhone XS Max is presented as the iPhone17,3 with its own artwork`() {+ let xsMax = VPhoneGuestDevice.iPhone11_6+ #expect(!xsMax.presentsBoard)+ #expect(xsMax.notchedArtworkSubtype == 2688)+ #expect(xsMax.screen == .init(width: 1242, height: 2688, pixelsPerInch: 458, scale: 3.0))+ #expect(VPhoneGuestDevice.iPhone17_3.notchedArtworkSubtype == nil)+ // Its IPSW covers the XS (iPhone11,2), which vphone does not run, first.+ #expect(VPhoneGuestDevice.detect(buildManifest: ["SupportedProductTypes": ["iPhone11,2", "iPhone11,4", "iPhone11,6"]]) == xsMax)+ }+@Testfunc `every other iPhone presents its own board at 3x`() {#expect(!VPhoneGuestDevice.iPhone17_3.presentsBoard)- for device in VPhoneGuestDevice.known where device.family == .iPhone && device != .iPhone17_3 {+ for device in VPhoneGuestDevice.known where device.family == .iPhone && device != .iPhone17_3 && device.notchedArtworkSubtype == nil {#expect(device.presentsBoard)#expect(device.screen.scale == 3.0)#expect(device.screen.pixelsPerInch == 460)