/duology-recipes:recipe-camera-studiofrom duology-recipes
Scaffolds a SwiftUI camera studio app for iPhone Duo foldable, with AVFoundation photo/video capture, self-timer, and outer-display subject preview.
Ships in duology-recipes. 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; scripts run unread.
This recipe makes a new Xcode project: a camera studio for iPhone Duo. The photographer takes photos and videos with the rear camera, with a self-timer of 3 or 10 seconds. While the phone is open, the outer display faces the person being filmed, and the studio shows them their own picture, mirrored, with a framing guide and the countdown or the recording time. Fold the phone like a book and the controls move to the right page; set it on a table half folded and the preview sits above the fold with the controls below it, for hands-free shots. Photos and videos stay in the app's gallery until someone shares them.
The simulator has no camera (measured in duo-camera). So the studio has a stand-in: a moving test card that the shutter photographs and the recorder films into a real movie. With it, every pose, the timer, recording, the gallery and the subject view on the outer display work in the simulator. The real capture code typechecks against the iOS 27.1 SDK and builds with no warnings, but has not run with a camera (device: no). Section 5 lists what to check on a device.
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1, 2 November 2026). Derived means reasoning from Apple's pages or our measurements. Unverified means we could not check it. Everything else links to Apple. "Book" and "tabletop" are Duology's words for Apple's "partially folded, like a book" and "seated on a table like a laptop"; no API reports them. Full source list: reference/sources.md.
Use a different skill when:
duo-camera (which camera faces whom, mirroring, rotation, the front cameras, flipped selfies), with duo-scenes for the accessory;duo-camera covers the virtual front camera that follows the app between displays;duo-scenes./duo-new recipe-camera-studio runs steps 1 to 5. Run every step yourself when there is no command.
Get three values from the user, or propose them:
AppName: letters and digits, starting with a letter (it becomes a Swift type, <AppName>App). Not Tools, and not an Apple module name such as SwiftUI or AVFoundation;com.example.sitter;Run the script from this skill's folder (in the plugin: ${CLAUDE_PLUGIN_ROOT}/skills/recipe-camera-studio/scripts/new-project.sh):
"${CLAUDE_PLUGIN_ROOT}/skills/recipe-camera-studio/scripts/new-project.sh" \
Sitter com.example.sitter ~/Developer/Sitter
It copies template/, replaces __APP_NAME__ and __BUNDLE_ID__ in file contents and paths, checks none are left, and prints the next steps. It refuses a folder that exists and is not empty (exit 73), and bad or clashing names (exit 65), before it creates anything.
Test the rules on the Mac. Expect 0 failed:
cd ~/Developer/Sitter && Tools/run-model-tests.sh
Build for the Duo simulator (find its UDID with xcrun simctl list devices available | grep "iPhone Duo"):
DEVELOPER_DIR=/Applications/Xcode-27.1.app/Contents/Developer \
xcodebuild -project Sitter.xcodeproj -scheme Sitter \
-destination "platform=iOS Simulator,id=<UDID>" \
-derivedDataPath build/DerivedData build
Install, launch with a 10-second countdown running, and screenshot both displays. Use the UDID, not booted. With the phone open, the outer display (--display=primary) shows the subject view.
DEV=/Applications/Xcode-27.1.app/Contents/Developer
DEVELOPER_DIR=$DEV xcrun simctl install <UDID> build/DerivedData/Build/Products/Debug-iphonesimulator/Sitter.app
DEVELOPER_DIR=$DEV xcrun simctl launch --terminate-running-process <UDID> com.example.sitter -timer 10 -shutter
DEVELOPER_DIR=$DEV xcrun simctl io <UDID> screenshot --display=primary build/outer.png
DEVELOPER_DIR=$DEV xcrun simctl io <UDID> screenshot --display=primary-1 build/inner.png
Look at the PNGs before you report. The studio asks for the camera on a device; in the simulator it says "Stand-in camera".
Run the UI tests: DESTINATION="id=<UDID>" Tools/run-ui-tests.sh. A UI test brings the app to the front; tell the user first if they share the simulator.
Tell the user what passed, that capture needs a real iPhone Duo to check (section 5), and that poses change only in Device Hub.
Set DEVELOPER_DIR for every xcrun and xcodebuild call when the Mac has more than one Xcode. Never run xcode-select.
| Path | What it holds |
|---|---|
<App>/Model/ | StudioLayout (the regions from the size and the fold), the self-timer (TimerSetting, Countdown), RecordingClock, CameraAccess, the gallery's index (Capture, CaptureLibrary), the stand-in's picture (StandInFrame), app facts. Foundation, CoreGraphics and ImageIO only, every type nonisolated and Sendable. |
<App>/Capture/ | CaptureService: an actor that owns the AVCaptureSession, the photo and movie outputs, the microphone, the rotation coordinators and the subject preview's mirroring. CameraPreview (the preview layer in SwiftUI), StandInPreview, StandInRecorder (writes the stand-in's movie with AVAssetWriter), Poster. |
<App>/Studio/ | StudioScreen (preview and controls), StudioControls and ShutterButton, SubjectView and the accessory registration, GalleryScreen. |
<App>/Shared/ | StudioSplit (the two regions), onFoldChange (from recipe-reader), test markers. |
<App>/App/ | App entry, RootView (the screen and the gallery sheet), StudioStore, launch switches. |
<App>/PrivacyInfo.xcprivacy | No tracking, no domains, no data collected, no required-reason API. |
<App>UITests/ | Eight UI tests, pose-agnostic, on the stand-in camera. |
Tools/ | run-model-tests.sh, ModelTests/main.swift, run-ui-tests.sh. |
Project settings match the other recipes: iOS 26.0 deployment, Swift 6, SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor, approachable concurrency, file-system synchronized groups, iPhone and iPad, a scheme with parallel testing off. This one is public.app-category.photography and sets the camera, microphone and photo-library-add usage strings.
Architecture, the capture paths and the stand-in: references/architecture.md. What to check on a device: references/device-checks.md.
| Pose | Studio screen (inside the safe area) | Preview | Controls | Outer display |
|---|---|---|---|---|
| Closed (outer display) | 382 × 644 pt (measured) | the whole screen | float along the bottom, a 132 pt bar; shutter 76 pt, the others 52 pt high (measured) | it is the screen in use |
| Closed, held sideways | wider than tall | the whole screen | float along the trailing edge | the same |
| Open, flat, held wide | 867 × 635 pt, fold's frame at x 455.5 to 495.5 (measured) | the whole screen; it may cross the flat fold | float along the trailing edge, 132 pt, x 735 to 867, off the fold (measured) | the subject view (measured, no capture session) |
| Book | the same size; the fold turns active (measured) | the left page, 455.5 pt wide (measured) | a column on the right page, 371.5 pt wide (measured) | the subject view (measured, no capture session) |
| Tabletop | 669 × 835 pt, fold's frame at y 373.5 to 413.5 (measured) | above the fold, 373.5 pt high (measured) | a row below it, 421.5 pt high (measured) | the subject view (measured, no capture session) |
| Open, held tall, flat | as tabletop's size; the fold is inactive | the whole screen | float along the bottom, off the fold | the subject view (unverified) |
Measured on 2 November 2026: each pose set with duo-pose, then testStudioLayoutInThisPose, which fails if a control sits on the fold, is under 44 pt or leaves the controls' region, or if the shutter is under 76 pt, and attaches the real frames and a screenshot of each display with a countdown running; it passed in each pose, and every frame matched the table. Flat and folded differ on purpose, like Apple's ArrangementView with the overlay style (duo-camera measured it): flat, the preview keeps the whole screen; folded, the controls take their own half. The preview's view keeps its identity through every change, because one StudioSplit places it in every pose. The closed phone held sideways and the open phone held tall are unverified: their rows come from the Mac tests.
The subject view. The simulator showed it on the outer display open and flat, in book and in tabletop, and not closed (measured, subjectAvailable in the studio.state marker). There was no capture session: the simulator shows camera capture accessories without one, a known issue in the Xcode 27.1 release notes. Apple's conditions say fully open with the camera running (guide), so book and tabletop may differ on a device (unverified). That is why the countdown also shows large on the main preview, and nothing the photographer needs lives on the outer display. In the screenshots the subject view showed the stand-in mirrored (the bars ran the other way and the corner tag sat on the other side), the thirds guide and the countdown, upright and in portrait for the person facing the outer display. With the phone open, simctl io … screenshot --display=primary returns that display as a 2034 × 1398 image with the view on its side; turn it a quarter turn counterclockwise to read it (measured).
| Technique | Where | Why |
|---|---|---|
| A countdown or a recording survives every fold | StudioStore, @State in RootView | The timer's task and the recording live above every layout switch (duo-continuity). SubjectView holds no state: the system builds a new accessory scene each time the phone opens (measured in duo-scenes). |
| One layout in every pose | StudioSplit placing StudioLayout's regions | No if on the pose around the preview, so its UIView, its layer and its coordinators stay (Layout). |
| Folded, the regions meet at the fold | StudioLayout, fed by onFoldChange | reservedRegions(kind:options:layoutDirectionBehavior:) with .division and .includeInactive, read on the StudioSplit itself. |
| Tabletop: watch above, tap below | StudioLayout mode foldTopBottom | Apple singles out the phone on a table as good for hands-free use: what people watch in the top region, what they tap in the bottom one, with the same controls as every other pose (talk 111466, talk 111463). |
| No control on the fold | Every control lives in controls; flat, the floating bar or column sits at the edge, away from the fold | Nothing interactive in an active fold (talk 111466). The UI test compares every control with a marker element at the fold's frame. |
| The subject sees themselves | SubjectView in a CameraCaptureAccessory, a second preview layer on the same session | Registering a camera capture accessory, talk 111464. The photographer can turn it off (isEnabled); the system decides when it can show. |
| The subject's picture is mirrored | CaptureService.attachSubjectPreview(_:mirrored:) | From the outer display the rear camera faces the subject, so its preview should look like a mirror (choosing a camera by the direction it faces, duo-camera). Derived; the stand-in shows it mirrored in the simulator. |
| Upright on both displays | AVCaptureDevice.RotationCoordinator, one per preview layer | Its angles also change when the app moves between displays (rotation coordinator, talk 111465). Unverified on a device. |
| Width and fold, never the device | StudioLayout(size:fold:controlsThickness:) | Same rule as every Duology skill; duo-lint --strict finds nothing. |
CaptureService owns the session; every configuration call and startRunning() (which blocks) run there. The photo and movie delegates hand results back through continuations. Two preview layers share the session: the photographer's and the subject's..builtInWideAngleCamera, .back) films the subject. Switch Camera picks the front camera every app asks for, which on iPhone Duo is the virtual front camera that follows the app between displays (duo-camera). With the front camera the subject view shows no picture: the thirds, "Look here" and the countdown.CaptureService.hasCamera is false in the simulator (measured: AVCaptureDevice.default(for: .video) returns nil), so the store uses the stand-in. -standIn forces it on a device too. Every camera lookup is optional; nothing force-unwraps a device.StandInFrame draws 75 % colour bars, a moving dot and a corner tag. The preview draws it 30 times a second, letterboxed to 4:3 like .resizeAspect; the shutter renders it as a 1200 × 900 JPEG; the recorder writes a 640 × 480 H.264 movie at 15 frames a second with AVAssetWriter (measured: a recording saved one H.264 track at 640 × 480 and 15 frames a second, its length matched the gallery's index, and its poster came out upright; playback in the gallery wasn't checked).NSCameraUsageDescription, NSMicrophoneUsageDescription (video sound) and NSPhotoLibraryAddUsageDescription (Save Image from the share sheet); a Mac test fails if one is missing. Camera access denied: the preview says so and offers Open Settings. The microphone is asked for only when switching to video.PHPhotoLibrary, a web address or a required-reason API appears in the app's sources (privacy manifest files).On a real iPhone Duo, nothing in this list has run yet. references/device-checks.md lists each check and what to expect: capture in each pose, the second preview layer, mirroring, rotation on both displays, the accessory's conditions in book and tabletop, interruptions in Split View, and the movie's sound.
StudioControls, ShutterButton, SubjectView. Keep every control inside the controls' region and at least 44 pt.CaptureMode and CaptureService.configure, and to the mode button.PHPhotoLibrary save with add-only access, then update the privacy line in the usage strings, the manifest and the Mac checks together.Model/, keep it nonisolated and Sendable, add a check in Tools/ModelTests/main.swift and a line to its off-main-actor check.Keep these, whatever the app:
StudioSplit for every pose; regions from the fold's frame, never from half the width.On the Mac: Tools/run-model-tests.sh builds Model/*.swift with the test program using swiftc -swift-version 6 -default-isolation MainActor, like the app target. It checks the layout in every pose at sizes measured on the Duo simulator, the self-timer and the clock, camera access messages, the gallery's index (order, deletes, missing files, the current file format), the stand-in's frames (pixels, size, JPEG without alpha), the privacy scan of the sources, the manifest and the usage strings, and that every model type works off the main actor. Measured: 82 checks pass in a few seconds, in the template and in a freshly generated project.
On the simulator: Tools/run-ui-tests.sh. The tests use the stand-in camera (-standIn), start from launch switches (-timer, -mode, -shutter, -resetState), find elements by identifier and read the studio.state and gallery.state markers, so they never depend on the pose. Measured: all eight passed on the closed Duo simulator, in a freshly generated project, in two runs of 113 s and about 270 s. The first runs found two problems, now fixed and described in references/architecture.md.
Tools/run-ui-tests.sh -only-testing:SitterUITests/SitterUITests/testStudioLayoutInThisPose
Set the pose in Device Hub (or with duo-pose), then run that test once per pose. With duo-pose-matrix (needs the user's Accessibility permission):
duo-pose-matrix com.example.sitter --case "studio=-uiTesting -resetState -standIn -timer 10 -shutter"
scripts/new-project.sh; no __APP_NAME__ or __BUNDLE_ID__ left.Tools/run-model-tests.sh prints 0 failed, privacy and usage-string checks included.xcodebuild … build succeeds for the iPhone Duo simulator with no warnings from your code.python3 duo-lint.py --strict <project> reports no findings.Tools/run-ui-tests.sh passes.references/architecture.md (opens in a new tab)references/device-checks.md (opens in a new tab)scripts/new-project.sh (opens in a new tab)template/README.md (opens in a new tab)template/Tools/ModelTests/main.swift (opens in a new tab)template/Tools/run-model-tests.sh (opens in a new tab)template/Tools/run-ui-tests.sh (opens in a new tab)template/__APP_NAME__.xcodeproj/project.pbxproj (opens in a new tab)template/__APP_NAME__.xcodeproj/project.xcworkspace/contents.xcworkspacedata (opens in a new tab)template/__APP_NAME__.xcodeproj/xcshareddata/xcschemes/__APP_NAME__.xcscheme (opens in a new tab)template/__APP_NAME__/App/LaunchOptions.swift (opens in a new tab)template/__APP_NAME__/App/RootView.swift (opens in a new tab)template/__APP_NAME__/App/StudioStore.swift (opens in a new tab)template/__APP_NAME__/App/__APP_NAME__App.swift (opens in a new tab)template/__APP_NAME__/Assets.xcassets/AccentColor.colorset/Contents.json (opens in a new tab)template/__APP_NAME__/Assets.xcassets/AppIcon.appiconset/AppIcon.png (opens in a new tab)template/__APP_NAME__/Assets.xcassets/AppIcon.appiconset/Contents.json (opens in a new tab)template/__APP_NAME__/Assets.xcassets/Contents.json (opens in a new tab)template/__APP_NAME__/Capture/CameraPreview.swift (opens in a new tab)template/__APP_NAME__/Capture/CaptureService.swift (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kimeur/duology --plugin duology-recipes8 skills in this plugin
/recipe-finance-dashboardCreates a complete SwiftUI personal finance dashboard for iPhone Duo, Apple's foldable: balance and recent spending in one column on the closed outer display; balance, a Swift Charts spending chart and the transaction list side by side on the open inner display; an even 8-column grid with the fold as its middle gutter (DuoColumns and PaneFrames from duo-design-system); and list-detail for a transaction that survives fold and unfold. Use when someone wants to start a new finance, budgeting, banking, expenses or any dashboard app from scratch (a new Xcode project), or runs /duo-new recipe-finance-dashboard. For an existing app, use duo-design-system (grid) and duo-patterns (list-detail) instead. Covers FoldPanes reading the .division reserved region with includeInactive, one NavigationStack whose path comes from the selection, a delayed pop on unfold that keeps the margins right, money as whole cents, a Foundation-only model tested on the Mac, and UI tests that pass in any pose on the iPhone Duo simulator./recipe-kids-learningCreates a complete SwiftUI early-learning app for young children on iPhone Duo, Apple's foldable: counting, first letters and shapes, one question at a time with a spoken prompt and big answer buttons. Closed, the picture sits above the answers; open and held wide or folded like a book, the question takes the left page and the answers the right; in tabletop the picture sits above the fold and the answers below it. Use when someone wants to start a new kids, preschool or early-learning quiz app from scratch, or runs /duo-new recipe-kids-learning. Covers a parental gate (a seeded multiplication on a number pad) in front of a grown-ups area with reset and the privacy policy link, App Review guidelines 1.3 and 5.1.4 for the Kids Category, a privacy manifest with no tracking and no data collected, no networking with a Mac check that fails if it appears, AVSpeechSynthesizer prompts, VoiceOver, progress that survives folds and relaunch, a model tested on the Mac, and UI tests on the iPhone Duo simulator./recipe-media-playerCreates a complete SwiftUI video and podcast player for iPhone Duo, Apple's foldable: a library list-detail, a full-screen player whose playback survives every fold, unfold and rotation, a tabletop layout (video above the fold, the same controls below), a book layout (video leading, controls trailing), Picture in Picture, an up next card, a mini player and background audio. Use when someone wants to start a new video, podcast, course or streaming app from scratch, or runs /duo-new recipe-media-player. For an existing player, use duo-postures (tabletop media) and duo-continuity instead. Covers one AVPlayer, AVPlayerLayer and AVPictureInPictureController owned above the layout switch, FoldRegionsLayout reading the .division reserved region, NavigationSplitView selection kept in a model, an up next card inside the controls so it never sits in the fold, a Foundation-only model tested on the Mac, bundled sample clips made with ffmpeg, and UI tests that work on the iPhone Duo simulator./recipe-notes-aiCreates a complete SwiftUI notes app for iPhone Duo, Apple's foldable, with summaries from Apple's on-device model (Foundation Models): a headline, key points and to-dos per note, streamed in. Closed, the note fills the screen and the summary is one line with Details; open, flat or like a book, the note takes the left page and the summary pane the right; in tabletop the note sits above the fold and the summary below it. Use when someone wants to start a new notes, journal or writing app with AI summaries from scratch, or runs /duo-new recipe-notes-ai. Covers a @Generable result streamed into a window-owned service so a fold never restarts it, a simple summary without AI whenever the model is unavailable or fails (it fails on the simulator), Stop and labels that say what is AI, a prompt budget for the 4,096-token context, notes that never leave the device (no network, no Private Cloud Compute) with a privacy manifest and Mac checks that say so, and UI tests on the iPhone Duo simulator./recipe-readerCreates a complete SwiftUI reading app for iPhone Duo, Apple's foldable: a library shelf, then one page on the closed outer display, two facing pages split at the fold when the phone is open and held wide or folded like a book, and in tabletop the page above the fold with the page turns below it. Use when someone wants to start a new e-reader, book, story, essay or long-form reading app from scratch, or runs /duo-new recipe-reader. For an existing reader, use duo-reading instead. Covers the reading place kept as a chapter and character offset in a store above the navigation stack, TextKit 1 pagination that runs again after every fold, rotation and Dynamic Type change, ReaderLayout reading the .division reserved region, an even-column shelf split at the fold, an in-app text size menu, swipe and VoiceOver page turns, three sample books written for the template, a Foundation-only model tested on the Mac (the paginator too, through AppKit), and UI tests that work on the iPhone Duo simulator./recipe-shopCreates a complete SwiftUI shop for iPhone Duo, Apple's foldable, that sells digital packs and a subscription with StoreKit 2: a product grid with even columns that reflows from 2 per row on the closed outer display to 4 on the open inner display with the fold as its middle gutter, product detail beside the grid when open, a basket that checks out one App Store purchase at a time, and a two-pane paywall and checkout (what you get on one side, price and button on the other; one column with the button pinned when closed). Use when someone wants to start a new shop, catalog, in-app purchase or paywall app from scratch, or runs /duo-new recipe-shop. For an existing app, use duo-patterns (feed reflow, list-detail) instead. Covers a local StoreKit configuration file (no network, no real products), PurchaseAction, Transaction.updates and currentEntitlements, restore, Ask to Buy, SKTestSession in UI tests, a Foundation-only model tested on the Mac, and UI tests that pass in any pose on the iPhone Duo simulator.Other plugins' skills for the same job