Run a virtual iPhone on an Apple Silicon Mac.
Swift
Skip service trimming on unsupported iOS versions
Phineas Guo60d5bd9324ce
diff --git a/Research/Host/machine_templates.md b/Research/Host/machine_templates.mdindex d09307d3..11fe7b2f 100644--- a/Research/Host/machine_templates.md+++ b/Research/Host/machine_templates.md@@ -378,12 +378,29 @@ one for iOS 26 and 27 (`GuestServiceProfile.supportedMajors`, mirrored byof the setup boot. So `VPhoneMachineTemplateSlimming.fitted(toIOSVersion:)`turns `trimmed` into `none` on such a version, where the key is made(`VPhoneMachineTemplateKeys.key`) and in `vm template setup`, and-`--accounts-off`, whose group is part of the list, is refused there before-anything is built. iOS 26 templates had `services none` until the 26 list+`--accounts-off`, whose group is part of the list, is skipped too, with a+notice on stderr to keep JSON reports clean. iOS 26 templates had `services+none` until the 26 listexisted (2026-10-09); they now take `trimmed` like iOS 27 ones, so their keychanges and a 26 template built before is no longer found for a defaultcreate, only for `--service-profile none`.+Launchpad leaves its service switch enabled and its arguments unchanged+(issue #679, 2026-10-23). A known unsupported version in the selected IPSW+name is only an advisory: New Machine shows the compatibility note and an+alert, without blocking creation or changing file/app choices. An unknown+name makes no support claim. The actual decision is made by the existing+`fitted(toIOSVersion:)` path, from IPSW manifests/template records for key+resolution and from `restore-info.json` for standalone setup, never from a+filename. Both paths use services `none` and no extra groups on unsupported+versions, so the template key matches what setup does and retries converge.+The guest's direct `services.profile.apply trimmed` RPC remains strict.++Validated with 16 core slimming tests and CLI `find --json` against manifest+fixtures with misleading names: 18.6.2 in a 27.0-named IPSW gives `none`+and no groups with a stderr notice; 26.0 in an 18.6.2-named IPSW keeps+`trimmed` and `accounts`. JSON output remains parseable in both cases.+`--slim off` still has a setup boot: skipping Setup and waiting forfirst-boot work are not slimming. Without them every clone would start at theSetup screen and write its own first-boot state (P2 measured 3.2 GB per clonediff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swiftindex c8f868d6..4c1e3987 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneMachineTemplateKeys.swift@@ -86,12 +86,7 @@ enum VPhoneMachineTemplateKeys {)// 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)- }+ let fitted = try self.fitted(slimming, toIOSVersion: ios.version)return VPhoneMachineTemplateKey(device: device,iOSVersion: ios.version,@@ -109,6 +104,21 @@ enum VPhoneMachineTemplateKeys {)}+ /// Use manifest/restore-record versions, never a source filename. Keep+ /// notices off stdout so `vm template find --json` remains valid JSON.+ static func fitted(_ slimming: VPhoneMachineTemplateSlimming, toIOSVersion version: String) throws -> VPhoneMachineTemplateSlimming {+ do {+ let fitted = try slimming.fitted(toIOSVersion: version)+ if fitted.serviceProfile != slimming.serviceProfile {+ let note = "note: skipping service trimming (including extra service groups): no trimmed service list for iOS \(version); keeping services\n"+ FileHandle.standardError.write(Data(note.utf8))+ }+ return fitted+ } catch let error as VPhoneTemplateSlimmingError {+ throw ValidationError(error.description)+ }+ }+// MARK: Builds of a request/// The device and builds of the two IPSWs when both are local files ordiff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swiftindex 49b8537a..c7ac6a92 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineTemplateCommand.swift@@ -418,7 +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)+ wanted = try VPhoneMachineTemplateKeys.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")}@@ -459,7 +459,7 @@ struct VPhoneVirtualMachineTemplateSetupCommand: ParsableCommand {}let request = try slimming.requestif !request.isEmpty {- let wanted = try Self.fitted(slimming.resolve(), toIOSVersion: record.key.iOSVersion)+ let wanted = try VPhoneMachineTemplateKeys.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.")}@@ -488,15 +488,6 @@ struct VPhoneVirtualMachineTemplateSetupCommand: ParsableCommand {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 (before 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 880b6b42..b1a8e836 100644--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneMachineTemplateKey.swift@@ -68,22 +68,16 @@ public struct VPhoneMachineTemplateSlimming: Codable, Equatable, Hashable, Senda/// ``VPhoneTemplateSlimmingRequest/trimmedServiceProfileMajors`` and/// refuses the profile elsewhere, after the restore and most of the setup/// 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.+ /// the key as in the setup boot. Extra groups (`--accounts-off`) are+ /// skipped too: they need the same version-specific list.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 = selffitted.serviceProfile = "none"+ fitted.serviceGroups = []return fitted}diff --git a/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift b/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swiftindex 9d7d6e77..761380d5 100644--- a/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Bundle/TemplateSlimmingRequestTests.swift@@ -168,9 +168,19 @@ struct TemplateSlimmingRequestTests {#expect(try none.fitted(toIOSVersion: "26.6.2") == none)}- @Test func `accounts-off is refused on an iOS without the trimmed service list`() throws {+ @Test func `unsupported iOS skips services and accounts without changing file or app trimming`() throws {let slimming = try Request(accountsOff: true).resolve()- #expect(throws: VPhoneTemplateSlimmingError.self) { try slimming.fitted(toIOSVersion: "25.4") }+ let withoutServices = try Request(serviceProfile: "none").resolve()+ for version in ["18.6.2", "25.4", "28.0"] {+ let fitted = try slimming.fitted(toIOSVersion: version)+ #expect(fitted == withoutServices)+ #expect(try fitted.fitted(toIOSVersion: version) == fitted)+ #expect(+ try MachineTemplateKeyTests.key(slimming: fitted).identifier+ == MachineTemplateKeyTests.key(slimming: withoutServices).identifier,+ )+ }#expect(try slimming.fitted(toIOSVersion: "26.6.2") == slimming)+ #expect(try slimming.fitted(toIOSVersion: "27.0") == slimming)}}diff --git a/VPhoneLaunchpad/Tests/TemplatesTests.sh b/VPhoneLaunchpad/Tests/TemplatesTests.shindex 67f3b748..464276a0 100755--- a/VPhoneLaunchpad/Tests/TemplatesTests.sh+++ b/VPhoneLaunchpad/Tests/TemplatesTests.sh@@ -7,6 +7,7 @@ trap '/bin/rm -rf "$temporary"' EXIT/usr/bin/xcrun swiftc -swift-version 6 -strict-concurrency=complete \-parse-as-library \+ "$launchpad/VPhoneLaunchpad/IPSWCache/VPhoneLaunchpadIPSW.swift" \"$launchpad/VPhoneLaunchpadShared/VPhoneLaunchpadBundleStore.swift" \"$launchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachine.swift" \"$launchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift" \diff --git a/VPhoneLaunchpad/Tests/TemplatesTests.swift b/VPhoneLaunchpad/Tests/TemplatesTests.swiftindex 099d72c2..0a61152e 100644--- a/VPhoneLaunchpad/Tests/TemplatesTests.swift+++ b/VPhoneLaunchpad/Tests/TemplatesTests.swift@@ -5,6 +5,7 @@ import Foundationstruct TemplatesTests {static func main() async throws {slimmingArguments()+ slimmingCompatibility()commandArguments()patchOverrides()creationPlan()@@ -88,6 +89,32 @@ struct TemplatesTests {// MARK: - Commands+ static func slimmingCompatibility() {+ for source in [+ "https://example.invalid/iPhone17,3_18.6.2_22G100_Restore.ipsw?download=1",+ "/tmp/iPhone17,3_25.4_22G100_Restore.ipsw",+ "/tmp/iPhone17,3_28.0_25A1_Restore.ipsw",+ ] {+ precondition(VPhoneLaunchpadSlimming.warnsAboutServiceTrimming(iphoneSource: source), source)+ }+ for source in [+ "https://example.invalid/iPhone17,3_26.6.2_23G90_Restore.ipsw",+ "/tmp/iPad_Pro_M4_27.0.1_24A446_Restore.ipsw",+ "file:///tmp/iPhone17_3_27.0_24A435_Restore-3c6d6dc0803d.ipsw",+ "/tmp/custom.ipsw", "https://example.invalid/download?id=26", "",+ ] {+ precondition(!VPhoneLaunchpadSlimming.warnsAboutServiceTrimming(iphoneSource: source), source)+ }+ let requested = VPhoneLaunchpadSlimming()+ let request = VPhoneLaunchpadTemplateCommands.Request(+ iphoneSource: "/tmp/iPhone17,3_18.6.2_22G100_Restore.ipsw", cloudOSSource: "cloud",+ preset: "standard", diskSizeGB: 64, slimming: requested,+ )+ precondition(VPhoneLaunchpadTemplateCommands.find(request).contains("--accounts-off"), "Filename hints do not filter Find options")+ precondition(VPhoneLaunchpadTemplateCommands.setup("ios18", requested).contains("--accounts-off"), "The CLI decides from real firmware records")+ print("Slimming warning tests passed")+ }+static func commandArguments() {var slimming = VPhoneLaunchpadSlimming()slimming.trimsServices = falsediff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstringsindex 7f202c09..ba8946a2 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Localizable.xcstrings@@ -1,6 +1,15 @@{"sourceLanguage" : "en","strings" : {+ "Service trimming is available only for iOS 26 and iOS 27." : {+ "localizations" : {+ "en" : { "stringUnit" : { "state" : "translated", "value" : "Service trimming is available only for iOS 26 and iOS 27." } },+ "ja" : { "stringUnit" : { "state" : "translated", "value" : "サービスの削減は iOS 26 と iOS 27 でのみ利用できます。" } },+ "ko" : { "stringUnit" : { "state" : "translated", "value" : "서비스 줄이기는 iOS 26 및 iOS 27에서만 사용할 수 있습니다." } },+ "vi" : { "stringUnit" : { "state" : "translated", "value" : "Chỉ iOS 26 và iOS 27 hỗ trợ tinh gọn dịch vụ." } },+ "zh-Hans" : { "stringUnit" : { "state" : "translated", "value" : "仅 iOS 26 和 iOS 27 支持服务裁剪。" } }+ }+ },"An Apple TV is restored on its own, with keys of its own. Templates are made for iPhone and iPad." : {"localizations" : {"en" : { "stringUnit" : { "state" : "translated", "value" : "An Apple TV is restored on its own, with keys of its own. Templates are made for iPhone and iPad." } },diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swiftindex d857de07..beacaf6c 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadNewMachineView.swift@@ -59,6 +59,7 @@ struct VPhoneLaunchpadNewMachineView: View {/// The page the Advanced Options sheet shows: the one last shown.@State private var page = Page.hardware@State private var showsAdvanced = false+ @State private var showsServiceTrimmingNotice = false/// The basic page, then the advanced ones.enum Page: Hashable {@@ -92,6 +93,11 @@ struct VPhoneLaunchpadNewMachineView: View {return selectedPairing.map { ($0.ios.url, ownCloudOS?.url ?? $0.recommendedCloudOS.url) }}+ private var warnsAboutServiceTrimming: Bool {+ slimming.slim && slimming.trimsServices+ && VPhoneLaunchpadSlimming.warnsAboutServiceTrimming(iphoneSource: sources?.0 ?? "")+ }+/// The release's own cloudOS, when chosen and the pairing has one.private var ownCloudOS: VPhoneLaunchpadFirmwareCatalog.Image? {usesOwnCloudOS && !usesCustomSources ? selectedPairing?.matchingCloudOS : nil@@ -248,6 +254,18 @@ struct VPhoneLaunchpadNewMachineView: View {.sheet(isPresented: $showsAdvanced) {advancedSheet.environment(model)+ .alert("Service trimming is available only for iOS 26 and iOS 27.", isPresented: $showsServiceTrimmingNotice) {+ Button("OK", role: .cancel) {}+ }+ }+ .alert("Service trimming is available only for iOS 26 and iOS 27.", isPresented: Binding(+ get: { showsServiceTrimmingNotice && !showsAdvanced },+ set: { showsServiceTrimmingNotice = $0 },+ )) {+ Button("OK", role: .cancel) {}+ }+ .onChange(of: warnsAboutServiceTrimming) { _, warns in+ showsServiceTrimmingNotice = warns}// Each bundle version has its own firmware pairings and patch sets..task(id: bundleVersion) { await loadCatalog() }@@ -310,9 +328,9 @@ struct VPhoneLaunchpadNewMachineView: View {hardwarePageadvancedSections(.hardware)case .template:- VPhoneLaunchpadSlimmingSections(part: .template, usesTemplate: $usesTemplate, templateAvailable: templateAvailable, slimming: $slimming, forAppleTV: isAppleTVGuest, forRestoredSystem: patches.customisesRestoredSystem)+ VPhoneLaunchpadSlimmingSections(part: .template, usesTemplate: $usesTemplate, templateAvailable: templateAvailable, slimming: $slimming, warnsAboutServiceTrimming: warnsAboutServiceTrimming, forAppleTV: isAppleTVGuest, forRestoredSystem: patches.customisesRestoredSystem)case .slimming:- VPhoneLaunchpadSlimmingSections(part: .slimming, usesTemplate: $usesTemplate, templateAvailable: templateAvailable, slimming: $slimming, forAppleTV: isAppleTVGuest, forRestoredSystem: patches.customisesRestoredSystem)+ VPhoneLaunchpadSlimmingSections(part: .slimming, usesTemplate: $usesTemplate, templateAvailable: templateAvailable, slimming: $slimming, warnsAboutServiceTrimming: warnsAboutServiceTrimming, forAppleTV: isAppleTVGuest, forRestoredSystem: patches.customisesRestoredSystem)case .firmware:bundleSectionfirmwareSourceSectiondiff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadSlimmingView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadSlimmingView.swiftindex 5f4bd66d..d0f5a6c5 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadSlimmingView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadSlimmingView.swift@@ -15,6 +15,7 @@ struct VPhoneLaunchpadSlimmingSections: View {/// IPSWs, which the list cannot be matched against.var templateAvailable: Bool?@Binding var slimming: VPhoneLaunchpadSlimming+ let warnsAboutServiceTrimming: Bool/// An Apple TV is restored on its own and not slimmed: templates and/// slimming drive iOS Setup Assistant and its apps.var forAppleTV = false@@ -138,7 +139,10 @@ struct VPhoneLaunchpadSlimmingSections: View {} footer: {VStack(alignment: .leading, spacing: 4) {Text("About 140 launch daemons a research machine rarely needs, Apple Account's among them.")- if slimming.trimsServices {+ if warnsAboutServiceTrimming {+ Text("Service trimming is available only for iOS 26 and iOS 27.")+ }+ if !warnsAboutServiceTrimming, slimming.trimsServices {// terminusd and the nano daemons are among them.Text("A phone with these services off cannot pair an Apple Watch.")}diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swiftindex 75f45901..b4b582e7 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadTemplates.swift@@ -78,6 +78,19 @@ nonisolated struct VPhoneLaunchpadSlimming: Hashable, Sendable {// MARK: Effective values+ /// A UI hint only. The Core Bundle fits services using the real firmware+ /// version; an unknown or misleading filename must never change options.+ static func warnsAboutServiceTrimming(iphoneSource: String) -> Bool {+ let source = iphoneSource.trimmingCharacters(in: .whitespacesAndNewlines)+ let url = source.contains("://") ? URL(string: source) : URL(fileURLWithPath: source)+ guard let name = url?.lastPathComponent,+ name.hasPrefix("iPhone") || name.hasPrefix("iPad"),+ let facts = VPhoneLaunchpadIPSW(fileName: name),+ let major = facts.version.split(separator: ".").first.flatMap({ Int($0) })+ else { return false }+ return ![26, 27].contains(major)+ }+/// The kept languages as the CLI takes them, or nil for the default (or/// when no tier removes language data).var languagesArgument: String? {