Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Avoid redundant vphoned update on first boot

Lakr421d2853c091
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index 42abdc8c..db5b24ea 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@ -331,15 +331,12 @@ struct VPhoneCustomFirmwareInstaller {
}
private func installVphoned(system: URL, work: URL) throws {
+ // Install the same signed bytes that vm launch uses for auto-update.
+ // Re-signing here changes the binary hash and forces an upload and
+ // daemon restart on the VM's first boot.
let vphoned = try VPhoneGuestBinaries.resolve("vphoned")
let staged = work.appendingPathComponent("vphoned")
try fm.copyItem(at: vphoned, to: staged)
- let entitlementsURL = resources.scriptsDir.appendingPathComponent("vphoned/VPhoneDaemon.entitlements")
- let entitlements = try Data(contentsOf: entitlementsURL, options: .mappedIfSafe)
- try VPhoneSigner.sign(
- fileAt: staged,
- options: .init(entitlements: entitlements, mergesExisting: true),
- )
try replace(staged, at: system.appendingPathComponent("usr/bin/vphoned"), mode: 0o755)
let signed = bundle.appendingPathComponent(".vphoned.signed")
if fm.fileExists(atPath: signed.path) {
diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
index 8b30ffb6..7c2ad469 100755
--- a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
+++ b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
@@ -54,7 +54,6 @@ fi
/bin/cp "$TARGET_BUILD_DIR/vphone-vm" "$macos/vphone-vm"
/bin/cp "$command_products/vphone-cli" "$macos/vphone-cli"
/bin/cp "$daemon_products/vphoned" "$macos/vphoned"
-/bin/cp "$daemon_products/vphoned" "$macos/vphoned.signed"
/bin/cp "$amfi_products/VPhoneEscalator" "$macos/VPhoneEscalator"
/bin/cp "$guest_products/camfix/libcamfix.dylib" "$macos/libcamfix.dylib"
/bin/cp "$guest_products/vcamcaptured/libvcamcaptured.dylib" "$macos/libvcamcaptured.dylib"
@@ -85,7 +84,7 @@ compatibility_library="$(/usr/bin/xcrun swift-stdlib-tool --print \
/usr/bin/codesign --force --sign - "$macos/vphone-cli"
/usr/bin/codesign --force --sign - --entitlements "$root/VPhoneDaemon/Configuration/VPhoneDaemon.entitlements" "$macos/vphoned"
-/usr/bin/codesign --force --sign - --entitlements "$root/VPhoneDaemon/Configuration/VPhoneDaemon.entitlements" "$macos/vphoned.signed"
+/bin/cp "$macos/vphoned" "$macos/vphoned.signed"
/usr/bin/codesign --force --sign - "$macos/VPhoneEscalator"
/usr/bin/codesign --force --sign - "$macos/libswiftCompatibilitySpan.vphone.dylib"
/usr/bin/codesign --force --sign - --entitlements "$root/VPhoneExecutable/VPhoneVirtualization/Resources/VPhoneVirtualization.entitlements" "$macos/vphone-vm"
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/GuestCommunication/VPhoneGuestControl.swift b/VPhoneExecutable/VPhoneVirtualization/UI/GuestCommunication/VPhoneGuestControl.swift
index 76e46c8d..7a9aa96c 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/GuestCommunication/VPhoneGuestControl.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/GuestCommunication/VPhoneGuestControl.swift
@@ -59,7 +59,7 @@ final class VPhoneGuestControl {
monitor = Task { [weak self] in
while !Task.isCancelled {
await self?.probe()
- try? await Task.sleep(for: .seconds(3))
+ try? await Task.sleep(for: .seconds(self?.isConnected == true ? 3 : 1))
}
}
}
diff --git a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestBinaries.swift b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestBinaries.swift
index f043ecd5..f6ef4972 100644
--- a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestBinaries.swift
+++ b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestBinaries.swift
@@ -1,7 +1,7 @@
// VPhoneGuestBinaries.swift — where the prebuilt iOS binaries live.
//
// vphoned is cross-compiled on the build machine and shipped in the bundle.
-// The runtime installs it with an ad-hoc signature and never needs Xcode.
+// The bundle carries the signed binary for installation and host auto-update.
import Foundation