Run a virtual iPhone on an Apple Silicon Mac.
Swift
Build iOS 26 templates without the trimmed service profile
Jacky52894664c849
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swiftindex 73f4e097..df2005c5 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swift@@ -84,6 +84,14 @@ enum VPhoneMachineTemplateKeys {blocked: blocked,allowed: allowed,)+ // The slimming this iOS can take: `trimmed` is `none` where vphoned+ // has no service list (VPhoneMachineTemplateSlimming.fitted).+ let fitted: VPhoneMachineTemplateSlimming+ do {+ fitted = try slimming.fitted(toIOSVersion: ios.version)+ } catch let error as VPhoneTemplateSlimmingError {+ throw ValidationError(error.description)+ }return VPhoneMachineTemplateKey(device: device,iOSVersion: ios.version,@@ -97,7 +105,7 @@ enum VPhoneMachineTemplateKeys {),bundleSeries: series,diskSizeGB: diskSizeGB,- slimming: slimming,+ slimming: fitted,)}diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swiftindex 1435513b..cf3ccc20 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift@@ -418,6 +418,7 @@ struct VPhoneVirtualMachineTemplateSetupCommand: ParsableCommand {wanted.trimTier = trimmed// Checked before booting: a machine adopt would refuse is not worth it.let recorded = try VPhoneMachineTemplateKeys.recorded(bundle)+ wanted = try Self.fitted(wanted, toIOSVersion: recorded.key.iOSVersion)if let snapshots = try? VPhoneMachineSnapshots.list(of: bundle), !snapshots.isEmpty {print("warning: \(target) has \(snapshots.count) snapshot(s); vm template adopt refuses it until they are deleted")}@@ -458,7 +459,7 @@ struct VPhoneVirtualMachineTemplateSetupCommand: ParsableCommand {}let request = try slimming.requestif !request.isEmpty {- let wanted = try slimming.resolve()+ let wanted = try Self.fitted(slimming.resolve(), toIOSVersion: record.key.iOSVersion)guard wanted == record.key.slimming else {throw ValidationError("\(target) is built to its key: \(record.key.slimming.summary). Leave the slimming switches out.")}@@ -486,6 +487,16 @@ struct VPhoneVirtualMachineTemplateSetupCommand: ParsableCommand {let template = try VPhoneTemplateBuildFinisher.freeze(build, key: record.key)print("[+] Template \(template.identifier) frozen at \(template.url.path)")}++ /// The slimming asked for, as the guest's iOS can take it: no trimmed+ /// service profile where vphoned has no list for that version (iOS 26).+ static func fitted(_ slimming: VPhoneMachineTemplateSlimming, toIOSVersion iOSVersion: String) throws -> VPhoneMachineTemplateSlimming {+ do {+ return try slimming.fitted(toIOSVersion: iOSVersion)+ } catch let error as VPhoneTemplateSlimmingError {+ throw ValidationError(error.description)+ }+ }}// MARK: - adoptdiff --git a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swiftindex c8310ce7..27c14665 100644--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift@@ -63,6 +63,30 @@ public struct VPhoneMachineTemplateSlimming: Codable, Equatable, Hashable, Sendacase removedApps = "RemovedApps"}+ /// This slimming for a guest of `iOSVersion`. `trimmed` is the service+ /// list measured for the guest's iOS; vphoned has one only for+ /// ``VPhoneTemplateSlimmingRequest/trimmedServiceProfileMajors`` and+ /// refuses the profile elsewhere, after the restore and most of the setup+ /// boot. So on another version (iOS 26) the profile is `none`, in the key+ /// as in the setup boot. Extra groups (`--accounts-off`) need the list and+ /// are refused before anything is built.+ public func fitted(toIOSVersion iOSVersion: String) throws -> Self {+ guard serviceProfile == "trimmed",+ let major = iOSVersion.split(separator: ".").first.flatMap({ Int($0) }),+ !VPhoneTemplateSlimmingRequest.trimmedServiceProfileMajors.contains(major)+ else { return self }+ guard serviceGroups.isEmpty else {+ let supported = VPhoneTemplateSlimmingRequest.trimmedServiceProfileMajors.map { "iOS \($0)" }.joined(separator: ", ")+ throw VPhoneTemplateSlimmingError(problems: [+ "service group(s) \(serviceGroups.joined(separator: ", ")) need the trimmed service list, "+ + "which vphoned has for \(supported), not iOS \(iOSVersion)",+ ])+ }+ var fitted = self+ fitted.serviceProfile = "none"+ return fitted+ }+/// One phrase for listings: `trim none, setup boot, services trimmed+accounts, 10 apps removed`.public var summary: String {var services = serviceProfilediff --git a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swift b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swiftindex aebc18bc..1e060d87 100644--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swift+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swift@@ -62,6 +62,12 @@ public struct VPhoneTemplateSlimmingRequest: Equatable, Sendable {public static let trimTiers = VPhoneSystemTrimTier.allCases.filter(\.isSupported).map(\.rawValue)public static let serviceProfiles = ["none", "trimmed"]+ /// The iOS major versions vphoned has a `trimmed` service list for, as+ /// `GuestServiceProfile.supportedMajors` in the guest says. On any other+ /// version `services.profile.apply trimmed` refuses, so a template there+ /// takes `none` (``VPhoneMachineTemplateSlimming/fitted(toIOSVersion:)``).+ public static let trimmedServiceProfileMajors = [27]+/// The removable system apps a slimmed template drops (list C of the/// template trim plan), each verified to stay removed across a respring/// and a reboot on iOS 27.0. Camera stays for camera passthrough checks;diff --git a/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift b/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swiftindex faa6de23..77b3ee95 100644--- a/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift@@ -130,4 +130,24 @@ struct TemplateSlimmingRequestTests {let identifiers = try Set(requests.map { try MachineTemplateKeyTests.key(slimming: $0.resolve()).identifier })#expect(identifiers.count == requests.count)}++ @Test func `the trimmed profile becomes none on an iOS vphoned has no service list for`() throws {+ let slimming = try Request().resolve()+ let on26 = try slimming.fitted(toIOSVersion: "26.6.2")+ #expect(on26.serviceProfile == "none")+ #expect(on26.serviceGroups.isEmpty)+ #expect(on26.trimTier == slimming.trimTier)+ #expect(on26.removedApps == slimming.removedApps)+ #expect(try slimming.fitted(toIOSVersion: "27.0") == slimming)+ #expect(try slimming.fitted(toIOSVersion: "27.0.1") == slimming)+ #expect(try on26.fitted(toIOSVersion: "26.6.2") == on26)+ let none = try Request(serviceProfile: "none").resolve()+ #expect(try none.fitted(toIOSVersion: "26.6.2") == none)+ }++ @Test func `accounts-off is refused on an iOS without the trimmed service list`() throws {+ let slimming = try Request(accountsOff: true).resolve()+ #expect(throws: VPhoneTemplateSlimmingError.self) { try slimming.fitted(toIOSVersion: "26.6.2") }+ #expect(try slimming.fitted(toIOSVersion: "27.0") == slimming)+ }}