Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Publish the virtual camera on iOS 27 so Camera.app saves photos

Jacky2df155ab54ec
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index e5642060..dd4424a1 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -402,6 +402,17 @@
> format with device exposure values. Details and validation:
> [`Guest/virtual_camera_transport.md`](Guest/virtual_camera_transport.md#front-camera-clients-and-data-output-frames-2026-10-10).
+> **Camera hook: the virtual camera on iOS 27 (2026-10-22):** no new patch
+> and no new library; `libvcamcaptured.dylib` and `libcamfix.dylib` change
+> behaviour only. iOS 27 has no `_sSourceList`, so `libvcamcaptured` adds
+> the synthetic backing to the `FigCaptureSourceBackingsProvider` its
+> microphone hook builds, which `FigCaptureSourceManager` publishes from.
+> `libcamfix` gives Camera.app's `-capturePhotoWithSettings:delegate:` the
+> full callback sequence it waits for before saving, and starts the preview
+> scan for a client that skips `-startRunning`. Camera.app's shutter saves
+> photos on 27 again (issue #707). Details and validation:
+> [`Guest/virtual_camera_transport.md`](Guest/virtual_camera_transport.md#ios-27-the-camera-through-the-backings-provider-2026-10-22).
+
> **3D gyroscope core (2026-10-08; guest acceptance pending):**
> `system-backboardd-cfw-gyroscope`, declared in the Guest System set and
> selected by both presets on iOS 18+, installs `/usr/lib/libvphonegyro.dylib`.
diff --git a/Research/Guest/ios27_capture_microphone_source.md b/Research/Guest/ios27_capture_microphone_source.md
index fa530572..3019801e 100644
--- a/Research/Guest/ios27_capture_microphone_source.md
+++ b/Research/Guest/ios27_capture_microphone_source.md
@@ -119,8 +119,9 @@ Even where it works, it appends one camera source and hands out its synthetic
device only for its own device ID (`copyDeviceWithID:forClient:…`), never for
`copyDeviceForPublishingWithID:` with `Default`. Nothing in it gives the vendor
a create function or touches the backings provider, so switching the virtual
-camera on cannot bring the microphone back. The iOS 27 virtual camera is a
-separate open item.
+camera on cannot bring the microphone back. The iOS 27 virtual camera now goes
+the other way round: its backing is added to the provider this note builds
+([virtual camera on iOS 27](virtual_camera_transport.md#ios-27-the-camera-through-the-backings-provider-2026-10-22)).
## 5. The fix: a microphone-only provider
diff --git a/Research/Guest/virtual_camera_transport.md b/Research/Guest/virtual_camera_transport.md
index f060cd9a..ce7175ee 100644
--- a/Research/Guest/virtual_camera_transport.md
+++ b/Research/Guest/virtual_camera_transport.md
@@ -141,7 +141,8 @@ under 10. The numbers are in [`service_trimming.md`](service_trimming.md#idle-co
Camera frames were not checked live after the change: an iPhone 27.0 guest
publishes no synthetic camera at all (`libvcamcaptured` logs `_sSourceList not
located` on every boot), so nothing can start the drive there. That is a
-separate open item ([iOS 27 capture sources](ios27_capture_microphone_source.md#4-the-virtual-camera-does-not-change-this)).
+separate open item ([iOS 27 capture sources](ios27_capture_microphone_source.md#4-the-virtual-camera-does-not-change-this)),
+since closed ([below](#ios-27-the-camera-through-the-backings-provider-2026-10-22)).
On 26.6.2 the synthetic source is published and the Camera app starts.
## Front-camera clients and data-output frames (2026-10-10)
@@ -185,4 +186,80 @@ uploaded its clip, and its back-camera photo capture still worked in the same
process. Limits: a 420f request gets 420v; delivery does not consult camera
authorization (the fallback calls the delegate directly, as before), so a
denied-permission path cannot be exercised; an iPhone 27.0 guest still
-publishes no synthetic source.
+publishes no synthetic source (until the change below).
+
+## iOS 27: the camera through the backings provider (2026-10-22)
+
+[Issue #707](https://github.com/Lakr233/vphone-cli/issues/707) reported that
+on an iOS 27.0.1 guest the Camera shutter and Safari's "Save Image" did
+nothing, and blamed missing `photolibraryd`, `camerawriterd` and
+`mediaassetd`. None of the three exists on stock iOS 27 (checked on the
+mounted 24A435 System volume; `assetsd` is the Photos writer and is
+present). On `photo707` (iPhone17,3, 27.0 24A435, default slimmed template,
+bundle 2.10.1 from main) PhotoKit `performChanges` with an image, with
+`addResourceWithType:fileURL:` and `UIImageWriteToSavedPhotosAlbum` all
+saved, and so did Safari's "Save to Photos". The one real failure was the
+Camera shutter: iOS 27 published no virtual camera at all, the open item
+above.
+
+### Where iOS 27 publishes sources
+
+`_sSourceList` is gone. `-[FigCaptureSourceManager copySourcesWithType:
+clientAuditToken:clientIsBincompat:]` makes each client's sources on
+request: for every `FigCaptureSourceBacking` in
+`+[FigCaptureSourceBackingsProvider sharedCaptureSourceBackingsProvider]
+.sourceBackings` it calls `FigVideoCaptureSourceCreateFromBacking` (video)
+or `FigAudioCaptureSourceCreateFromBacking` (audio), after filtering on the
+backing's `attributes.deviceType` and `position`. The shared manager itself
+is made from the same array (`+sharedCaptureSourceManager`'s once block ->
+`-initWithBackings:fineGrainThermalMonitoringEnabled:…`). The provider keeps
+the backings in an `NSMutableArray *_sourceBackings`, which
+`-_addBackingsForSourceInfoDictionaries:` fills with
+`-initWithMediaType:attributes:cachedProperties:formats:missingFormatNames:
+synchronizedStreamUniqueIDs:unsynchronizedStreamUniqueIDs:` — the same
+initializer `vcc_build_backing()` already used for 26.x, which wraps the
+attributes dictionary in `FigCaptureSourceAttributes`. iOS 26.6.2 (23G90)
+has the provider class but no `FigCaptureSourceManager`, and still serves
+`_sSourceList`.
+
+### The change
+
+- `VCamCaptured/Synthetic/VCamProviderSource.m`: where
+ `FigCaptureSourceManager` exists, the synthetic backing is appended to the
+ provider's `_sourceBackings` once, when the microphone hook
+ (`VCamMicrophoneSource.m`) builds the provider the daemon could not. That
+ happens at the daemon's first source query, before the source manager is
+ made. `vcc_install_synthetic` (the `_sSourceList` path) returns early there.
+- `CamFix/Photo/CamFixCapturePhoto.m`: Camera.app on 27 takes photos with
+ `-capturePhotoWithSettings:delegate:`, not the moment-capture trio. When the
+ delegate is its `CAMCaptureEngine` (it answers
+ `_resultsQueueRegisteredStillImageRequests`; the ivar is
+ `__resultsQueueRegisteredStillImageRequests`), the hook now runs the
+ moment-capture driver: the engine's request for the settings' uniqueID,
+ then will/did/finish for it. With only `didFinishProcessingPhoto:` the
+ engine filed the photo under captureID 0, logged "Have not received final
+ callback", and saved nothing. Other delegates keep the single callback.
+- `CamFix/Session/CamFixSessionGuards.m`: the `isRunning` lie made Camera.app
+ log "Session is already running. Skipping call to startRunning", so
+ `_setRunning:YES`, which started the preview-layer scan, never came and the
+ viewfinder stayed black. The lie now starts the scan too.
+
+The daemon only parses the session configuration (`cameraCfgs.count=1`,
+"Wide back BGRA/1280x720"); it never builds a graph or asks the vendor for
+the device, so preview and photos come from `libcamfix` in the client, as
+the hook was designed.
+
+### Validation (photo707)
+
+With a 1280x720 BGRA test frame written into the shared frame file (the file
+the host's camera server fills through vphoned), Camera.app showed the frame
+in its viewfinder, and each shutter press saved a 1280x720 JPEG of it to
+`DCIM/100APPLE` with the library thumbnail updated (three in a row). A
+third-party app got `vphone:vcam:0` from `+defaultDeviceWithMediaType:`, ran
+an `AVCaptureSession` and received a 24,635-byte photo from
+`AVCapturePhotoOutput`. No crash reports from Camera or cameracaptured.
+
+Not checked: frames streamed by the host's camera server (the menu has no
+automation; the file it writes is the one tested), Camera.app video
+recording, Voice Memos recording with the camera backing present, and an
+iOS 26 guest after the camfix changes (both camfix changes also load there).
diff --git a/VPhoneGuestComponents/CamFix/CamFixPrivate.h b/VPhoneGuestComponents/CamFix/CamFixPrivate.h
index d338eacb..0a25a816 100644
--- a/VPhoneGuestComponents/CamFix/CamFixPrivate.h
+++ b/VPhoneGuestComponents/CamFix/CamFixPrivate.h
@@ -60,6 +60,12 @@ CFX_HIDDEN void cfx_install_photo_representation_hooks(void);
CFX_HIDDEN void cfx_install_capturePhoto_hook(void);
CFX_HIDDEN void cfx_install_moment_capture_hooks(void);
CFX_HIDDEN void cfx_install_capturerequest_stubs(void);
+// YES for Camera.app's CAMCaptureEngine, which registers each still request
+// by uniqueID and waits for the whole callback sequence before saving.
+CFX_HIDDEN BOOL cfx_delegate_registers_still_requests(id delegate);
+// Delivers a photo built from the shm frame to such a delegate, with the
+// full will/did/finish callback sequence for the settings' uniqueID.
+CFX_HIDDEN void cfx_drive_capture(id output, id delegate, id settings);
// MARK: - preview (Preview/)
diff --git a/VPhoneGuestComponents/CamFix/Photo/CamFixCapturePhoto.m b/VPhoneGuestComponents/CamFix/Photo/CamFixCapturePhoto.m
index 44fe7ea3..98c27673 100644
--- a/VPhoneGuestComponents/CamFix/Photo/CamFixCapturePhoto.m
+++ b/VPhoneGuestComponents/CamFix/Photo/CamFixCapturePhoto.m
@@ -71,6 +71,20 @@ static void cfx_capturePhoto_hook(id self, SEL _cmd, id settings, id delegate) {
}
__strong id retainedSelf = self;
__strong id retainedDelegate = delegate;
+ // Camera.app on iOS 27 takes its photos here rather than through the
+ // moment-capture trio. Its CAMCaptureEngine matches the photo to the
+ // request it registered for the settings' uniqueID and saves it only once
+ // every callback for that request has arrived, so it gets the same full
+ // sequence the moment-capture commit drives.
+ if (cfx_delegate_registers_still_requests(delegate)) {
+ __strong id retainedSettings = settings;
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
+ @autoreleasepool {
+ cfx_drive_capture(retainedSelf, retainedDelegate, retainedSettings);
+ }
+ });
+ return;
+ }
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
@autoreleasepool {
cfx_deliver_capturePhoto(retainedSelf, retainedDelegate);
diff --git a/VPhoneGuestComponents/CamFix/Photo/CamFixMomentCapture.m b/VPhoneGuestComponents/CamFix/Photo/CamFixMomentCapture.m
index e35c6864..9b362551 100644
--- a/VPhoneGuestComponents/CamFix/Photo/CamFixMomentCapture.m
+++ b/VPhoneGuestComponents/CamFix/Photo/CamFixMomentCapture.m
@@ -123,7 +123,13 @@ void cfx_install_capturerequest_stubs(void) {
// MARK: - drive the capture state machine
-static void cfx_drive_capture(id output, id delegate, id settings) {
+BOOL cfx_delegate_registers_still_requests(id delegate) {
+ // The getter cfx_drive_capture reads the registry through (KVC); the ivar
+ // behind it is __resultsQueueRegisteredStillImageRequests.
+ return [delegate respondsToSelector:NSSelectorFromString(@"_resultsQueueRegisteredStillImageRequests")];
+}
+
+void cfx_drive_capture(id output, id delegate, id settings) {
// Extract uniqueID from AVMomentCaptureSettings.
int64_t uid = 0;
@try {
diff --git a/VPhoneGuestComponents/CamFix/Session/CamFixSessionGuards.m b/VPhoneGuestComponents/CamFix/Session/CamFixSessionGuards.m
index f60026f5..b135cb08 100644
--- a/VPhoneGuestComponents/CamFix/Session/CamFixSessionGuards.m
+++ b/VPhoneGuestComponents/CamFix/Session/CamFixSessionGuards.m
@@ -176,6 +176,10 @@ static BOOL cfx_session_isRunning_hook(id self, SEL _cmd) {
BOOL real = ((Fn)cfx_orig_isRunning)(self, _cmd);
if (cfx_session_is_for_vcam(self)) {
cfx_track_vcam_session(self);
+ // A client that believes this and skips -startRunning (Camera.app on
+ // iOS 27) never reaches _setRunning:YES, which is what starts the scan
+ // for its preview layer otherwise.
+ cfx_start_scan_timer();
if (cfx_isRunning_logged < 3) {
cfxlog(@"[isRunning] real=%d -> forcing YES (session=%p)", real, self);
cfx_isRunning_logged++;
diff --git a/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneSource.m b/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneSource.m
index f92c16e8..b71f3156 100644
--- a/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneSource.m
+++ b/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneSource.m
@@ -20,9 +20,13 @@
// so the plist is the first shipped product's that describes a microphone.
// A provider the daemon did build is
// returned unchanged. See Research/Guest/ios27_capture_microphone_source.md.
+//
+// On iOS 27 the provider built here also carries the virtual camera's
+// backing, added once when it is made (Synthetic/VCamProviderSource.m).
#include "VCamCapturedPrivate.h"
#include "VCamImage.h"
+#include "VCamSynthetic.h"
// FigCaptureGetModelSpecificName(void) -> CFStringRef (not retained)
typedef CFStringRef (*VccModelNameFn)(void);
@@ -152,6 +156,7 @@ static id vcc_shared_provider_hook(id self, SEL _cmd) {
if (!vcc_mic_provider && !vcc_mic_provider_failed) {
vcc_mic_provider = vcc_build_mic_provider(self);
vcc_mic_provider_failed = (vcc_mic_provider == nil);
+ vcc_provider_add_synthetic_camera(vcc_mic_provider);
}
if (vcc_mic_provider && !vcc_mic_provider_served) {
vcc_mic_provider_served = YES;
diff --git a/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamProviderSource.m b/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamProviderSource.m
new file mode 100644
index 00000000..8c999fed
--- /dev/null
+++ b/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamProviderSource.m
@@ -0,0 +1,45 @@
+// The synthetic camera's source on iOS 27.
+//
+// iOS 27 no longer keeps a source list the daemon serializes for clients
+// (`_sSourceList`, which VCamSourceInstallation.m appends to on 26.x).
+// -[FigCaptureSourceManager copySourcesWithType:clientAuditToken:
+// clientIsBincompat:] makes each client's sources on request, one per
+// FigCaptureSourceBacking in +[FigCaptureSourceBackingsProvider
+// sharedCaptureSourceBackingsProvider].sourceBackings, through
+// FigVideoCaptureSourceCreateFromBacking for video backings. The shared
+// FigCaptureSourceManager is itself made from that array.
+//
+// So the synthetic camera is published by adding its backing to the
+// provider's `_sourceBackings`, before the source manager is created. The
+// provider is the one VCamMicrophoneSource.m serves when the daemon could
+// build none of its own, which is the case on every VM. See
+// Research/Guest/virtual_camera_transport.md.
+
+#include "VCamSynthetic.h"
+
+BOOL vcc_provider_publishes_sources(void) {
+ return NSClassFromString(@"FigCaptureSourceManager") != Nil;
+}
+
+void vcc_provider_add_synthetic_camera(id provider) {
+ if (!provider || !vcc_provider_publishes_sources()) return;
+ Ivar iv = class_getInstanceVariable(object_getClass(provider), "_sourceBackings");
+ if (!iv) {
+ vcc_log(@" provider camera: no _sourceBackings ivar");
+ return;
+ }
+ id backings = object_getIvar(provider, iv);
+ if (![backings isKindOfClass:NSMutableArray.class]) {
+ vcc_log(@" provider camera: _sourceBackings is %@, not a mutable array",
+ [backings class]);
+ return;
+ }
+ id backing = vcc_build_backing();
+ if (!backing) {
+ vcc_log(@" provider camera: no synthetic backing");
+ return;
+ }
+ [(NSMutableArray *)backings addObject:backing];
+ vcc_log(@" provider camera: added synthetic backing %p, %lu backing(s)",
+ backing, (unsigned long)[(NSMutableArray *)backings count]);
+}
diff --git a/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSourceInstallation.m b/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSourceInstallation.m
index 38cf5b12..e1804964 100644
--- a/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSourceInstallation.m
+++ b/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSourceInstallation.m
@@ -85,6 +85,12 @@ static void vcc_probe_contract(void *source) {
// MARK: - _sSourceList manipulation
void vcc_install_synthetic(void) {
+ // iOS 27 has no source list to append to; the backing went into the
+ // provider when the daemon first asked for it (VCamProviderSource.m).
+ if (vcc_provider_publishes_sources()) {
+ vcc_log(@" source list: the backings provider publishes the camera here");
+ return;
+ }
vcc_image_t img;
int rc = vcc_image_resolve(&img, "FigCaptureSourceServerStart");
if (rc != 0) {
diff --git a/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSynthetic.h b/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSynthetic.h
index cc9c0d88..bb45afa9 100644
--- a/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSynthetic.h
+++ b/VPhoneGuestComponents/VCamCaptured/Synthetic/VCamSynthetic.h
@@ -21,6 +21,15 @@ extern NSString *const kVccSynthStreamID;
// and formats), or nil when a required class or key is missing.
id vcc_build_backing(void);
+// YES where the daemon publishes its sources from the backings provider
+// (iOS 27) rather than from `_sSourceList` (iOS 26.x).
+BOOL vcc_provider_publishes_sources(void);
+
+// Adds the synthetic backing to a FigCaptureSourceBackingsProvider's
+// backings, so the source manager made from it publishes the camera. Does
+// nothing where the daemon still publishes from `_sSourceList`.
+void vcc_provider_add_synthetic_camera(id provider);
+
// VccSynthDevice, registered on first use; Nil until then or on failure.
extern Class vcc_synth_device_class;