Overview
SwiftUI for building native iOS, macOS, watchOS, and tvOS apps. Covers declarative UI, state management, navigation, Core Data, and Apple ecosystem integration.
Capabilities
- Build declarative UIs with SwiftUI views and modifiers
- Implement state management (@State, @Binding, @Observable)
- Design navigation with NavigationStack and NavigationLink
- Integrate with Core Data, HealthKit, and Apple services
- Submit to App Store via TestFlight
When to Use
Trigger phrases:
"ios swiftui"
"SwiftUI development — declarative UI, state management, navigation, and Apple ec"
Building native iOS/macOS apps
Need deep Apple ecosystem integration (HealthKit, CarPlay, widgets)
Target iOS 16+ for modern SwiftUI features
Team has Swift experience
When NOT to Use
- Task is about deployment, not development (use deploy skills)
- Task is about code review, not writing (use review skills)
- You need to understand existing code first (use research skills)
- Task is about testing only (use test skills)
- Requirements are unclear (clarify first)
- Task is trivially simple (single line fix)
Pseudo Code
The ios-swiftui workflow follows a standard pipeline pattern.
Core flow:
# ios-swiftui primary flow
input = prepare(raw_data)
result = process(input, config={apple, declarative, development, ecosystem, integration})
validate(result)
deliver(result)
Error handling:
on error:
log(error_details)
retry_with_backoff(max=3)
if still_failing: alert_and_escalate()
SwiftUI View
struct ContentView: View {
@State private var items: [Item] = []
var body: some View {
NavigationStack {
List(items) { item in
NavigationLink(item.name) {
DetailView(item: item)
}
}
.navigationTitle("Items")
.task { await loadItems() }
}
}
func loadItems() async {
items = try? await APIService.fetchItems()
}
}
Observable Pattern
@Observable
class ItemStore {
var items: [Item] = []
func fetch() async throws {
items = try await APIService.fetchItems()
}
}
Common Patterns
- @Observable: Use the new @Observable macro (iOS 17+) over ObservableObject
- NavigationStack: Use NavigationStack over NavigationView (deprecated)
- Task modifier: Use .task {} for async loading instead of .onAppear
- PreviewProvider: Always include previews for rapid development
How to Use
- Understand the requirement and existing codebase patterns
- Design the solution with error handling and testability in mind
- Implement incrementally with tests for each change
- Verify against expected outcomes (manual and automated)
- Document usage, edge cases, and integration points
- Review with team before merging to shared branches
Red Flags
- Skipping tests to ship faster: Untested code breaks in production when you least expect it
- No error handling in production code: Unhandled errors crash services and lose user data
- Hardcoded configuration values: Hardcoded values prevent environment switching and leak secrets
- Ignoring security implications: Missing input validation, auth bypasses, and injection vulnerabilities
- Over-engineering simple solutions: Premature abstraction adds complexity without proportional benefit
Verification
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "Tests slow me down" |
Bugs slow you down 10x more. Tests are speed, not overhead. |
| "I will refactor later" |
Technical debt compounds. Refactor as you go. |
| "It works on my machine" |
If it is not in CI, it does not work. Ship proof, not claims. |
1---2name: ios-swiftui3description: Use when swiftUI development — declarative UI, state management, navigation,4 and Apple ecosystem integration. Use when working with ios swiftui.5domain: development6author: oyi777license: Apache-2.08subdomain: software-development9tags:10- coding11- ios12- software-engineering13- swiftui14- testing15version: 1.0.016category: development17metadata:18 source: https://skillmd.com/skills/oyi77/ios-swiftui19---20212223## Overview2425SwiftUI for building native iOS, macOS, watchOS, and tvOS apps. Covers declarative UI, state management, navigation, Core Data, and Apple ecosystem integration.2627## Capabilities2829- Build declarative UIs with SwiftUI views and modifiers30- Implement state management (@State, @Binding, @Observable)31- Design navigation with NavigationStack and NavigationLink32- Integrate with Core Data, HealthKit, and Apple services33- Submit to App Store via TestFlight3435## When to Use36**Trigger phrases:**37- "ios swiftui"38- "SwiftUI development — declarative UI, state management, navigation, and Apple ec"394041- Building native iOS/macOS apps42- Need deep Apple ecosystem integration (HealthKit, CarPlay, widgets)43- Target iOS 16+ for modern SwiftUI features44- Team has Swift experience4546## When NOT to Use4748- Task is about deployment, not development (use deploy skills)49- Task is about code review, not writing (use review skills)50- You need to understand existing code first (use research skills)51- Task is about testing only (use test skills)52- Requirements are unclear (clarify first)53- Task is trivially simple (single line fix)545556## Pseudo Code5758The ios-swiftui workflow follows a standard pipeline pattern.5960Core flow:61```62# ios-swiftui primary flow63input = prepare(raw_data)64result = process(input, config={apple, declarative, development, ecosystem, integration})65validate(result)66deliver(result)67```6869Error handling:70```71on error:72 log(error_details)73 retry_with_backoff(max=3)74 if still_failing: alert_and_escalate()75```767778### SwiftUI View79```swift80struct ContentView: View {81 @State private var items: [Item] = []82 83 var body: some View {84 NavigationStack {85 List(items) { item in86 NavigationLink(item.name) {87 DetailView(item: item)88 }89 }90 .navigationTitle("Items")91 .task { await loadItems() }92 }93 }94 95 func loadItems() async {96 items = try? await APIService.fetchItems()97 }98}99```100101### Observable Pattern102```swift103@Observable104class ItemStore {105 var items: [Item] = []106 107 func fetch() async throws {108 items = try await APIService.fetchItems()109 }110}111```112113## Common Patterns114115- **@Observable**: Use the new @Observable macro (iOS 17+) over ObservableObject116- **NavigationStack**: Use NavigationStack over NavigationView (deprecated)117- **Task modifier**: Use .task {} for async loading instead of .onAppear118- **PreviewProvider**: Always include previews for rapid development119120## How to Use1211221. Understand the requirement and existing codebase patterns1232. Design the solution with error handling and testability in mind1243. Implement incrementally with tests for each change1254. Verify against expected outcomes (manual and automated)1265. Document usage, edge cases, and integration points1276. Review with team before merging to shared branches128129## Red Flags130131- **Skipping tests to ship faster**: Untested code breaks in production when you least expect it132- **No error handling in production code**: Unhandled errors crash services and lose user data133- **Hardcoded configuration values**: Hardcoded values prevent environment switching and leak secrets134- **Ignoring security implications**: Missing input validation, auth bypasses, and injection vulnerabilities135- **Over-engineering simple solutions**: Premature abstraction adds complexity without proportional benefit136137## Verification138139- [ ] Skill output matches expected behavior140141## Process1421431. Analyze the task requirements1442. Apply domain expertise1453. Verify output quality146147## Anti-Rationalization Table148149| Rationalization | Reality |150|---|---|151| "Tests slow me down" | Bugs slow you down 10x more. Tests are speed, not overhead. |152| "I will refactor later" | Technical debt compounds. Refactor as you go. |153| "It works on my machine" | If it is not in CI, it does not work. Ship proof, not claims. |