Run a virtual iPhone on an Apple Silicon Mac.
Swift
Apply selected Preboot identity during guest environment updates
Phineas Guob8e9ea7c310a
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex e5642060..22fea52f 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -3261,3 +3261,21 @@ in `fw patch`. The SEP firmware (`sep-firmware.vphone600.RELEASE.im4p`, sent asbefore keep Apple's SEP ROM; `vm config --seprom opensep|apple` switches onewithout a restore. `Firmware/opensep_sep_rom.md` has the contract and thevalidation.++## Apply selected Preboot identity during guest updates (2026-10-21)++`preboot-exp-devicetree_identity` was advertised as an `update-environment`+guest patch but its installer call enabled identity only for full installs.+Launchpad's Apply to Guest therefore completed with the identity still pending.+Environment updates now run the existing identity rewrite when the current+resolved plan selects it, using the installed tree without a restore directory.+The patch bytes, presets, board-presenting guest guard, post-identity repair+backup and existing off-state behavior are unchanged. This fixes the same+delivery path for CLI updates, bundle changes and template guest-patch steps;+other Preboot repairs already used it. It does not enable the eight firmware+DeviceTree identity edits or establish that Apple will deliver Photos models.++Validation on `upstream/main` `047642f8` (2.10.1): 77 existing tests in eight+suites pass, covering guest device trees, patch resolution/catalogue/drift,+board audio, microphone-array removal, iPhone product properties and haptics.+The complete `VPhone` Debug build and bundle admission also pass.diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swiftindex ba10510a..4f9741d4 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift@@ -408,10 +408,8 @@ struct VPhoneCustomFirmwareInstaller {)}}- // The Preboot identity patches go with the boot chain and belong to a- // full install only. The device tree repairs are the exception: a VM- // restored before the board audio repair or the haptics removal has no- // other way to get them, since `fw patch` does not run again.+ // The selected Preboot identity can also reach an installed guest through+ // an environment update, using its installed tree without a restore.// A guest that has booted keeps the MobileGestalt answers it cached from// the old tree on its Data volume, which the host cannot reach. vphoned// drops that cache at startup when it is older than the tree; see@@ -426,7 +424,8 @@ struct VPhoneCustomFirmwareInstaller {plan: plan,priorGuest: priorGuest,guestDevice: device,- includeIdentity: mode == .full,+ includeIdentity: mode == .full+ || plan?.isEnabled(FirmwareGuestIdentityPatchSet.prebootDeviceTreeIdentity) == true,buildVersion: buildVersion,boardDeviceTree: boardDeviceTree,))@@ -2234,8 +2233,8 @@ struct VPhoneCustomFirmwareInstaller {return VPhoneGuestDevice.detect(buildManifest: manifest) ?? .default}- /// `includeIdentity` is false for an environment update, which carries only- /// the device tree repairs: the board repair, which needs `boardDeviceTree`+ /// `includeIdentity` also enables an environment update's selected identity.+ /// The device tree repairs include the board repair, which needs `boardDeviceTree`/// (a board-presenting guest's audio node, an iPhone17,3's product/// description), the haptics removal and the microphone-array repair./// `boardDeviceTree` is the guest's own board tree (`DeviceTree.<board>.im4p`),@@ -2252,8 +2251,8 @@ struct VPhoneCustomFirmwareInstaller {/// - full install: restore that backup to a clean base, apply identity,/// re-take the backup from the post-identity bytes, then apply the/// enabled repairs;- /// - environment update (no identity step): restore the backup, apply the- /// enabled repairs.+ /// - environment update: restore the backup, apply identity when selected,+ /// then apply the enabled repairs.////// A backup is taken only when the base is known clean — a backup already/// existed, or no repair was live before. A tree repaired before backups@@ -2289,8 +2288,8 @@ struct VPhoneCustomFirmwareInstaller {}}} else if priorGuest.contains(identity) {- // An environment update does not touch the identity rewrite; if the- // last install wrote it, it is still live.+ // With identity off, an environment update preserves the installed+ // identity: the repair backup is already post-identity.live.insert(identity)}@@ -2408,7 +2407,7 @@ struct VPhoneCustomFirmwareInstaller {let staged = work.file(folder).appendingPathComponent("devicetree.img4")try (hadRepairBackup ? root.readData(backup) : currentBytes).write(to: staged)- // Identity first (full install only), so the post-identity snapshot and+ // Identity first when selected, so the post-identity snapshot and// a later repair revert never undo it.if rewriteIdentity {try patch("patch-post-restore-dt", [staged.path])