/duology:duo-layoutfrom duology
Provides layout rules for iPhone Duo (Apple's foldable) covering size classes, asymmetric safe areas, reserved regions, ArrangementView, EvenSplit, and fold-safe grid columns for SwiftUI/UIKit.
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 has a compact outer display, a large inner display and a fold. Your app resizes every time someone opens, closes, rotates or folds it. This skill tells you how to lay out for that.
Load other skills for neighbouring work: duo-navigation (vertical bars, sidebars, sheets), duo-continuity (state that must survive a fold), duo-patterns (which layout pattern to pick).
Labels used below: measured means we ran it on the iPhone Duo simulator (iOS 27.1, fully open, held wide). Unverified means we could not confirm it. Everything else comes from Apple's pages, linked inline. Full source list: reference/sources.md.
NavigationSplitView, TabView, sheets, alerts). They avoid the fold on their own.ArrangementView for two views that sit side by side or overlap. Put NavigationStack or TabView around it. Never nest it with NavigationSplitView.EvenSplit, not ArrangementView.Apple's sources for these rules: the HIG page, the developer overview, and Tech Talks 111461, 111463 and 111466.
ArrangementView and its modifiers, reserved regions (ReservedRegion, reservedRegions(kind:options:)) and ContentMarginGuide with contentMargins(for:edges:alignment:) are new in iOS 27.1. Most apps deploy lower, and then these calls don't compile.
@available(iOS 27.1, *). The snippets in this skill already are.if #available(iOS 27.1, *). iPhone Duo ships with iOS 27.1, so the else branch only runs on other iPhones. Keep today's layout there: a stack or EvenSplit instead of an arrangement, plain padding instead of container margins, no fold handling.duo-start Step 1 shows how to read the deployment target.| Where | Width class | Height class |
|---|---|---|
| Outer display, portrait | compact | regular |
| Outer display, landscape | compact | compact |
| Inner display | regular | regular (measured fully open, held wide) |
One half of a side-by-side ArrangementView on the inner display | compact (measured) | regular (measured) |
One half of an EvenSplit | the window's class (measured: regular on the inner display) | the window's class |
Source: Tech Talk 111461. The inner display ignores your supported orientations, so orientation tells you nothing useful there.
Switch layouts with AnyLayout. The views keep their identity and state when the layout changes (AnyLayout).
import SwiftUI
struct LibraryScreen: View {
@Environment(\.horizontalSizeClass) private var widthClass
var body: some View {
let layout = widthClass == .regular
? AnyLayout(HStackLayout(alignment: .top, spacing: 16))
: AnyLayout(VStackLayout(alignment: .leading, spacing: 12))
layout {
AlbumHeader()
TrackList()
}
}
}
Replace these on sight:
| Don't | Do |
|---|---|
UIScreen.main.bounds, UIScreen.main.scale (deprecated since iOS 26) | the view's or scene's size; traitCollection.displayScale or @Environment(\.displayScale) |
UIDevice.current.userInterfaceIdiom == .pad | horizontalSizeClass == .regular |
UIDevice.current.orientation, interfaceOrientation | size classes, or the view's own width and height |
.frame(width: 390), if height == 844 | flexible frames, containerRelativeFrame, GeometryReader |
| a global screen | view.window?.windowScene?.screen, only when you truly need the screen |
Bars sit on the side on Duo. The bar edge can be left or right, for example in Split View. So the inset on one side says nothing about the other (HIG: account for asymmetry).
.ignoresSafeArea().ContentMarginGuide.container (iOS 27.1) can differ on each side next to a vertical bar (doc).import SwiftUI
struct ArticleScreen: View {
var body: some View {
ScrollView {
ArticleBody()
.duoContainerMargins()
}
.background {
HeroImage().ignoresSafeArea()
}
}
}
extension View {
/// The system container margins, which can differ per side on iPhone Duo.
/// Plain horizontal padding before iOS 27.1.
@ViewBuilder
func duoContainerMargins() -> some View {
if #available(iOS 27.1, *) {
contentMargins(for: .container, edges: .horizontal)
} else {
padding(.horizontal)
}
}
}
Never compute one inset and double it. In UIKit, inset by the real insets: view.bounds.inset(by: view.safeAreaInsets). See references/uikit.md.
A reserved region is part of your view that hardware or system UI claims (ReservedRegion).
| Kind | What it is | Active when |
|---|---|---|
.division | The fold. It splits the inner display into two usable areas. | The phone is partly folded. Flat, it is inactive and zero width. |
.occlusion | Something covering content: a camera, or other system UI (Apple lists the Dynamic Island and window controls). Measured: an active region also sits where the status bar is, on both displays (our reading; Apple doesn't label it). | Inner camera: while it runs. Outer camera: always. |
Facts you need:
.includeInactive to get the flat fold. Apple's ReservedRegion page says the opposite; the talk and our probe agree with each other. Filter on isActive anyway, so your code works either way.margins on each side. frame includes the margins.onAppear.layoutDirectionBehavior: .fixed to stop that.Move a control off the fold (Apple calls this displacement, 111463):
import SwiftUI
@available(iOS 27.1, *)
struct FoldAvoidingControls<Controls: View>: View {
@ViewBuilder var controls: Controls
var body: some View {
GeometryReader { proxy in
let area = Self.controlArea(in: proxy)
controls
.frame(width: area.width, height: area.height)
.position(x: area.midX, y: area.midY)
}
}
/// The whole view when flat. When folded, the side after the fold:
/// trailing for a top-to-bottom fold, bottom for a side-to-side fold.
static func controlArea(in proxy: GeometryProxy) -> CGRect {
let bounds = CGRect(origin: .zero, size: proxy.size)
let folds = proxy.reservedRegions(kind: .division).filter(\.isActive)
guard let fold = folds.first?.frame, fold.intersects(bounds) else { return bounds }
if fold.height >= fold.width {
return CGRect(x: fold.maxX, y: 0, width: bounds.maxX - fold.maxX, height: bounds.height)
}
return CGRect(x: 0, y: fold.maxY, width: bounds.width, height: bounds.maxY - fold.maxY)
}
}
Grids: use an even number of columns when a division exists, so the fold falls between cells. Count with .includeInactive, so the column count doesn't jump when someone folds (111463). Code: references/reserved-regions.md.
More (measured values, occlusions, a player for both fold directions, UIKit): references/reserved-regions.md.
A layout container for a primary and a secondary view. It adapts to size, size class and the fold (ArrangementView).
.split (the default, also what .automatic resolves to): side by side or stacked. Use it where you would write HStack or VStack..overlay: primary on top of secondary; side by side when folded. Use it where you would write ZStack, such as controls over a video..split.axes(.horizontal). If it can't split on an allowed axis, it shows only the primary view.import SwiftUI
@available(iOS 27.1, *)
struct NowPlayingScreen: View {
var body: some View {
NavigationStack {
ArrangementView {
PlayerView()
} secondary: {
UpNextView()
}
.arrangementViewStyle(.split)
.navigationTitle("Now Playing")
}
}
}
Rules:
NavigationStack and TabView around the arrangement, never inside it (HIG, 111463).NavigationSplitView and arrangements apart. No split view inside an arrangement (111463), and no arrangement inside a split view or one of its columns (overview). The HIG's wording allows a split view around an arrangement; Duology follows the overview and the talk, as duo-patterns does.List or ScrollView (overview)..automatic and .split show only the primary view. The secondary is never drawn, though its onAppear still runs. With compact width and regular height (closed, portrait) they stack the two views.splitArrangementAxis, overlayArrangementZIndex and size classes in a view nested inside the half (for example inside a ZStack). The view you pass directly read the default values in our probe.Details, the behaviour table and the UIKit UIArrangementViewController: references/arrangement-view.md.
Two players, a game board and its tray, a teacher and a student: these need both halves in every pose, including closed and sideways. ArrangementView hides one there. Use an even split you control. The same type ships in the gallery app at samples/DuologyGallery/DuologyGallery/Shared/EvenSplit.swift.
import SwiftUI
/// Two equal halves that always show. Side by side when the view is wider
/// than tall, stacked otherwise. AnyLayout keeps each half's state when the
/// axis flips.
struct EvenSplit<Primary: View, Secondary: View>: View {
var spacing: CGFloat = 0
@ViewBuilder var primary: () -> Primary
@ViewBuilder var secondary: () -> Secondary
var body: some View {
GeometryReader { proxy in
let wide = proxy.size.width >= proxy.size.height
let half = wide
? CGSize(width: max(0, (proxy.size.width - spacing) / 2), height: proxy.size.height)
: CGSize(width: proxy.size.width, height: max(0, (proxy.size.height - spacing) / 2))
let layout = wide
? AnyLayout(HStackLayout(spacing: spacing))
: AnyLayout(VStackLayout(spacing: spacing))
layout {
primary().frame(width: half.width, height: half.height)
secondary().frame(width: half.width, height: half.height)
}
}
}
}
import SwiftUI
struct DuelScreen: View {
var body: some View {
EvenSplit(spacing: 2) {
PlayerHalf(player: 1)
} secondary: {
PlayerHalf(player: 2)
}
.background(Color.secondary)
}
}
Fit content to its half, not to the device:
duo-shared-screen and duo-design-review: the safe area is 382 × 644 pt of a 466 × 678 pt window, with 84 pt trailing and 34 pt at the bottom). A split that ignores the safe area gets 466 × 339 pt halves. Held sideways, plan for two halves of at most about 339 × 466 pt side by side (derived, not measured). Drop labels, then shrink spacing, before you shrink touch targets. ViewThatFits code: references/custom-split.md.EvenSplit always puts its seam at the middle of its own frame. If a vertical bar narrows the view, that middle is not the fold. To put the seam on an active fold, use FoldSplitLayout in references/custom-split.md.
An EvenSplit half keeps the window's size classes, so on the inner display a 338 pt half still reads regular width (measured). Inside a half, lay out by the half's size, as above, not by its size class.
ScrollView) may cross the fold. Don't displace it.Same rules: traitCollection size classes, safeAreaInsets per side, view.reservedRegions(kind:options:), UIArrangementViewController, and a UIStackView with .fillEqually for an even split. Code: references/uikit.md.
xcrun simctl io booted screenshot --display=primary outer.png (outer) and xcrun simctl io booted screenshot --display=primary-1 inner.png (inner).simctl cannot change the pose (measured). Pose changes happen in Device Hub only.UIScreen.main, userInterfaceIdiom, device orientation or fixed device sizes drive layout.horizontalSizeClass / verticalSizeClass, with AnyLayout where the same views change axis..division regions and move when the fold is active.isActive and handles an empty first pass.ArrangementView sits inside NavigationStack or TabView only: no NavigationSplitView inside or around it, and no List or ScrollView around it.@available and if #available.EvenSplit (or FoldSplitLayout), checked closed and sideways.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-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-scenesScenes and windows on iPhone Duo, Apple's foldable. Use when an app opens a second window (openWindow, WindowGroup(for:), activateSceneSession, UISceneSessionActivationRequest, UIWindowScene.ActivationAction), handles new-window requests on the outer display and their errors, asks before a window closes (closureConfirmation), runs in 50/50 Split View, shows content on the outer display while the camera runs on the inner display (sceneAccessory, CameraCaptureAccessory, onAvailabilityChange, UISceneAccessory, registerSceneAccessory, UISceneAccessoryRegistration, windowCameraCaptureAccessory, ExternalNonInteractiveAccessory), restores state per window (@SceneStorage, stateRestorationActivity), or reacts to the UIScene lifecycle when the phone folds or unfolds (scenePhase, didUpdateEffectiveGeometry, UIWindowScene.screen)./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