Run a virtual iPhone on an Apple Silicon Mac.
Swift
Add a trimmed service list for iOS 26
Jacky50545d33f2cf
diff --git a/VPhoneDaemon/Daemon/GuestServiceProfile.swift b/VPhoneDaemon/Daemon/GuestServiceProfile.swiftindex fd15a0d4..003e0052 100644--- a/VPhoneDaemon/Daemon/GuestServiceProfile.swift+++ b/VPhoneDaemon/Daemon/GuestServiceProfile.swift@@ -8,8 +8,10 @@ import Foundation/// load the job at the next boot. Nothing changes until the guest restarts;/// `launchctl stop` and `unload` return launchd status 144 on the guest.///-/// `trimmed` is the set measured on an iOS 27.0 iPhone guest: memory −29%,-/// idle host CPU −26%, idle host writes −60%, with no vphone feature lost.+/// `trimmed` is the set measured on an iOS 27.0 iPhone guest (memory −29%,+/// idle host CPU −26%, idle host writes −60%) and mapped onto iOS 26.6.2+/// (memory −30%, idle host CPU −39%, idle host writes −94%), with no vphone+/// feature lost on either./// `none` turns back on only what the profile turned off, which it records in/// `recordPath`; a job somebody else disabled (the OTA block, a user in the/// Services panel) is never touched. See `Research/Guest/service_trimming.md`.@@ -34,38 +36,48 @@ enum GuestServiceProfile {}/// The groups for an iOS major version, nil where no list was measured.- /// iOS 26 and iPadOS guests have none yet.+ /// Both lists were measured on iPhone guests.static func groups(iosMajor: Int) -> [Group]? {- iosMajor == 27 ? groups27 : nil+ switch iosMajor {+ case 26: groups26+ case 27: groups27+ default: nil+ }}- static let supportedMajors = [27]+ static let supportedMajors = [26, 27]++ /// `base` plus the groups every version shares: the store, sign-in+ /// follow-up and account daemons have the same labels on 26 and 27.+ static func catalog(base: [String]) -> [Group] {+ [+ Group(+ name: "base", byDefault: true,+ summary: "Siri and intelligence, Find My, Wallet/NFC/SE, Watch, Home, health coaching, Maps background, "+ + "iCloud/iMessage sync, ads and recommendations, telemetry, accessory firmware, OTA",+ labels: base,+ ),+ Group(+ name: "app_store", byDefault: true,+ summary: "App Store and iTunes Store daemons, off with the store apps; appstorecomponentsd is in base",+ labels: ["com.apple.appstored", "com.apple.itunesstored"],+ ),+ Group(+ name: "signin_followup", byDefault: true,+ summary: "Sign-in follow-up and Apple Account setup prompts; apply after first-boot work has settled",+ labels: ["com.apple.appleidsetupd", "com.apple.followupd"],+ ),+ Group(+ name: "accounts", byDefault: false,+ summary: "Apple Account daemons; with these off the guest cannot sign in to an Apple Account",+ labels: ["com.apple.akd", "com.apple.amsaccountsd", "com.apple.appleaccountd"],+ ),+ ]+ }// MARK: - iOS 27- static let groups27: [Group] = [- Group(- name: "base", byDefault: true,- summary: "Siri and intelligence, Find My, Wallet/NFC/SE, Watch, Home, health coaching, Maps background, "- + "iCloud/iMessage sync, ads and recommendations, telemetry, accessory firmware, OTA",- labels: base27,- ),- Group(- name: "app_store", byDefault: true,- summary: "App Store and iTunes Store daemons, off with the store apps; appstorecomponentsd is in base",- labels: ["com.apple.appstored", "com.apple.itunesstored"],- ),- Group(- name: "signin_followup", byDefault: true,- summary: "Sign-in follow-up and Apple Account setup prompts; apply after first-boot work has settled",- labels: ["com.apple.appleidsetupd", "com.apple.followupd"],- ),- Group(- name: "accounts", byDefault: false,- summary: "Apple Account daemons; with these off the guest cannot sign in to an Apple Account",- labels: ["com.apple.akd", "com.apple.amsaccountsd", "com.apple.appleaccountd"],- ),- ]+ static let groups27 = catalog(base: base27)/// Appendix A of the 2026-10-07 measurement on `svctest-a` (iPhone, 27.0/// 24A435): 137 LaunchDaemons that were loaded at boot and stayed unloaded@@ -210,6 +222,25 @@ enum GuestServiceProfile {"com.apple.wirelessinsightsd",]+ // MARK: - iOS 26++ static let groups26 = catalog(base: base26)++ /// The iOS 27 list mapped onto iPhone 26.6.2 (23G90), measured on `t26-a`+ /// (2026-10-09): every label of `base27` that 26 loads at boot, under the+ /// same name. Of the four jobs only 26 has, the one that runs,+ /// `com.apple.timesync.audioclocksyncd`, stays on: off, it saved no host+ /// CPU. The never-disabled set needed nothing new for 26.+ static let base26: [String] = base27.filter { !notLoadedOn26.contains($0) }++ /// `base27` labels 26.6.2 does not load: five its launchd.plist does not+ /// have, and safetyalertsd, which it limits to hardware a guest is not.+ static let notLoadedOn26: Set<String> = [+ "com.apple.cloudtelemetryd", "com.apple.hybridsearchd", "com.apple.libsqlite3.dbtelemetryd",+ "com.apple.speechmaintenanced", "com.apple.visualintelligenced",+ "com.apple.safetyalertsd",+ ]+// MARK: - Never Disabled/// Jobs the profile refuses to disable, whatever list or group names them.diff --git a/VPhoneDaemon/Tests/LogicTests.swift b/VPhoneDaemon/Tests/LogicTests.swiftindex 81b61eec..f1b89dbd 100644--- a/VPhoneDaemon/Tests/LogicTests.swift+++ b/VPhoneDaemon/Tests/LogicTests.swift@@ -25,6 +25,7 @@ func expectEqual<T: Equatable>(_ actual: T, _ expected: T, _ message: String = "enum LogicTests {static func main() {profileCatalog()+ profileCatalog26()profileSelection()neverDisableEnforcement()reconciliation()@@ -53,8 +54,33 @@ enum LogicTests {expectEqual(groups.map(\.name), ["base", "app_store", "signin_followup", "accounts"])expectEqual(groups.filter(\.byDefault).map(\.name), ["base", "app_store", "signin_followup"])expect(GuestServiceProfile.base27.contains("com.apple.appstorecomponentsd"), "appstorecomponentsd is in base")- expect(GuestServiceProfile.groups(iosMajor: 26) == nil, "no list for iOS 26")+ expect(GuestServiceProfile.groups(iosMajor: 25) == nil, "no list for iOS 25")+ expect(GuestServiceProfile.groups(iosMajor: 28) == nil, "no list for iOS 28")+ expect(GuestServiceProfile.groups(iosMajor: 26) != nil, "a list for iOS 26")expect(GuestServiceProfile.groups(iosMajor: 27) != nil, "a list for iOS 27")+ expectEqual(GuestServiceProfile.supportedMajors, [26, 27])+ }++ static func profileCatalog26() {+ let base26 = GuestServiceProfile.base26+ expectEqual(base26.count, 131, "137 minus six 26.6.2 does not load")+ expectEqual(Set(base26).count, base26.count, "no duplicates")+ expect(Set(base26).isSubset(of: GuestServiceProfile.base27), "26 adds no label of its own")+ expect(GuestServiceProfile.notLoadedOn26.isSubset(of: GuestServiceProfile.base27), "only 27 labels are left out")+ expect(Set(base26).isDisjoint(with: GuestServiceProfile.notLoadedOn26), "what 26 does not load is left out")+ for label in ["com.apple.cloudtelemetryd", "com.apple.hybridsearchd", "com.apple.safetyalertsd"] {+ expect(!base26.contains(label), "\(label) is not in the 26 list")+ }+ let groups = GuestServiceProfile.groups26+ expectEqual(groups.map(\.name), GuestServiceProfile.groups27.map(\.name), "same groups as 27")+ expectEqual(groups.filter(\.byDefault).map(\.name), ["base", "app_store", "signin_followup"])+ expectEqual(groups.first?.labels, base26, "base is the 26 list")+ expectEqual(+ groups.dropFirst().map(\.labels), GuestServiceProfile.groups27.dropFirst().map(\.labels),+ "store, follow-up and account labels are the same on 26",+ )+ let all = groups.flatMap(\.labels)+ expectEqual(Set(all).count, all.count, "no label is in two 26 groups")}static func profileSelection() {@@ -76,8 +102,21 @@ enum LogicTests {expectEqual(allowed?.allowed, ["com.apple.weatherd"], "only catalog labels are reported as allowed")expect(allowed?.labels.contains("com.apple.weatherd") == false, "weatherd kept")- expectEqual(try? GuestServiceProfile.select(profile: "none", iosMajor: 26), GuestServiceProfile.Selection())- expectThrows(.unsupported(iosMajor: 26)) { try GuestServiceProfile.select(profile: "trimmed", iosMajor: 26) }+ let trimmed26 = try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 26)+ expectEqual(trimmed26?.labels.count, 135, "26 trimmed = 131 + 2 store + 2 follow-up")+ expectEqual(trimmed26?.groups, ["base", "app_store", "signin_followup"])+ expect(trimmed26?.refused.isEmpty == true, "the 26 list names nothing never disabled")+ expectEqual(+ (try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 26, extraGroups: ["accounts"]))?.labels.count,+ 138, "accounts adds three on 26",+ )++ expectEqual(try? GuestServiceProfile.select(profile: "none", iosMajor: 25), GuestServiceProfile.Selection())+ expectThrows(.unsupported(iosMajor: 25)) { try GuestServiceProfile.select(profile: "trimmed", iosMajor: 25) }+ expectEqual(+ GuestServiceProfile.Failure.unsupported(iosMajor: 25).description,+ "No trimmed service list for iOS 25; lists exist for iOS 26, 27",+ )expectThrows(.unknownGroup("bogus")) {try GuestServiceProfile.select(profile: "trimmed", iosMajor: 27, extraGroups: ["bogus"])}@@ -96,7 +135,7 @@ enum LogicTests {}static func neverDisableEnforcement() {- for group in GuestServiceProfile.groups27 {+ for group in GuestServiceProfile.groups27 + GuestServiceProfile.groups26 {let overlap = Set(group.labels).intersection(GuestServiceProfile.neverDisable)expect(overlap.isEmpty, "\(group.name) names never-disabled \(overlap.sorted())")}diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swiftindex cf3ccc20..49b8537a 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift@@ -489,7 +489,7 @@ struct VPhoneVirtualMachineTemplateSetupCommand: ParsableCommand {}/// 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).+ /// service profile where vphoned has no list for that version (before iOS 26).static func fitted(_ slimming: VPhoneMachineTemplateSlimming, toIOSVersion iOSVersion: String) throws -> VPhoneMachineTemplateSlimming {do {return try slimming.fitted(toIOSVersion: iOSVersion)diff --git a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swiftindex 27c14665..880b6b42 100644--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift@@ -67,8 +67,8 @@ public struct VPhoneMachineTemplateSlimming: Codable, Equatable, Hashable, Senda/// 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+ /// boot. So on another version (iOS 25 and earlier) 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",diff --git a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swift b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swiftindex 1e060d87..f603a278 100644--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swift+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneTemplateSlimmingRequest.swift@@ -66,7 +66,7 @@ public struct VPhoneTemplateSlimmingRequest: Equatable, Sendable {/// `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]+ public static let trimmedServiceProfileMajors = [26, 27]/// The removable system apps a slimmed template drops (list C of the/// template trim plan), each verified to stay removed across a respringdiff --git a/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift b/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swiftindex 77b3ee95..9d7d6e77 100644--- a/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift@@ -131,23 +131,46 @@ struct TemplateSlimmingRequestTests {#expect(identifiers.count == requests.count)}+ @Test func `the trimmed profile stays on the iOS versions vphoned has a service list for`() throws {+ let slimming = try Request().resolve()+ #expect(VPhoneTemplateSlimmingRequest.trimmedServiceProfileMajors == [26, 27])+ for version in ["26.6.2", "26.0", "27.0", "27.0.1"] {+ #expect(try slimming.fitted(toIOSVersion: version) == slimming)+ }+ let accounts = try Request(accountsOff: true).resolve()+ #expect(try accounts.fitted(toIOSVersion: "26.6.2") == accounts)+ #expect(try accounts.fitted(toIOSVersion: "27.0") == accounts)+ }++ @Test func `an iOS 26 key keeps the trimmed profile and differs from its untrimmed one`() throws {+ let trimmed = try Request().resolve().fitted(toIOSVersion: "26.6.2")+ let none = try Request(serviceProfile: "none").resolve().fitted(toIOSVersion: "26.6.2")+ #expect(trimmed.serviceProfile == "trimmed")+ #expect(none.serviceProfile == "none")+ #expect(trimmed.trimTier == none.trimTier)+ #expect(trimmed.removedApps == none.removedApps)+ #expect(+ try MachineTemplateKeyTests.key(slimming: trimmed).identifier+ != MachineTemplateKeyTests.key(slimming: none).identifier,+ )+ }+@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 on25 = try slimming.fitted(toIOSVersion: "25.4")+ #expect(on25.serviceProfile == "none")+ #expect(on25.serviceGroups.isEmpty)+ #expect(on25.trimTier == slimming.trimTier)+ #expect(on25.removedApps == slimming.removedApps)+ #expect(try on25.fitted(toIOSVersion: "25.4") == on25)let none = try Request(serviceProfile: "none").resolve()+ #expect(try none.fitted(toIOSVersion: "25.4") == none)#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)+ #expect(throws: VPhoneTemplateSlimmingError.self) { try slimming.fitted(toIOSVersion: "25.4") }+ #expect(try slimming.fitted(toIOSVersion: "26.6.2") == slimming)}}