/duology-features:duo-camerafrom duology-features
Guides camera capture on iPhone Duo across all poses: closed, open, partly folded, flipped, and through fold/unfold. Covers virtual front camera, physical front cameras, direction coordination, rotation, and tabletop capture.
Ships in duology-features. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
iPhone Duo has a front camera above each display, rear cameras, and a hinge that turns them around. Which way a camera points depends on the display your app is on. This skill tells you which camera to use, how to follow it through a fold, and how to lay out capture for each pose.
Load neighbours when the task needs them: duo-scenes (the camera capture accessory's lifecycle and UIKit registration), duo-postures (tabletop and flipped layouts), duo-layout (reserved regions, including the inner camera's occlusion), duo-continuity (state through a fold). To start a new camera app with all of this in place, use recipe-camera-studio.
No camera in the simulator. The iPhone Duo simulator has no camera. Measured (20 Oct 2026): every discovery session returned no device, and a direction coordinator kept an empty map and never called its handler (we watched for up to 2 minutes). So every capture behaviour in this skill comes from Apple's pages and is unverified on a device. All Swift code here typechecks against the iOS 27.1 SDK; none of it has run with a real camera.
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1). Derived means reasoning from Apple's numbers or our measurements. Unverified means we could not check it. Everything else comes from Apple, linked inline. Full source list: reference/sources.md.
AVCaptureDeviceDirectionCoordinator which way each one faces. Never infer it from position or the device type.| Camera | How to get it | Faces | What it gives you |
|---|---|---|---|
| Virtual front camera | .builtInWideAngleCamera or .builtInUltraWideCamera at .front. isVirtualDevice is true. | The display your app is on: inner when open, outer when closed | Only what both front cameras share: up to 1080p at 60 fps, no depth. The system switches for you (talk 111465). |
| Outer front | .builtInOuterUltraWideCamera | The same way as the outer display | Square sensor. Up to 4K and 120 fps per the talk; Apple's spec page lists 4K up to 60 fps and 120 fps slo-mo at 1080p. |
| Inner front | .builtInInnerUltraWideCamera | The same way as the inner display. Under the display, hidden until it runs. | Square sensor, 1080p up to 60 fps (talk 111465) |
| Rear | Your usual rear types, position == .back | Away from the person on the inner display; toward them when the phone is turned around | As on other iPhones |
supportedDepthDataFormats before you rely on it.position == .front. That is where a camera sits, not where it points (guide).AVCaptureDevice.h says the outer and inner types can only be discovered with a discovery session, so use one rather than AVCaptureDevice.default(_:for:position:). Both are iOS 27.1 and unavailable on Mac Catalyst.formats at run time; never hard-code either number. Helpers: references/cameras.md.| The app is | Use |
|---|---|
| A video call, a social selfie, a face scan, any app that already uses the front camera | The virtual front camera |
| A camera app, or anything that needs 4K or 120 fps on the outer camera, depth, or a rear-camera selfie | The physical cameras, with a direction coordinator |
The virtual front camera is the discovery you already write. It streams from the camera above the display your app is on, and follows it when the phone opens or closes (guide).
import AVFoundation
/// The front camera most apps ask for. On iPhone Duo it is the virtual front camera.
func usualFrontCamera() -> AVCaptureDevice? {
AVCaptureDevice.DiscoverySession(
deviceTypes: [.builtInWideAngleCamera, .builtInUltraWideCamera],
mediaType: .video, position: .front
).devices.first // nil in the simulator
}
Read activePrimaryConstituent to see which physical camera streams; it is nil until the session runs. Code that already handles the dual camera handles this virtual device too.
AVCaptureDeviceDirectionCoordinator lives in AVKit, not AVFoundation. It takes the view that shows your preview as its frame of reference and sorts the cameras you list into forward facing (the same way as that view) and backward facing (talk 111465).
| Your preview view is on | Forward facing | Backward facing |
|---|---|---|
| The outer display, phone closed | Outer front | Rear |
| The inner display, phone open | Inner front | Outer front, rear |
| The outer display, phone open and turned around | Rear, outer front | Apple doesn't say |
| Both displays at once (accessory) | Each view's own coordinator: the rear cameras face forward from the outer view and backward from the inner view |
Source: talk 111465. Apple doesn't say where the inner camera lands while the phone is closed.
import AVKit
import UIKit
// requires: CaptureService (references/direction-and-mirroring.md)
#if !targetEnvironment(macCatalyst) // the outer and inner types don't exist there
@available(iOS 27.1, *)
@MainActor
final class FrontCameraFollower {
private let capture: CaptureService
private var coordinator: AVCaptureDeviceDirectionCoordinator?
private(set) var cameraID: String?
init(capture: CaptureService) { self.capture = capture }
/// Call once the preview view exists. Keep this object while the view is on screen.
func follow(_ previewView: UIView) {
coordinator = AVCaptureDeviceDirectionCoordinator(
view: previewView,
// Both physical front cameras, never the virtual one, plus the rear camera.
deviceTypes: [.builtInOuterUltraWideCamera, .builtInInnerUltraWideCamera, .builtInDualWideCamera]
) { [weak self] map in
self?.directionsChanged(map) // main queue; no AVFoundation calls here
}
}
private func directionsChanged(_ map: AVCaptureDeviceDirectionMap) {
let forward = map.forwardFacingDeviceDescriptors
if let cameraID, forward.contains(where: { $0.uniqueID == cameraID }) { return }
guard let next = forward.first(where: { $0.position == .front }) ?? forward.first else { return }
cameraID = next.uniqueID
Task { await capture.useCamera(withID: next.uniqueID) } // descriptors are Sendable
}
}
#endif
What to know:
deviceDirections is empty until that first call (AVCaptureDeviceDirectionCoordinator.h).AVCaptureDevice(uniqueID:) can return nil by the time your actor runs. Handle that.Full code: the capture actor, a watcher that prefers a rear camera when the person asks, and the UIKit wiring: references/direction-and-mirroring.md.
A preview connection mirrors any camera whose position is .front. On Duo that is wrong twice: a rear camera facing the person should look like a mirror, and a front camera facing away should not (guide, talk 111465).
import AVKit
/// Mirror by where a camera points, not by where it sits.
/// Returns nil when the connection's automatic mirroring is already right.
@available(iOS 27.1, *)
func previewMirroring(for camera: AVCaptureDeviceDescriptor, in map: AVCaptureDeviceDirectionMap) -> Bool? {
let facesViewer = map.forwardFacingDeviceDescriptors.contains { $0.uniqueID == camera.uniqueID }
let facesAway = map.backwardFacingDeviceDescriptors.contains { $0.uniqueID == camera.uniqueID }
if camera.position == .back && facesViewer { return true } // a rear-camera selfie
if camera.position == .front && facesAway { return false } // a front camera looking away
return nil
}
automaticallyAdjustsVideoMirroring = false before isVideoMirrored. The other order raises an exception.Adopt AVCaptureDevice.RotationCoordinator (iOS 17) for the preview and for captured media. On Duo its angles also change when the app moves to the other display (talk 111465).
isCameraSensorOrientationCompensationEnabled to false on AVCapturePhotoOutput (iOS 26). It is on for every front camera on Duo and costs performance (talk 111465).Code that observes both angles on the capture actor: references/rotation-and-preview.md.
videoGravity = .resizeAspectFill (talk 111465).setDynamicAspectRatio(_:completionHandler:) (iOS 26) when the format supports it, so the preview fills the wide display (talk 111465, WWDC26 session 341)..occlusion regions (duo-layout)..division frame. A preview may cross the fold, but nothing people tap.Measured region frames for the inner camera, and the code: references/rotation-and-preview.md.
Fully open, with the rear camera running and your app full screen on the inner display, the system can show your CameraCaptureAccessory on the outer display, which faces the subject (guide, talk 111464). duo-scenes covers registration, availability and the UIKit version. The camera side:
AVCaptureVideoPreviewLayer on the same session. Give its view its own direction coordinator: from the outer display the rear camera faces forward, so mirror that preview, and leave the photographer's preview unmirrored (talk 111465). Unverified: a second preview layer on one session on a device; the AVFoundation header for deferredStartEnabled (iOS 26) talks about apps with several preview layers.duo-scenes measured this). Partly folded is unclear: in the simulator, with no capture session, it was available in book at 128° and, on 2 November, in tabletop (measured; references/testing.md). On a device, unverified. Put the countdown in the main UI as well, so it never depends on the accessory.Code: references/outer-display-and-tabletop.md.
Open and turned around, the rear cameras and the outer display face the person, and a camera app can move to the outer display. The rear and the outer front cameras then both face forward (talk 111465).
position.Apple names one optional layout worth designing for a single pose: the phone seated on a table, good for hands-free use. What people watch goes in the top region, what they tap goes in the bottom region, and every control stays the same as in other poses (talk 111466, talk 111463). For a camera:
ArrangementView with .overlay does this with no fold code. Measured with a video in its place (20 Oct 2026): flat or closed, the primary view floated over the secondary; in tabletop the primary took the bottom region and the secondary the top; in book, trailing and leading.duo-postures measurements). On a table that half lies flat, so the inner camera would point at the ceiling. Ask the coordinator what faces forward; never assume. Unverified on a device.import SwiftUI
// requires: CameraModel, CaptureControls, TimerBadge, SubjectPreview (references/outer-display-and-tabletop.md)
// requires: CameraPreview (references/rotation-and-preview.md)
#if !targetEnvironment(macCatalyst)
/// One camera screen for every pose. Flat or closed, the controls float over the
/// preview. Partly folded, they move to the bottom region (tabletop) or trailing region (book).
@available(iOS 27.1, *)
struct CaptureScreen: View {
@State private var model = CameraModel() // above the arrangement: a fold never rebuilds it
var body: some View {
ArrangementView {
CaptureControls(model: model) // primary: what people tap
} secondary: {
CameraPreview(source: model.capture.previewSource) { model.attachMain($0) }
.overlay { if model.isSwitching { Color.black } } // hide the old camera's frames
.overlay { TimerBadge(secondsLeft: model.secondsLeft) }
.ignoresSafeArea()
}
.arrangementViewStyle(.overlay)
.background(.black)
.sceneAccessory { // section 7: the subject's view, outer display
CameraCaptureAccessory { SubjectPreview(model: model) }
}
}
}
#endif
AVCaptureSession.h says a session can be interrupted with .videoDeviceNotAvailableWithMultipleForegroundApps in a multi-app layout. Unverified on Duo: expect it, show why the preview stopped, and resume on interruptionEndedNotification.isMultitaskingCameraAccessSupported is true for video-call apps (the voip background mode) and for apps with the multitasking camera entitlement (Apple). Set isMultitaskingCameraAccessEnabled before the session starts.Code: references/direction-and-mirroring.md.
@available(iOS 27.1, *) and if #available(iOS 27.1, *). On older iOS, keep using the discovery session above.#if !targetEnvironment(macCatalyst).setDynamicAspectRatio and sensor orientation compensation are iOS 26; videoRotationAngleRelative(toDeviceOrientation:) is iOS 27.0.| Where | What you can check |
|---|---|
| Simulator | Layout only: controls in every pose, the accessory view at the outer display's size, nothing in the fold. Discovery returns no camera (measured), so guard every nil. |
| Real iPhone Duo | Everything else: open and close with each strategy, the switch mask, mirroring on both displays, flipped selfies, rotation on both displays, the accessory with capture running, Split View, tabletop with the timer. |
Checklists for both and how to fake a camera in the simulator: references/testing.md.
position or the device type to decide which way a camera points.AVCaptureDeviceDirectionCoordinator per preview view, created on the main actor and kept alive while the view is on screen.AVCaptureDevice(uniqueID:) and handles nil.nil cameras handled (the simulator returns none).What SKILL.md sets; muted values are Claude Code's defaults
8 skills in this plugin
/duo-app-intentsApp Intents on iPhone Duo: AppIntent, AppEntity with EntityStringQuery, OpenIntent with TargetContentProvidingIntent and onAppIntentExecution (UISceneAppIntent and AppIntentSceneDelegate in UIKit) to show the right item in the right pane or window, handlesExternalEvents to pick the window, intents that work with the phone closed (supportedModes .background, IntentDialog, ProvidesDialog, isVoiceOnly), onscreen awareness when two panes are visible (appEntityIdentifier, appEntityIdentifier(forSelectionType:), NSUserActivity), App Shortcuts (AppShortcutsProvider) and AppIntentsTesting runs on the Duo simulator in each pose. Use when an app adds Siri, Shortcuts, Spotlight or Apple Intelligence actions, when an intent opens the wrong pane or an extra window, or when an intent must work while the phone is closed./duo-gamesBuilds games for iPhone Duo, Apple's foldable. The game fills the closed outer display, the open inner display, book pose and tabletop by changing its aspect ratio instead of letterboxing, as Apple's HIG asks; touch controls stay off the fold; and in tabletop the world sits above the fold with the controls below it, like a handheld console. Use when you build or port a SpriteKit, Metal or SwiftUI game, when a game letterboxes, restarts or loses input on fold or unfold, or when you add touch controls or game controller support. Covers SKScene .resizeFill with a camera that keeps the play area in view, one scene or renderer that survives every fold (measured), MTKView drawableSizeWillChange, a UIWindowScene display link that follows the scene to the other display, TouchZones split at the .division reserved region, GameLayout for tabletop, GCController and the simulator's own Gamepad, GCVirtualController and Touch Controller placement, orientation locks the inner display ignores, and two-player games.npx claudepluginhub kimeur/duology --plugin duology-featuresOther plugins' skills for the same job