Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Merge upstream/main into appletv-4thgen

Guilherme Rambo72c3658fa5b2
diff --cc VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwarePatchSetCatalog.swift
index fee6eead,9955dfb6..4aee5869
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwarePatchSetCatalog.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwarePatchSetCatalog.swift
@@@ -68,8 -68,8 +68,8 @@@ public enum FirmwarePatchSetCatalog
Set(FirmwareKernelFridaPatchSet.manifest.patches.map(\.identifier))
.union(hypervisorConcealmentPatches)
.union(experimentalIdentityPatches)
- .union([FirmwareGuestSystemPatchSet.otaUserland, FirmwareGuestSystemPatchSet.homePodTopCap, FirmwareGuestSystemPatchSet.homePodSetupBypass, FirmwareGuestSystemPatchSet.homePodAudioProduct, FirmwareGuestSystemPatchSet.homePodWelcome, FirmwareGuestSystemPatchSet.homePodSiriSpeech, FirmwareGuestSystemPatchSet.homePodOTAUserland, FirmwareGuestSystemPatchSet.homePodSoundGlow])
+ .union([FirmwareGuestSystemPatchSet.otaUserland, FirmwareGuestSystemPatchSet.homePodTopCap, FirmwareGuestSystemPatchSet.homePodSetupBypass, FirmwareGuestSystemPatchSet.homePodAudioProduct, FirmwareGuestSystemPatchSet.homePodWelcome, FirmwareGuestSystemPatchSet.homePodSiriSpeech, FirmwareGuestSystemPatchSet.homePodOTAUserland, FirmwareGuestSystemPatchSet.homePodSoundGlow, FirmwareGuestSystemPatchSet.homePodCryptexStaging, FirmwareGuestSystemPatchSet.homePodCryptexClass, FirmwareGuestSystemPatchSet.homePodAdHocInstall])
- .union([FirmwareKernelCustomFirmwarePatchSet.tvTPROPagers, misTrustAuthPatch, FirmwareGuestSystemPatchSet.settingsRootRows, FirmwareGuestSystemPatchSet.settingsSoftwareUpdate, FirmwareGuestSystemPatchSet.tvTPRO, FirmwareGuestSystemPatchSet.tvOTAUserland])
+ .union([FirmwareKernelCustomFirmwarePatchSet.tvTPROPagers, misTrustAuthPatch, FirmwareGuestSystemPatchSet.settingsRootRows, FirmwareGuestSystemPatchSet.settingsSoftwareUpdate, FirmwareGuestSystemPatchSet.tvTPRO, FirmwareGuestSystemPatchSet.tvOTAUserland, FirmwareGuestSystemPatchSet.tvSetupDisplayLookup, FirmwareGuestSystemPatchSet.tvLegacySetup])
/// ProMotion: the 120 Hz timing for the paravirtual display.
///
@@@ -226,7 -226,7 +226,7 @@@
freshly restored 26.4 guest does not survive. The HomePod-only top cap is off.
""",
patchSets: bundledReferences,
- selection: .block([FirmwareGuestSystemPatchSet.tvLegacySetup, FirmwareGuestSystemPatchSet.tvSetupDisplayLookup, FirmwareGuestSystemPatchSet.homePodTopCap, FirmwareGuestSystemPatchSet.homePodSetupBypass, FirmwareGuestSystemPatchSet.homePodAudioProduct, FirmwareGuestSystemPatchSet.homePodWelcome, FirmwareGuestSystemPatchSet.homePodSiriSpeech, FirmwareGuestSystemPatchSet.homePodOTAUserland, FirmwareGuestSystemPatchSet.homePodSoundGlow]),
- selection: .block([FirmwareGuestSystemPatchSet.homePodTopCap, FirmwareGuestSystemPatchSet.homePodSetupBypass, FirmwareGuestSystemPatchSet.homePodAudioProduct, FirmwareGuestSystemPatchSet.homePodWelcome, FirmwareGuestSystemPatchSet.homePodSiriSpeech, FirmwareGuestSystemPatchSet.homePodOTAUserland, FirmwareGuestSystemPatchSet.homePodSoundGlow, FirmwareGuestSystemPatchSet.homePodCryptexStaging, FirmwareGuestSystemPatchSet.homePodCryptexClass, FirmwareGuestSystemPatchSet.homePodAdHocInstall]),
++ selection: .block([FirmwareGuestSystemPatchSet.tvLegacySetup, FirmwareGuestSystemPatchSet.tvSetupDisplayLookup, FirmwareGuestSystemPatchSet.homePodTopCap, FirmwareGuestSystemPatchSet.homePodSetupBypass, FirmwareGuestSystemPatchSet.homePodAudioProduct, FirmwareGuestSystemPatchSet.homePodWelcome, FirmwareGuestSystemPatchSet.homePodSiriSpeech, FirmwareGuestSystemPatchSet.homePodOTAUserland, FirmwareGuestSystemPatchSet.homePodSoundGlow, FirmwareGuestSystemPatchSet.homePodCryptexStaging, FirmwareGuestSystemPatchSet.homePodCryptexClass, FirmwareGuestSystemPatchSet.homePodAdHocInstall]),
)
/// The iOS payloads, hooks and shared-cache patches an Apple TV guest has no
diff --cc VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwareGuestPatchResolutionTests.swift
index 9188d179,a3e725ce..6aa75303
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwareGuestPatchResolutionTests.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwareGuestPatchResolutionTests.swift
@@@ -12,35 -12,62 +12,91 @@@ import VPhonePatchKi
@Suite("Guest patch resolution")
struct FirmwareGuestPatchResolutionTests {
+ @Test func `TV legacy setup is limited to the 27 point 2 4K preset`() throws {
+ let identifier = FirmwareGuestSystemPatchSet.tvLegacySetup
+ for version in ["26.6", "27.0", "27.1", "27.2", "27.3"] {
+ for preset in FirmwarePatchSetCatalog.builtInPresets {
+ let plan = try VPhonePatchPlan.resolve(
+ preset: preset, patchSets: FirmwarePatchSetCatalog.bundled,
+ iOSBase: VPhoneVersion(version), cloudOS: VPhoneVersion("26.4"),
+ )
+ #expect(plan.isEnabled(identifier) == (version == "27.2" && preset.identifier == VPhonePatchPreset.tvOS4KIdentifier))
+ }
+ }
+ #expect(FirmwareGuestPatchResolution.unvalidatedTVGuestPatches(enabled: [identifier], arm64eUserland: true).isEmpty)
+ #expect(FirmwareGuestPatchResolution.unvalidatedHomePodGuestPatches(enabled: [identifier]) == [identifier])
+ #expect(FirmwareGuestPatchResolution.guestPatchesOff(selectionEnabled: []).contains(identifier))
+ }
+
+ @Test func `new TV setup display repair remains opt in`() throws {
+ let identifier = FirmwareGuestSystemPatchSet.tvSetupDisplayLookup
+ for preset in FirmwarePatchSetCatalog.builtInPresets {
+ let plan = try VPhonePatchPlan.resolve(
+ preset: preset, patchSets: FirmwarePatchSetCatalog.bundled,
+ iOSBase: VPhoneVersion("27.2"), cloudOS: VPhoneVersion("26.4"),
+ )
+ #expect(!plan.isEnabled(identifier))
+ }
+ #expect(FirmwareGuestPatchResolution.unvalidatedTVGuestPatches(enabled: [identifier], arm64eUserland: true).isEmpty)
+ #expect(FirmwareGuestPatchResolution.unvalidatedHomePodGuestPatches(enabled: [identifier]) == [identifier])
+ }
+
+ @Test func `HomePod persona lookup uses isolated tvOS deployment and follows selection`() throws {
+ let identifier = FirmwareGuestSystemPatchSet.installCoordinationPersona
+ for base in ["26.4", "27.0", "27.2", "28.0"] {
+ let plan = try VPhonePatchPlan.resolve(
+ preset: FirmwarePatchSetCatalog.homePodMiniPreset, patchSets: FirmwarePatchSetCatalog.bundled,
+ iOSBase: VPhoneVersion(base), cloudOS: VPhoneVersion("26.4"),
+ )
+ #expect(plan.isEnabled(identifier) == base.hasPrefix("27."))
+ #expect(!plan.isEnabled("system-launchdaemons-boot-environment"))
+ #expect(!plan.isEnabled(FirmwareGuestSystemPatchSet.arm64eX1LaunchdBootstrap))
+ #expect(!plan.isEnabled("system-launchd-boot-jetsam_panic_guard_bypass"))
+ }
+ let disabled = try VPhonePatchPlan.resolve(
+ preset: FirmwarePatchSetCatalog.homePodMiniPreset, patchSets: FirmwarePatchSetCatalog.bundled,
+ iOSBase: VPhoneVersion("27.2"), cloudOS: VPhoneVersion("26.4"), blocked: [identifier],
+ )
+ #expect(!disabled.isEnabled(identifier))
+ #expect(FirmwareGuestPatchResolution.guestPatchesOff(selectionEnabled: disabled.enabled).contains(identifier))
+ #expect(FirmwareGuestPatchResolution.unvalidatedHomePodGuestPatches(enabled: [identifier]).isEmpty)
+ #expect(FirmwareGuestPatchResolution.unvalidatedTVGuestPatches(enabled: [identifier], arm64eUserland: true) == [identifier])
+ }
+
+ @Test(arguments: [FirmwareGuestSystemPatchSet.homePodCryptexStaging, FirmwareGuestSystemPatchSet.homePodCryptexClass, FirmwareGuestSystemPatchSet.homePodAdHocInstall])
+ func `HomePod developer compatibility is independent of the iPhone environment and reversible in selection`(identifier: String) throws {
+ for base in ["26.4", "27.0", "27.2", "28.0"] {
+ for preset in FirmwarePatchSetCatalog.builtInPresets {
+ let plan = try VPhonePatchPlan.resolve(
+ preset: preset, patchSets: FirmwarePatchSetCatalog.bundled,
+ iOSBase: VPhoneVersion(base), cloudOS: VPhoneVersion("26.4"),
+ )
+ #expect(plan.isEnabled(identifier) == (base.hasPrefix("27.")
+ && preset.identifier == VPhonePatchPreset.homePodMiniIdentifier))
+ if plan.isEnabled(identifier) {
+ #expect(!plan.isEnabled("system-launchdaemons-boot-environment"))
+ let disabled = try VPhonePatchPlan.resolve(
+ preset: preset, patchSets: FirmwarePatchSetCatalog.bundled,
+ iOSBase: VPhoneVersion(base), cloudOS: VPhoneVersion("26.4"),
+ blocked: [identifier],
+ )
+ #expect(!disabled.isEnabled(identifier))
+ #expect(FirmwareGuestPatchResolution.guestPatchesOff(selectionEnabled: disabled.enabled).contains(identifier))
+ }
+ }
+ }
+ #expect(FirmwareGuestPatchResolution.unvalidatedHomePodGuestPatches(enabled: [identifier]).isEmpty)
+ #expect(FirmwareGuestPatchResolution.unvalidatedTVGuestPatches(enabled: [identifier], arm64eUserland: true) == [identifier])
+ let declaration = try #require(FirmwarePatchSetCatalog.allDeclarations.first { $0.identifier == identifier })
+ let expectedTarget: VPhonePatchTarget = switch identifier {
+ case FirmwareGuestSystemPatchSet.homePodCryptexStaging: .guestExecutable(path: "/usr/libexec/cryptexd")
+ case FirmwareGuestSystemPatchSet.homePodAdHocInstall: .guestExecutable(path: "/usr/libexec/installd")
+ default: .prebootDeviceTree
+ }
+ #expect(declaration.target == expectedTarget)
+ #expect(!declaration.bootEssential)
+ }
+
@Test(arguments: [FirmwareGuestSystemPatchSet.homePodOTAUserland, FirmwareGuestSystemPatchSet.homePodSoundGlow])
func `HomePod OTA and Sound Glow require 27 point 2 and stay out of other presets`(identifier: String) throws {
for version in ["26.6", "27.0", "27.1", "27.2", "27.3"] {
diff --cc VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swift
index 514f15f8,bb7a6cb1..2848faad
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swift
@@@ -242,8 -242,9 +242,11 @@@ struct FirmwarePatchSetCatalogTests
&& $0.identifier != FirmwareGuestSystemPatchSet.homePodAudioProduct
&& $0.identifier != FirmwareGuestSystemPatchSet.homePodOTAUserland
&& $0.identifier != FirmwareGuestSystemPatchSet.homePodSoundGlow
+ && $0.identifier != FirmwareGuestSystemPatchSet.tvSetupDisplayLookup
+ && $0.identifier != FirmwareGuestSystemPatchSet.tvLegacySetup
+ && $0.identifier != FirmwareGuestSystemPatchSet.homePodCryptexStaging
+ && $0.identifier != FirmwareGuestSystemPatchSet.homePodCryptexClass
+ && $0.identifier != FirmwareGuestSystemPatchSet.homePodAdHocInstall
&& $0.applicability.matches(iOSBase: version, cloudOS: cloud)
}.map(\.identifier))
#expect(experimental.enabled.subtracting(standard.enabled) == applicableManual)
diff --cc VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index c64a11e0,f722d9b0..ff2474c6
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@@ -1895,41 -1990,7 +1997,39 @@@ struct VPhoneCustomFirmwareInstaller
}
}
+ let tvLegacySetup = FirmwareGuestSystemPatchSet.tvLegacySetup
+ let tvSetupFlags = CustomFirmwareTVSetup.relativePath
+ isolate([tvLegacySetup]) {
+ if (version == "27.2" || version.hasPrefix("27.2.")), on(tvLegacySetup), guestDevice.family == .appleTV {
+ try patchCopy(
+ of: tvSetupFlags, in: system, work: work,
+ verb: "patch-tv-setup", backupSafe: backupSafe(tvLegacySetup),
+ )
+ live.insert(tvLegacySetup)
+ } else if try revertCopy(of: tvSetupFlags, in: system) {
+ print(" [+] \(tvLegacySetup): restored CompanionServices feature flags")
+ } else if priorGuest.contains(tvLegacySetup) {
+ print(" [!] \(tvLegacySetup): no backup to revert (not revertible)")
+ live.insert(tvLegacySetup)
+ }
+ }
+
+ let tvSetupLookup = FirmwareGuestSystemPatchSet.tvSetupDisplayLookup
+ let tvSetupBackground = "Applications/SetupBackground.app/SetupBackground"
+ isolate([tvSetupLookup]) {
+ if on(tvSetupLookup), guestDevice.family == .appleTV {
+ if try patchTVSetupDisplayLookup(system: system, work: work, backupSafe: backupSafe(tvSetupLookup)) {
+ live.insert(tvSetupLookup)
+ }
+ } else if try revertMachO(system: system, work: work, path: tvSetupBackground) {
+ print(" [+] \(tvSetupLookup): restored SetupBackground from backup")
+ } else if priorGuest.contains(tvSetupLookup) {
+ print(" [!] \(tvSetupLookup): off now but no backup to revert (not revertible)")
+ live.insert(tvSetupLookup)
+ }
+ }
+
- let personaPatch = FirmwareGuestSystemPatchSet.installCoordinationPersona
- let personaMarker = String(FirmwareGuestSystemPatchSet.installCoordinationPersonaMarker.dropFirst())
- isolate([personaPatch]) {
+ if !isHomePod { isolate([personaPatch]) {
// Undo the experimental entitlement-only patch if this machine
// received it. Platform Protobox profiles ignore that exception.
let proxy = "System/Library/PrivateFrameworks/InstallCoordination.framework/Support/installcoordination_proxy"
diff --cc VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/homepod-mini.plist
index d8b0e9d4,812bc346..ef66455f
--- a/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/homepod-mini.plist
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/homepod-mini.plist
@@@ -114,10 -114,7 +114,9 @@@
<string>system-diskimagesiod-cfw-is_mount_complete</string>
<string>system-extensions-boot-gpu_bundle</string>
<string>system-tv-exp-ota_userland</string>
+ <string>system-setupbackground-exp-pineboard_lookup</string>
+ <string>system-tv-exp-legacy_setup</string>
<string>system-fsck-boot-arm64e_x1_bootstrap</string>
- <string>system-installcoordination_proxy-cfw-persona_lookup</string>
<string>system-jetsamproperties-cfw-disable_allowed</string>
<string>system-launchd-boot-arm64e_x1_bootstrap</string>
<string>system-launchd-boot-jetsam_panic_guard_bypass</string>
diff --cc VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift
index 9894f9bc,bd35c907..a28aa6ec
--- a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift
+++ b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift
@@@ -567,21 -576,8 +576,21 @@@ public enum VPhoneFirmwareCatalog
size: 4_831_838_208,
key: "L3wZrfSYx2pFDbJSYtEteNDspB26qBv0lxLlkWrKTYk=",
baseVersion: "26.6",
- minimumHostMacOS: 27,
+ minimumHostMacOS: VPhoneOTARelease.lzravenMinimumMacOS,
),
+ // Pallas SoftwareUpdate response, 2026-10-23: J265AP's only release
+ // is the 27.2 beta. The 24K6120 asset alias points to this same archive;
+ // use its restore build, 24K120, as with HomePod 27.2.
+ .init(
+ productType: "AppleTV18,1",
+ version: "27.2",
+ build: "24K120",
+ url: "https://updates.cdn-apple.com/2026FallFCS/a0d11961-e437-45c7-8252-2d62f7e057b6/com_apple_MobileAsset_SoftwareUpdate/c6553d1b2d6e080adcd92fd8281e36a47dc870e22fb9d0ac057b4489916bcd9c.aea",
+ size: 5_234_491_392,
+ key: "B/S/c74WZgPJLoJc7BDr+IxDjtQZ2H8gUwWp7kq9RpI=",
+ baseVersion: "26.6",
+ minimumHostMacOS: 27,
+ ),
// HomePod's newer software ships as a full ZIP OTA. Keep its own
// 27.0 restore IPSW as the base; the OTA supplies only the userland
// and board tree, while the boot chain remains cloudOS 26.4.