SwiftUI Skill
When to Use This Skill
Use this skill when:
- Building user interfaces with SwiftUI
- Working with SwiftUI views, modifiers, and layouts
- Implementing state management with @State, @Binding, @ObservableObject
- Creating animations and transitions
- Implementing navigation with NavigationStack, NavigationLink, TabView
- Working with data flow patterns (@Environment, @EnvironmentObject)
- Using SwiftUI controls (Button, TextField, Picker, etc.)
- Building cross-platform apps for iOS, macOS, watchOS, tvOS, visionOS
Description
Complete SwiftUI framework documentation covering views, modifiers, layout, state management, animations, navigation, data flow, and all SwiftUI APIs for iOS, macOS, watchOS, tvOS, and visionOS.
Quick Reference
Core Components
Accessibility
AccessibilityTraits
Animations
AnimationAnyTransitionTransition
Api Reference
CapsuleCircleCommandsConfirmationDialogDisclosureGroupEllipseForEachFormFullScreenCoverGaugeGeometryProxyGeometryReaderGroupBoxImmersiveSpaceListMenuMenuBarExtraObservedObjectOutlineGroupPublishedRectangleRoundedRectangleSectionSecureFieldSwiftUIToolbarToolbarItemToolbarItemGroup
App Structure
DocumentGroupSceneSettingsWindowGroup
Controls
ButtonDatePickerPickerSliderStepperToggle
Data Flow
FocusedSceneValuePreferenceKey
Drawing
CanvasPath
Essentials
AppAppStorage
Gestures
DigitalCrownRotationalSensitivityDragGestureLongPressGestureMagnificationGestureRotationGestureTapGesture
Layout
DividerGridGridRowHStackLazyHGridLazyHStackLazyVGridLazyVStackNavigationStackSpacerVStackZStack
Navigation
AlertLinkNavigationLinkNavigationPathPopoverSheetTableTableColumnWKInterfaceObjectRepresentable
State Management
BindingEnvironmentEnvironmentObjectFocusStateObservableObservableObjectSceneStorageStateStateObject
Views
AccessibilityLabelColorColorPickerContextMenuImageLabelNSViewControllerRepresentableNSViewRepresentablePreviewProviderProgressViewRealityViewScrollViewShapeTabViewTextTextEditorTextFieldTimelineViewUIViewControllerRepresentableUIViewRepresentableViewViewModifier
Key Concepts
Platform Support
- iOS 26.0+
- iPadOS 26.0+
- macOS 26.0+
- Mac Catalyst 26.0+
- visionOS 26.0+
On-Device AI
All models run entirely on-device, ensuring privacy and offline capability.
Usage Guidelines
- Check model availability before use
- Define clear instructions for the model's behavior
- Use guided generation for structured outputs
- Implement tool calling for dynamic capabilities
- Handle errors appropriately
Navigation
See the references/ directory for detailed API documentation organized by category:
references/accessibility.md- Accessibilityreferences/animations.md- Animationsreferences/api_reference.md- Api Referencereferences/app_structure.md- App Structurereferences/controls.md- Controlsreferences/data_flow.md- Data Flowreferences/drawing.md- Drawingreferences/essentials.md- Essentialsreferences/gestures.md- Gesturesreferences/layout.md- Layoutreferences/navigation.md- Navigationreferences/state_management.md- State Managementreferences/view_modifiers.md- View Modifiers (18 modifiers including .sheet(), .frame(), .animation(), etc.)references/views.md- Views
Best Practices
- Prompting: Be specific and clear in your prompts
- Instructions: Define the model's behavior upfront
- Safety: Enable guardrails for sensitive content
- Localization: Check supported languages for your use case
- Performance: Use prewarm() for better response times
- Streaming: Use streamResponse() for real-time user feedback
Common Patterns
Basic Session
let model = SystemLanguageModel(useCase: .general)
let session = LanguageModelSession(model: model)
let response = try await session.respond(to: Prompt("Your question"))
Guided Generation
struct Recipe: Generable {
let title: String
let ingredients: [String]
}
let recipe = try await session.respond(
generating: Recipe.self,
prompt: Prompt("Create a pasta recipe")
)
Tool Calling
struct WeatherTool: Tool {
func call(arguments: String) async throws -> String {
// Fetch weather data
}
}
let session = LanguageModelSession(
model: model,
tools: [WeatherTool()]
)
Reference Documentation
For complete API details, see the categorized documentation in the references/ directory.