/duology:duo-scenesfrom duology
Guides implementing multi-window scenes on iPhone Duo (Apple's foldable): opening second windows, handling outer-display errors, Split View 50/50 layout, scene accessories for camera passthrough, per-window state restoration, and fold/unfold lifecycle.
Ships in duology. 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 is the first iPhone that can show more than one window of the same app. It also runs two apps side by side on the inner display, and it can put a camera app's extra content on the outer display. All of this goes through scenes. This skill tells you how to open windows safely, how to use scene accessories, and how to keep each window's state.
Load other skills for neighbouring work: duo-layout (size classes, half-width layouts in Split View), duo-continuity (state that survives a fold inside one window), duo-navigation (bars on the outer edge in Split View), duo-pose-matrix (set the simulator's pose from a script), duo-testing (UI tests on the simulator).
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1) on 18 October 2026, closed and fully open, with no camera; see references/evidence.md. Unverified means we could not confirm it. Everything else comes from Apple's pages, linked inline. Full source list: reference/sources.md.
| Feature | What Apple says | Source |
|---|---|---|
| Several windows of one app | If your app supports several windows on iPad, it does on iPhone Duo too. | Tech Talk 111464 |
| New windows | Only the inner display can create one. Requests on the outer display fail, so handle errors. UIWindowScene.ActivationAction hides itself when a new window isn't possible. | 111464 |
| Split View | Every app takes part. Two apps share the inner display 50/50, each with its bars on its outer edge. A pinned Picture in Picture video can sit on top and resize the app below. | 111464, Tech Talk 111466, HIG |
| Scene accessories | The system can show your extra content on another display. A camera capture accessory uses the outer display while the camera UI runs full screen on the inner display. | 111464, Registering a camera capture accessory |
UIWindowScene.ActivationAction(title:alternate:_:) with the alternate: label, or an explicit return. The short form crashes (section 3)..background. Read windowScene.screen when you need it; never cache it.Add the scene manifest key to the app's Info.plist. Apps without it get one window (UIApplicationSupportsMultipleScenes).
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
</dict>
plutil -p <App>.app/Info.plist | grep -A2 SceneManifest.supportsMultipleWindows were both true on the closed phone. Apple's supportsMultipleWindows page still says only iPadOS and macOS return true. Neither value tells you which display you're on.duo-layout.Declare a WindowGroup(for:) per kind of content and open it with openWindow(value:). If a window already shows that value, the system brings it forward (OpenWindowAction).
import SwiftUI
import Observation
struct Note: Identifiable, Hashable, Codable, Sendable {
var id = UUID()
var title: String
}
@MainActor @Observable
final class NoteStore { // one per app, shared by every window
var notes = [Note(title: "Groceries"), Note(title: "Trip")]
func note(_ id: Note.ID?) -> Note? { notes.first { $0.id == id } }
}
struct NotesApp: App { // mark it @main in your app
@State private var store = NoteStore()
var body: some Scene {
WindowGroup {
NoteList().environment(store)
}
WindowGroup("Note", for: Note.ID.self) { $id in
NoteDetail(id: id).environment(store)
}
}
}
struct NoteList: View {
@Environment(NoteStore.self) private var store
@Environment(\.openWindow) private var openWindow
@Environment(\.supportsMultipleWindows) private var supportsMultipleWindows
@State private var path: [Note.ID] = [] // each window keeps its own
var body: some View {
NavigationStack(path: $path) {
List(store.notes) { note in
NavigationLink(note.title, value: note.id) // works in every window
.contextMenu {
if supportsMultipleWindows {
Button("Open in New Window", systemImage: "plus.rectangle.on.rectangle") {
openWindow(value: note.id)
}
}
}
}
.navigationDestination(for: Note.ID.self) { NoteDetail(id: $0) }
}
}
}
struct NoteDetail: View {
@Environment(NoteStore.self) private var store
let id: Note.ID?
var body: some View { Text(store.note(id)?.title ?? "Note not found") }
}
openWindow has no error callback. Where multiple windows aren't supported, SwiftUI ignores the call and logs an error (supportsMultipleWindows).openWindow(id:) raised no error. The new window took the whole display (951 × 669 pt when open, not half), and the old one moved to the background, still connected. Split View comes from people dragging a window aside, not from your request. When the app later launched with two saved windows, the system showed a "2 Views Open" pill. That is why rule 2 matters: people may not find the old window again.Ask with activateSceneSession(for:errorHandler:) and a UISceneSessionActivationRequest (both iOS 17). When it fails with a UISceneError, show the content in the current window.
import UIKit
enum NoteActivity {
static let type = "com.example.notes.open" // list it under NSUserActivityTypes
static func make(noteID: UUID) -> NSUserActivity {
let activity = NSUserActivity(activityType: type)
activity.targetContentIdentifier = noteID.uuidString
activity.userInfo = ["noteID": noteID.uuidString]
return activity
}
}
@MainActor
func openInNewWindow(noteID: UUID, otherwise showHere: @escaping @MainActor @Sendable () -> Void) {
let app = UIApplication.shared
guard app.supportsMultipleScenes else { showHere(); return }
let request = UISceneSessionActivationRequest(userActivity: NoteActivity.make(noteID: noteID))
app.activateSceneSession(for: request) { error in
let code = (error as? UISceneError)?.code // .multipleScenesNotSupported, .requestDenied
print("No new window:", code.map { "\($0)" } ?? "\(error)")
Task { @MainActor in showHere() }
}
}
In menus, use UIWindowScene.ActivationAction; its handler returns a UIWindowScene.ActivationConfiguration. Give it an alternate: action that opens the note in place, and don't list that action again. Apple's header says the alternate replaces the action where multiple windows aren't supported, and runs if the request fails.
import UIKit
@MainActor
func openNoteMenu(noteID: UUID, showHere: @escaping @MainActor () -> Void) -> UIMenu {
let inPlace = UIAction(title: "Open", image: UIImage(systemName: "doc.text")) { _ in showHere() }
let newWindow = UIWindowScene.ActivationAction(title: "Open in New Window", alternate: inPlace) { _ in
UIWindowScene.ActivationConfiguration(userActivity: NoteActivity.make(noteID: noteID))
}
return UIMenu(children: [newWindow]) // shows "Open" where no window can open
}
alternate: nil it was missing, as Apple says, and with an alternate the alternate took its place. The raw requests still succeeded there (section 2), so the action is the more reliable signal.UIWindowScene.ActivationAction(title: "X") { _ in config } compiles with only a warning ("result ... is unused"), because Swift picks UIAction's handler initializer. At runtime it throws NSInternalInconsistencyException ("Initializer is unavailable"). Always write alternate: (even alternate: nil) or return config.connectionOptions.userActivities.first (doc). Code: references/multiple-windows.md.A scene accessory is extra content you declare. The system decides if, when and where to show it (sceneAccessory(content:)). Two kinds exist in the iOS 27.1 SDK:
| Accessory | Where it shows | Interactive | Since |
|---|---|---|---|
CameraCaptureAccessory / UISceneAccessory.cameraCapture(sceneConfiguration:) | The outer display, while your camera UI runs on the inner display | Yes, keep it minimal | iOS 27.1 |
ExternalNonInteractiveAccessory / UISceneAccessory.externalNonInteractive(sceneConfiguration:) | A connected or AirPlay display. Apple names no other. | No | iOS 27.0 |
The camera capture accessory shows only when all of these hold (111464, Apple's guide): the phone is fully open, your app is in the foreground and full screen on the inner display, a capture session is running (Apple's overview names the rear camera), and the view that registered it is on screen. It goes away when capture stops, the app leaves the foreground, the phone closes, or a deeper view registers its own.
import SwiftUI
import Observation
@MainActor @Observable
final class ShootModel {
var secondsToStart: Int? // countdown the subject sees
var isRecording = false
var showsSubjectView = true // the photographer can turn it off
var subjectViewAvailable = false // only the system sets this
}
@available(iOS 27.1, *)
struct CaptureScreen: View {
@State private var model = ShootModel()
var body: some View {
NavigationStack { // toolbar items show only inside a navigation container
CameraPreview() // your capture UI; it runs the capture session
.sceneAccessory {
CameraCaptureAccessory(isEnabled: $model.showsSubjectView) {
SubjectView(model: model)
}
.onAvailabilityChange { model.subjectViewAvailable = $0 }
}
.toolbar {
if model.subjectViewAvailable {
Toggle("Subject View", systemImage: "person.crop.rectangle", isOn: $model.showsSubjectView)
}
}
}
}
}
struct SubjectView: View { // what the person in front of the camera sees
let model: ShootModel
var body: some View {
if let seconds = model.secondsToStart {
Text("\(seconds)").font(.system(size: 160, weight: .bold))
} else {
Label(model.isRecording ? "Recording" : "Ready", systemImage: "record.circle")
.font(.largeTitle)
}
}
}
struct CameraPreview: View { // stand-in for your preview layer
var body: some View { Color.black.ignoresSafeArea() }
}
isEnabled, not by removing it. Availability and enabled are separate: the system owns the first, you own the second. It's on by default.true and the system made a scene with role windowCameraCaptureAccessory on the outer screen (466 × 678 pt). Closing the phone set it to false and discarded that session; reopening made a new scene and new content views. Closed at launch, it stayed false. A second window in front made the first window's accessory unavailable.if #available(iOS 27.1, *). If the target also builds for Mac Catalyst, wrap it in #if !targetEnvironment(macCatalyst) too: the accessory types don't exist there. Code, the UIKit version, both accessories at once and camera direction per display: references/scene-accessories.md.Each window is its own scene session, with its own saved state.
@SceneStorage is per window (SceneStorage). Measured: a new window started at 0 while the first window held 7. After a relaunch the system reconnected only the last window used. Activating the other saved session brought back its 7.NSUserActivity from stateRestorationActivity(for:) and read session.stateRestorationActivity when the scene connects.duo-continuity covers that.com.apple.SwiftUI.stateRestoration). Don't read or replace it.session.role before deleting per-window data.Apple says opening and closing work like resizing the app in iPhone Mirroring (Tech Talk 111461). For a scene this means it moves to the other screen and changes size:
| Event | What to expect | Source |
|---|---|---|
| Window moves between displays | windowScene(_:didUpdateEffectiveGeometry:) (iOS 26) always fires, and windowScene.screen changes. Measured: same scene and session, the size class flipped. | doc, evidence |
| Display link | windowScene.displayLink(target:selector:) (iOS 27) follows the scene to the new display. UIScreen's version is deprecated in iOS 27 (UIScreen.h). | doc |
| Scene phase during a fold | Measured: scenePhase stayed active through close and open. No inactive, no new onAppear. | evidence |
| Two windows in Split View, then close | Unverified which one moves to the outer display | Split View needs a drag in Device Hub |
| Any window going to the background (covered by another window, or the whole app) | Measured: inactive, then background, still connected. In 5 of 6 runs, two geometry updates followed within 0.2 s, with no fold. Closed: 466 × 678 to 951 × 669 pt and back, width class unchanged. Open: 951 × 669 to 466 × 678 pt and back, width class regular, compact, regular. | closed, open |
So:
.inactive or sceneWillResignActive(_:). Save on .background.scenePhase == .active, check again when the phase returns to .active, and keep one view tree for both widths so @State survives (duo-continuity). Code for both: references/restoration-and-lifecycle.md.onAppear size. Measured: a new window's first layout reported 466 × 562 pt, then 382 × 644 pt.Scene delegate code for new windows, a close confirmation for windows with unsaved work (closureConfirmation, iOS 27), restoration, geometry updates, the accessory registration and the accessory's own scene delegate: references/multiple-windows.md, references/scene-accessories.md, references/restoration-and-lifecycle.md.
duo-pose set open from duo-pose-matrix. The pose applies to everything on the shared simulator, and duo-pose refuses while UI tests run. Open a second window, then drag your app by its home indicator to each side for Split View (Tech Talk 111461). Close the phone the same way (duo-pose set closed) with two windows open and note which one stays.xcrun simctl io booted screenshot --display=primary outer.png and --display=primary-1 inner.png.What the simulator can't tell you:
| Check | Why | Do instead |
|---|---|---|
| Camera capture accessory conditions | The simulator has no camera, and in the Duo simulator the accessory shows without a capture session (Xcode 27.1 release notes) | Check its layout in the simulator; test availability on a real iPhone Duo with capture running, then stop capture and close the phone |
| Touch on the accessory | It needs the accessory shown for real, with capture running | Real device |
| The outer display refusing new windows | Our simulator didn't refuse | Real device; keep the in-place fallback either way |
UIApplicationSupportsMultipleScenes is set only if every window works alone; one model per window, one shared store.ActivationAction uses alternate: (or an explicit return), never the short trailing-closure form.UISceneSessionActivationRequest(session:), not duplicates.#available(iOS 27.1, *), and behind #if !targetEnvironment(macCatalyst) when the target builds for Mac Catalyst..background; nothing tears down on .inactive; size and size-class reactions run only while the scene is active, and catch up when it becomes active.UIScreen; display links come from the window scene.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub kimeur/duology --plugin duology6 skills in this plugin
/duo-continuityKeeps app state alive when iPhone Duo, Apple's foldable, folds, unfolds, rotates or resizes between the outer display and the inner display. Use when scroll position, video or audio playback, typed text, keyboard focus, selection, form input, the selected item, the navigation stack, an upload or sign-in resets or reloads on fold or unfold, and when writing or reviewing @Observable models, @SceneStorage, NavigationPath, NavigationSplitView, ScrollPosition, AnyLayout, .id, onAppear, .task, registerForTraitChanges or viewWillTransition(to:with:)./duo-layoutCore layout rules for iPhone Duo, Apple's foldable. Use when content lands in the fold, a screen breaks on the inner or outer display, or you write SwiftUI or UIKit layout for a foldable. Covers size classes instead of UIScreen.main, idiom or orientation, asymmetric safe areas and margins, reserved regions (ReservedRegion, reservedRegions(kind:options:), .division, .occlusion, .includeInactive), ArrangementView and UIArrangementViewController (split and overlay styles), an even custom split (EvenSplit) for two halves that must always show, even grid columns, and keeping controls off the fold./duo-navigationGets toolbars, navigation bars, tab bars, split views and sheets right on iPhone Duo, Apple's foldable, where bars move into one vertical bar on the side of the outer display and of the inner display in landscape. Use it when bars go vertical, items overflow or vanish, an app draws its own custom bottom bar (UIToolbar, or a SwiftUI row in safeAreaInset or an overlay), toolbar or Menu buttons are icon-only, tabs should become a sidebar on the inner display, a sheet should sit to one side or off the fold, or code touches toolbarVerticalBehavior, toolbarVerticalEdge, axisBehavior, visibilityPriority, topBarPinnedTrailing, ToolbarOverflowMenu, toolbarVerticalCompressionBehavior, defaultTabBarPlacement, presentationPlacement, NavigationSplitView, preferredVerticalBarBehavior, verticalBarEdge, pinnedTrailingGroup, additionalOverflowItems, UITabBarController.Sidebar.preferredPlacement or UISheetPresentationController.preferredPlacement./duo-setupSets up a Mac to build, run and test apps for iPhone Duo, the foldable iPhone with an outer display and an inner display, covering Xcode 27.1 next to an older Xcode with DEVELOPER_DIR (no sudo xcode-select), xcodebuild -version, the iOS 27.1 SDK and runtime, the iPhone Duo simulator in Device Hub (xcrun simctl create/bootstatus, a screenshot of each display, the Closed / Partially Open / Open poses and the fold angle), Xcode's MCP server for Claude Code (xcrun mcpbridge, MCP_XCODE_PID, xcrun agent skills export) and project settings (IPHONEOS_DEPLOYMENT_TARGET, SWIFT_VERSION 6, SWIFT_DEFAULT_ACTOR_ISOLATION MainActor, SWIFT_APPROACHABLE_CONCURRENCY, synchronized folders). Use it when the Mac or project isn't ready for iPhone Duo work (duo-start or /duo-doctor sends you here), when /duo-doctor fails, when xcodebuild picks the wrong Xcode, when the Duo simulator, iOS 27.1 runtime or hinge pose is missing, or when Claude Code can't reach Xcode./duo-startEntry point for iPhone Duo, Apple's foldable with an outer display, an inner display and a fold; use it first when someone asks to get an app ready for iPhone Duo, make it work on the foldable or survive fold and unfold, or doesn't know which Duology skill to load. It detects SwiftUI or UIKit, new or existing app, the Xcode and iOS SDK the app builds with (iOS 26, 27 or 27.1 behaviour on Duo), the deployment target and the UIKit scene life cycle, runs a five-minute first pass (Xcode 27.1 build, duo-lint, closed and open on the iPhone Duo simulator in Device Hub) and routes to duo-setup, duo-layout, duo-navigation, duo-continuity, duo-scenes, duo-patterns, the design skills (duo-design-system, duo-postures, duo-transitions, duo-ergonomics, duo-accessibility), the iOS 27 feature skills in duology-features, duo-testing, duo-pose-matrix, duo-lint, the recipes and Apple's App Resizability skill (xcrun agent skills export).Other plugins' skills for the same job