/duology-features:duo-swiftui-27from duology-features
Covers iOS 27 SwiftUI changes specific to iPhone Duo's foldable form factor: @State macro through folds, reorderable grids across displays, swipe actions outside List, Tab(role: .prominent), toolbar minimization, AsyncImage caching, and resizable apps. Load when Xcode 27.1 breaks a Duo view or when adopting new tab/toolbar/dialog APIs.
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.
Every app that builds with Xcode 27 gets the iOS 27 SwiftUI changes. On iPhone Duo they show up more, because the app resizes each time someone opens, closes, rotates or folds the phone. This skill covers what that changes. For the rest of iOS 27 SwiftUI, use Apple's own skill (below).
Load neighbours when the task needs them: duo-navigation (vertical bars, ranking toolbar items), duo-continuity (state through a fold), duo-patterns (grids and two-pane layouts), duo-system-surfaces (the Dynamic Island that shares the side column with your bars).
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1, 20 October 2026) with a probe app that logged its own size and fold. Unverified means we could not confirm it. Everything else links to Apple. Runs and logs: references/evidence.md. Sources: reference/sources.md.
Xcode 27 ships two SwiftUI agent skills: swiftui-whats-new-27 (the new APIs) and swiftui-specialist (best practices) (What's new in SwiftUI, WWDC26 session 269). Export them with xcrun agent skills export --output-dir <folder> and load swiftui-whats-new-27 when you adopt any API below. Duology links to it and never copies it.
One name differs. The talk and Apple's skill call the scroll-minimizing modifier toolbarMinimizeBehavior. The iOS 27.1 SDK has no such symbol. Write toolbarMinimizationBehavior(_:for:) with ToolbarMinimizationBehavior (doc).
init sets a @State value, remove the inline default.@State. Never do once-only work in a view's init: a fold runs it again.nonisolated..prominent tab, for the action that isn't a place (cart, compose). It sits apart at the foot of the vertical tab bar.visibilityPriority(_:). The Dynamic Island grows in the same side column.if #available(iOS 27.0, *) when the app deploys lower. iPhone Duo runs iOS 27.1, so the fallback runs only on other iPhones.@State and an init with a real build or swiftc -emit-sil. -typecheck misses the TN3211 initialization error (measured).| Needs iOS 27.0 | Builds for any target with Xcode 27 |
|---|---|
reorderable(), reorderable(collectionID:), reorderContainer(for:...), swipeActionsContainer(), swipeActions(edge:allowsFullSwipe:content:onPresentationChanged:), TabRole.prominent, toolbarMinimizationBehavior(_:for:), visibilityPriority(_:), ToolbarOverflowMenu, topBarPinnedTrailing, AsyncImage(request:...), asyncImageURLSession(_:) | the @State macro, ContentBuilder, alert(_:item:actions:), confirmationDialog(_:item:titleVisibility:actions:) (inlined into your app; measured: they typecheck at an iOS 15 target) |
Availability comes from the iOS 27.1 SDK interfaces; see the API index.
@State is now a macro. A class you store in it is created once per view, not on every init of the view struct (TN3211, session 269).
Measured: through one unfold and one fold, a parent that reads its size rebuilt its children four times, passing through 466 × 562 pt and 951 × 553 pt on the way. A class held with @State was created once. The same class built with State(wrappedValue:) in the declaration, which is the old timing, was created five times.
import SwiftUI
@Observable
final class LibraryModel {
var books: [String] = []
}
struct LibraryScreen: View {
@State private var model = LibraryModel() // created once, however often the phone folds
var body: some View {
List(model.books, id: \.self) { Text($0) }
.task { /* load once here, not in init */ }
}
}
Source breaks, by shape:
@State var page = 0 plus self.page = startPage in init, before another stored property: "variable ... used before being initialized", but only in a real build. If the assignment comes last, it compiles and the default wins at run time (measured: the view showed page 0, not 42). Remove the default.@State property, or a memberwise init called from an extension: errors whose wording in Xcode 27.1 differs from TN3211's..overlay(Color.blue.opacity(0.7)), a constraint that spells TupleView, or an empty Group { } with MapKit visible: ContentBuilder ambiguity errors.Fixes, the exact messages we saw and the probe code: references/state-and-builders.md.
reorderable() on a ForEach and reorderContainer(for:isEnabled:move:) on its stack, grid or layout add the system drag, placeholder and animation to any container, not only List (doc). The move closure hands you a ReorderDifference; you apply it to your data.
import SwiftUI
// requires: Book, BookCover, applyReorder (references/reorder-and-swipe.md)
@available(iOS 27.0, *)
struct ShelfGrid: View {
@Binding var books: [Book]
@Environment(\.horizontalSizeClass) private var widthClass
var body: some View {
// Even column counts, so the fold falls between columns on the inner display.
let count = widthClass == .regular ? 4 : 2
ScrollView {
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 12), count: count), spacing: 12) {
ForEach(books) { book in
BookCover(book: book)
}
.reorderable()
}
.reorderContainer(for: Book.self) { difference in
books.applyReorder(difference)
}
.padding()
}
}
}
Measured with a UI test in three poses: closed (2 columns), open with the fold inactive (4 columns), and in book pose with the fold active (4 columns). A drag from the first tile onto the fourth reordered the grid every time; open and in book it crossed the middle of the display, where the fold is. Two collections in one container, one on each side of the fold, also worked in all three poses: a card dropped on the other list moved there. That suits book pose (later and today, library and playlist).
reorderContainer(for:in:isEnabled:move:) and tag each ForEach with reorderable(collectionID:).nonisolated enum Lane: Hashable, Sendable. Otherwise the build fails (measured; message in the reference).Full code (apply helper, two lanes, UI tests that reach the drag): references/reorder-and-swipe.md.
swipeActions now works on rows in a ScrollView, LazyVStack or grid. Add swipeActionsContainer() to the container so only one row stays open, and scrolling or a tap elsewhere closes it (doc). That matters on the inner display, where a custom two-column inbox can't be a List.
import SwiftUI
// requires: Message (references/reorder-and-swipe.md)
@available(iOS 27.0, *)
struct InboxColumn: View {
@Binding var messages: [Message]
@State private var openRows = 0
var body: some View {
ScrollView {
LazyVStack(spacing: 0) {
ForEach(messages) { message in
Text(message.subject)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(.background)
.swipeActions(edge: .trailing) {
Button("Delete", systemImage: "trash", role: .destructive) {
messages.removeAll { $0.id == message.id }
}
} onPresentationChanged: { isShown in
openRows += isShown ? 1 : -1
}
}
}
}
.swipeActionsContainer()
}
}
Measured closed, open and in book pose: swipeLeft() on a row revealed Delete and onPresentationChanged reported it open. The action sits at the row's trailing edge. In a row that spans the inner display, that edge is beside the vertical bar, not near the fold. In UI tests the revealed button's label was "Delete, Delete" (symbol and title), so app.buttons["Delete"] found nothing; match with BEGINSWITH.
Tab(role: .prominent) sets one tab apart (doc, session 269). Only one tab gets it; without one, a .search tab may take the look.
import SwiftUI
// requires: ShopScreen, PacksScreen, SavedScreen, CartScreen (your screens)
@available(iOS 27.0, *)
struct StoreRoot: View {
var body: some View {
TabView {
Tab("Shop", systemImage: "bag") { ShopScreen() }
Tab("Packs", systemImage: "square.stack") { PacksScreen() }
Tab("Saved", systemImage: "heart") { SavedScreen() }
Tab("Cart", systemImage: "cart", role: .prominent) { CartScreen() }
}
}
}
Measured: closed, and open held wide, the tab bar is vertical on the trailing side and the prominent tab is a separate round button at its foot. Held tall on the inner display, the bar is horizontal at the bottom and the prominent tab sits at its trailing end. The vertical bar shows no titles, so give the tab a symbol that reads alone.
visibilityPriority(_:), ToolbarOverflowMenu and topBarPinnedTrailing decide what stays in a crowded bar (session 269). On Duo the crowding is vertical: your bar shares the side column with the status bar and the Dynamic Island, which grows as Live Activities arrive, and app items collapse into the overflow menu when room runs out (Tech Talk 111466). How to order and rank items for the vertical bar: duo-navigation.
toolbarMinimizationBehavior(.onScrollDown, for: .navigationBar) shrinks the navigation bar as people scroll. Only .navigationBar supports it (doc). Measured on Duo: the title area at the top shrank (the top inset went from 82 to 24 pt) while the buttons in the side column stayed where they were, closed, open and in book pose. Details and the companion modifiers: references/toolbars-tabs-dialogs.md.
alert(_:item:actions:) and confirmationDialog(_:item:titleVisibility:actions:) present while the binding is non-nil and pass the value to the actions, like sheet(item:) (session 269).
import SwiftUI
// requires: Draft with a static `samples` list (your model)
struct DraftsList: View {
@State private var pendingDelete: Draft?
var body: some View {
List(Draft.samples) { draft in
Button(draft.title) { pendingDelete = draft }
}
.confirmationDialog("Delete draft?", item: $pendingDelete) { draft in
Button("Delete \(draft.title)", role: .destructive) { delete(draft) }
}
}
private func delete(_ draft: Draft) {}
}
Keep the item in state above the layout switch, so a fold doesn't lose it. Measured: a dialog opened closed stayed up through unfolding and folding into book pose, and moved beside its button, off the fold. System sheets, alerts and menus move out of the fold by themselves (Tech Talk 111466). Don't position them yourself.
In iOS 27, AsyncImage keeps downloaded images in an HTTP cache that follows the server's cache headers, with no code change (doc, session 269). On Duo it matters when a fold rebuilds your image views.
Measured with a local server that sends Cache-Control: max-age=3600, through closed, open, closed, open:
LazyVGrid that only changes from 2 to 4 columns kept its loaded images through every fold, with or without the cache. No refetch either way.List closed, a grid open) rebuilds every image view. With the cache bypassed it refetched 7 or 8 images on each fold and unfold. With the default cache it fetched 8 images in all, and none after the first unfold.Numbers and the probe: references/async-image.md.
import SwiftUI
@available(iOS 27.0, *)
struct CoverWall: View {
let urls: [URL]
// One session for the whole wall, with room for a few hundred covers.
private static let session: URLSession = {
let configuration = URLSessionConfiguration.default
configuration.urlCache = URLCache(memoryCapacity: 32_000_000, diskCapacity: 256_000_000)
return URLSession(configuration: configuration)
}()
var body: some View {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 140))]) {
ForEach(urls, id: \.self) { url in
AsyncImage(url: url) { $0.resizable().scaledToFill() } placeholder: { Color.secondary.opacity(0.2) }
.frame(height: 180)
.clipped()
}
}
.asyncImageURLSession(Self.session)
}
}
The server's headers decide what the cache keeps. If covers never change, send a long max-age rather than forcing a cache policy in the app.
In iOS 27 iPhone apps resize: in iPhone Mirroring on the Mac and as an iPhone app on iPad (session 269). Opening and closing iPhone Duo works the same way (Tech Talk 111461). An app that resizes well there is most of the way to Duo.
duo-layout.@State and an init, run swiftc -emit-sil -o /dev/null or a full build.press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:) (duo-testing).@State property has both an inline default and an assignment in init.@State or above the layout switch.reorderable() and reorderContainer, with even column counts; collection ID types are nonisolated.swipeActionsContainer()..prominent tab, with a symbol that reads without its title.ToolbarOverflowMenu.toolbarMinimizationBehavior(_:for:), the SDK name.item: form, with the item stored above the layout switch.AsyncImage with cacheable server headers, not hand-made reload code.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-cameraCamera capture on iPhone Duo, Apple's foldable. Use when an app takes photos or video, runs a video call or shows a camera preview, and must work closed (outer display), open (inner display), partly folded (book, tabletop), open and turned around (flipped) and through fold and unfold. Covers the virtual front camera (.builtInWideAngleCamera or .builtInUltraWideCamera at .front; shared features only, up to 1080p at 60 fps, no depth), the physical front cameras (.builtInOuterUltraWideCamera, .builtInInnerUltraWideCamera), choosing a camera by the way it faces with AVCaptureDeviceDirectionCoordinator (AVKit) and AVCaptureDeviceDescriptor, mirroring a rear-camera selfie, AVCaptureDevice.RotationCoordinator across displays, the square front sensor and dynamicAspectRatio, a subject preview on the outer display with CameraCaptureAccessory, tabletop hands-free capture, and Split View interruptions. The simulator has no camera: the code typechecks; capture is unverified on a device./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./duo-intelligenceAdds Foundation Models to an iPhone Duo app: the on-device model (SystemLanguageModel) and the Private Cloud Compute server model (PrivateCloudComputeLanguageModel) behind one LanguageModelSession API, an AI side pane beside the content when the phone is open or in book pose (split ArrangementView) and a one-line summary when it is closed or in tabletop, streaming (streamResponse with @Generable partial snapshots) into a pane that keeps going through fold and unfold, availability checks and non-AI fallbacks, quota and error handling (LanguageModelError), tool calling, image prompts (Attachment), reasoning levels (ContextOptions) and privacy. Use when someone adds summaries, an assistant, chat, tagging or image understanding to an app that runs on iPhone Duo, or when an AI feature restarts on a fold, sits in the fold or doesn't fit the outer display./duo-mediaVideo and audio playback on iPhone Duo, Apple's foldable. Use when an app plays video or audio and must keep playing through fold, unfold and rotation, when you build a tabletop player (video above the fold, the same controls below) or a book-pose player, an up next queue, Picture in Picture, Now Playing or background audio. Covers one AVPlayer owned above the layout switch (VideoPlayer, AVPlayerViewController, AVPlayerLayer), ArrangementView with .overlay and overlayArrangementZIndex for up next (measured on the simulator in every pose), when to pick .split instead, toolbarVerticalBehavior(.disabled) for a full-screen player, AVPictureInPictureController and canStartPictureInPictureAutomaticallyFromInline, the pinned Picture in Picture video that takes half the screen when folded, MPNowPlayingSession and remote commands, the .playback audio session, and what to test in Device Hub and on a device./duo-readingBuilds reading and document screens for iPhone Duo, Apple's foldable: 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 page turns below it. Use when you build an e-reader, a long-form or PDF viewer, notes beside a document, or when a reader loses its place on fold, unfold, rotation or a Dynamic Type change. Covers TextKit 1 pagination (NSLayoutManager, NSTextContainer) that keeps the place as a character offset, PagedReader with FoldGeometry and reservedRegions(kind: .division, options: .includeInactive), notes that move between the trailing region and a sheet, Dynamic Type reflow, text selection that stays inside one page (iOS 27 Text range selection, a UITextView edit menu Add to Notes action, drag), PDFKit two-up centred on the fold, and Apple Pencil, which Apple says comes later in 2026 (what it will support is unverified).npx claudepluginhub kimeur/duology --plugin duology-featuresOther plugins' skills for the same job