Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Swiftui Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-swiftui-knowledge-patch-nevaberry-plugins)
---
name: swiftui-knowledge-patch
description: SwiftUI
version: "iOS 27 beta 4 / Xcode 27 beta 4"
license: MIT
metadata:
author: Nevaberry
---
# SwiftUI Compatibility Guidance
Load this skill when updating SwiftUI state and builders, adapting layouts and
navigation, implementing document I/O and interactions, or integrating platform
scenes and web content. Use the topic references for complete guidance and examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [State, Concurrency, and Builders](references/state-concurrency-and-builders.md) | State initialization, builder compatibility, off-main callbacks, observation, animation |
| [Interface, Layout, and Navigation](references/interface-layout-and-navigation.md) | Window resizing, commands, toolbars, tabs, search, Liquid Glass, arrangements, hardware regions, spatial layout |
| [Documents, Interactions, and Text](references/documents-interactions-and-text.md) | Document scenes and I/O, dragging, reordering, gestures, controls, dialogs, text editing |
| [Web, Interoperability, and Scenes](references/web-interop-and-scenes.md) | Web navigation and scrolling, image caching, UIKit and AppKit hosting, utility windows, accessibility, widgets, immersive spaces |
| [Diagnostics, Charts, and Color](references/diagnostics-charts-and-color.md) | Chart surfaces and compilation, HDR colors, accessible color names, skill export |
## Migration and compatibility
### Full-screen assumptions and resizing
Migrate away from the deprecated `UIRequiresFullscreen` Info.plist key and let
`NavigationSplitView` adapt its visible columns as the window resizes.
iPhone apps can be resized in iPhone Mirroring and when running on iPad; use the
resize handles in Xcode 27 Live Previews to test those window sizes.
### State initialization and composition
The Xcode 27 `@State` macro lazily evaluates the initial value once per view
identity, including on iOS 17, macOS 14, and aligned releases. For values supplied
by `init`, omit the inline default because it takes precedence. Initialize
non-state stored properties before assigning state.
Remove other property wrappers stacked with `@State`. If an extension used a
synthesized memberwise initializer for a view with private state, define the
initializer explicitly.
### Builder ambiguities and concrete result types
Xcode 27 unifies builders such as `ViewBuilder` under `@ContentBuilder`, which
works with older deployment targets. Builders including those on `Group`,
`ForEach`, and `Section` accept unconstrained elements; assembled content conforms
to the required protocol when its elements do.
If a styled expression is ambiguous in `background` or `overlay`, use the closure
overload, such as `.overlay { Color.blue.opacity(0.3).blendMode(.overlay) }`.
Qualify colliding names in builder bodies, such as `SwiftUI.Color.clear`.
A two-expression stack can now produce `VStack<TupleContent<Text, Text>>`, so
prefer opaque return types such as `some View`. For a concrete constraint
back-deploying below iOS 27, iPadOS 27, macOS 27, or visionOS 27, retain
`VStack<TupleView<(Text, Text)>>` and explicitly construct:
```swift
VStack { TupleView((Text("A"), Text("B"))) }
```
If an empty nested builder resolves to `EmptyMapContent` when MapKit is in scope,
provide `EmptyContent()` or `EmptyView()`, as in `Group { EmptyView() }`. Put the
empty value in `#else` when a conditionally compiled branch can disappear.
When a `Chart` closure with roughly ten or more branches times out while
back-deploying below iOS 27, iPadOS 27, macOS 27, or visionOS 27, move the branches
to an `@ChartContentBuilder` function returning `some ChartContent` and call it
from the chart closure.
### Off-main callbacks
SwiftUI can call `Layout` requirements, `Shape.path(in:)`, `visualEffect`, and the
transform closure of `onGeometryChange` off the main actor. Capture a sendable
snapshot of view state before a `@Sendable` callback runs:
```swift
Text("Loading").visualEffect { [pulse] content, _ in content.blur(radius: pulse ? 2 : 0) }
```
## Adaptive interfaces and navigation
### Toolbar grouping, overflow, and vertical controls
Place `ToolbarSpacer(.fixed, placement: .primaryAction)` between items in the
same toolbar placement to put them in separate Liquid Glass groups.
Use `.visibilityPriority(.high)` on a `ToolbarItemGroup` to keep it visible longer
as space shrinks, `ToolbarOverflowMenu` for actions that should always live in
overflow, and `.topBarPinnedTrailing` for an action that must stay visible.
Read `@Environment(\.toolbarVerticalEdge)` to position custom UI relative to the
system's vertical controls. Use `toolbarVerticalBehavior(_:)` to opt a view out
and move its bar content to the standard top and bottom toolbars.
Set individual standard or customizable items with `axisBehavior(_:)`, using
values such as `.horizontalOnly` or `.verticalPreferred`.
Use `toolbarVerticalCompressionBehavior(_:)` with `.prefersToolbarItems` or
`.prefersTabBar` to choose which content to favor when bars share limited space.
### Tabs, search, and window appearance
Declare `Tab(role: .prominent) { CartView() }` inside a `TabView` to place a
destination at the bottom trailing edge, apart from the other tabs.
Apply `.toolbarMinimizeBehavior(.onScrollDown, for: .navigationBar)` to a scroll
view to collapse the navigation bar as the user scrolls down.
Apply `.searchable(text:)` to the outer `NavigationSplitView`. In iOS and iPadOS
26, this places search at the bottom on iPhone and in the top trailing corner on
iPad. In custom controls, read `@Environment(\.appearsActive)` and adjust their
appearance when an iPad window becomes inactive; standard icons and text dim.
### Arrangements and hardware geometry
Use `ArrangementView` for primary and secondary content that responds to the
environment. Select a style with `arrangementViewStyle(_:)`, or implement
`ArrangementViewStyle.makeBody(configuration:)` using `configuration.primary`
and `configuration.secondary`.
The `.split` style places views side by side on axes allowed by `axes(_:)`.
The `.overlay` style layers the primary view above the secondary view; its
`axes(_:)` controls which axes can switch to a side-by-side layout.
The layout reference details companion-relative sizing, absolute constraints,
ideal sizing, overlay edges, and the axis and z-index environment values.
Query intersecting camera occlusions or hinge divisions with
`GeometryProxy.reservedRegions(kind:options:layoutDirectionBehavior:)`, using
kinds such as `.occlusion` and `.division`. Pass `.includeInactive` to include
inactive regions; use `ReservedRegion.ID` to track the same region across
coordinate spaces or over time.
On iPhone Duo, `onHingeChange(isEnabled:_:)` delivers a `DeviceHingeContext`.
Use `CameraCaptureAccessory` to show content on the outer display while the
device is open, the app is in the foreground, and a camera capture session is active.
## Documents and interactions
### Document architecture and snapshots
Place `DocumentGroup` before `WindowGroup` in `App.body` when declaring both to
opt into SwiftUI's document-based architecture. Give each launch-scene
`NewDocumentButton` a `DocumentCreationSource` with its own ID; SwiftUI passes
the selected source through the `DocumentGroup` creation context.
Use an `@Observable` model in `DocumentGroup` and conform it to `WritableDocument`
to declare supported formats, supply
`@MainActor func snapshot(contentType: UTType) async throws -> sending Snapshot`,
and select a `DocumentWriter` using `configuration.contentType` in
`writer(configuration:)`. The writer receives a destination URL, an optional
previous snapshot for incremental writes, and Foundation `Subprogress`.
`ReadableDocument` declares supported formats and applies the snapshot returned
by a `DocumentReader`. It can also read directly from the file URL;
`URLDocumentConfiguration` supplies the URL and last modification date and
coordinates additional file access. See the document reference for file-wrapper
adapters and exporting a `WritableDocument`.
### Dragging, reordering, and swipe actions
Mark each draggable child with its ID, then supply the selection and a resolver
on the container. SwiftUI asks for payloads lazily at the drop. On macOS, you can opt
into deletion and remove the reported IDs when the session ends with `.delete`.
Use `.dragPreviewsFormation(.stack)` on the macOS drag container to stack previews.
Mark a `ForEach` with `.reorderable()` and update the underlying collection from
the `ReorderDifference` delivered to `.reorderContainer(for:)`. The pattern also
works on watchOS; single-collection moves place source IDs before the destination
ID or at the end. For swipe actions in a custom layout, attach `.swipeActions`
to each row and `.swipeActionsContainer()` to its enclosing `ScrollView`.
### Dialogs, text, and gesture handoffs
Set an optional state item to a value to present an item-bound `.confirmationDialog` or
`.alert`; each passes the item to its actions closure. Use `alert(error:actions:)`
or `alert(error:actions:message:)` for an optional error; SwiftUI supplies the
title from the error and passes it to the content closures.
Add text-field choices with `textInputSuggestions(_:)` and mark their inserted
text with `textInputCompletion(_:)`. For editable search tokens, pass a binding
to `editableTokens:` in `searchable(text:editableTokens:isPresented:placement:prompt:token:)`;
the `token` closure receives a binding to the individual token.
Set `Transaction.tracksVelocity` on gesture-driven updates to track velocity for
the handoff to an animation. Read `DragGesture.Value.velocity` for the velocity directly.
## Web content, image loading, and scenes
Supply a `NavigationDecider` to `WebPage` to allow or cancel navigation and adjust
`NavigationPreferences`. To route external links out of the web view, cancel
their navigation and hand the URL to SwiftUI's `openURL` action.
Use a `URLSchemeHandler` to serve bundled HTML and CSS through a custom scheme.
`WebView` bounces on both axes even when content fits. Use
`.scrollBounceBehavior(.basedOnSize, axes: .horizontal)` to restrict horizontal
bounce to overflow. On visionOS, enable `.look` with `webViewScrollInputBehavior`
to opt into look-to-scroll.
On the 2027 OS releases, `AsyncImage` caches according to HTTP response headers
by default. Use `AsyncImage(request: URLRequest(url: imageURL, cachePolicy: .returnCacheDataElseLoad))`
for per-request control, or set a shared session configured with a custom
`URLCache` on an ancestor using `.asyncImageURLSession(imageSession)`.
Use `UIHostingSceneDelegate` in UIKit or `NSHostingSceneRepresentation` in AppKit
to host and present SwiftUI scenes. On iOS 26, add
`AssistiveAccess { SimplifiedContentView() }` alongside `WindowGroup` in `App.body`
for a dedicated Assistive Access interface. Use the scene reference for utility
windows, widget detail levels, remote immersive rendering, and entity popovers.