plugins/build-ios-apps/skills/swiftui-ui-patterns/SKILL.md
Build and refactor SwiftUI UI with component patterns and examples. Use when shaping navigation, state, layouts, controls, or screen composition.
npx skillsauth add openai/plugins swiftui-ui-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Choose a track based on your goal:
rg "TabView\(" or similar, then read the closest SwiftUI view.references/components-index.md and follow its guidance.references/scroll-reveal.md before implementing gestures manually.references/app-wiring.md to wire TabView + NavigationStack + sheets.AppTab and RouterPath based on the provided skeletons.@State, @Binding, @Observable, @Environment) and avoid unnecessary view models.ObservableObject with @StateObject for root ownership, @ObservedObject for injected observation, and @EnvironmentObject only for truly shared app-level state..task and explicit loading/error states. For restart, cancellation, and debouncing guidance, read references/async-state.md.@Environment, but prefer explicit initializer injection for feature-local dependencies and models. For root wiring patterns, read references/app-wiring.md..sheet(item:) over .sheet(isPresented:) when state represents a selected model. Avoid if let inside a sheet body. Sheets should own their actions and call dismiss() internally instead of forwarding onCancel/onConfirm closures.Use the narrowest state tool that matches the ownership model:
| Scenario | Preferred pattern |
| --- | --- |
| Local UI state owned by one view | @State |
| Child mutates parent-owned value state | @Binding |
| Root-owned reference model on iOS 17+ | @State with an @Observable type |
| Child reads or mutates an injected @Observable model on iOS 17+ | Pass it explicitly as a stored property |
| Shared app service or configuration | @Environment(Type.self) |
| Legacy reference model on iOS 16 and earlier | @StateObject at the root, @ObservedObject when injected |
Choose the ownership location first, then pick the wrapper. Do not introduce a reference model when plain value state is enough.
references/navigationstack.md: navigation ownership, per-tab history, and enum routing.references/sheets.md: centralized modal presentation and enum-driven sheets.references/deeplinks.md: URL handling and routing external links into app destinations.references/app-wiring.md: root dependency graph, environment usage, and app shell wiring.references/async-state.md: .task, .task(id:), cancellation, debouncing, and async UI state.references/previews.md: #Preview, fixtures, mock environments, and isolated preview setup.references/performance.md: stable identity, observation scope, lazy containers, and render-cost guardrails.body-driven code paths instead of view lifecycle hooks or injected models/services.AnyView to work around type mismatches that should be solved with better composition.@EnvironmentObject or a global router without a clear ownership reason.@Environment and which should stay as explicit initializer inputs.references/navigationstack.md, references/sheets.md, or references/deeplinks.md. Build and verify no compiler errors before proceeding..task or .task(id:), plus explicit loading and error states when needed. Read references/async-state.md when the work depends on changing inputs or cancellation.references/previews.md when the view needs fixtures or injected mock dependencies.references/performance.md if the screen is large, scroll-heavy, or frequently updated. For common SwiftUI compilation errors — missing @State annotations, ambiguous ViewBuilder closures, or mismatched generic types — resolve them before updating callsites. If the build fails: read the error message carefully, fix the identified issue, then rebuild before proceeding to the next step. If a preview crashes, isolate the offending subview, confirm its state initialisation is valid, and re-run the preview before continuing.Use references/components-index.md as the entry point. Each component reference should include:
references/<component>.md.references/components-index.md with the new entry.development
Use when the user wants to spin up / create / launch / provision a DigitalOcean droplet (or "a remote dev box on DO") and connect to it from Codex as a remote SSH workspace.
data-ai
Search through Microsoft Teams chats or channels, triage unread or recent activity, draft follow-ups, and manage Planner tasks through connected Teams data.
tools
Motion / animation context for the `use_figma` MCP tool — animating Figma nodes via manual keyframes, animation styles, easing, and timeline duration. Load alongside figma-use whenever a task involves adding, editing, or inspecting animation on a node.
development
SwiftUI ↔ Figma translation. Use whenever the user mentions Swift, SwiftUI, iOS, iPhone, or iPad — in EITHER direction — translating a Figma design into SwiftUI (design → code), or pushing SwiftUI views / screens / tokens back into a Figma file (code → design). Triggers on phrases like 'implement this Figma design in SwiftUI', 'build this screen in Swift', 'push this SwiftUI view to Figma', 'mirror my Swift code in a Figma file', or whenever a Figma URL appears alongside `.swift` files / an `.xcodeproj`. Routes to a direction-specific reference doc; loads alongside `figma-use` for the code → design path.