Advisor Swift Champion
Powerful agent for expert, assistance, building, model. Includes structured workflows, validation checks, and reusable patterns for expert advisors.
Swift Champion Advisor
Your specialized agent for Swift and iOS/macOS development — covering SwiftUI, UIKit, Swift concurrency, Combine, and Apple platform best practices.
When to Use This Agent
Choose Swift Champion Advisor when:
- Building iOS, macOS, watchOS, or tvOS applications with Swift
- Implementing SwiftUI views, navigation, and state management
- Working with Swift concurrency (async/await, actors, structured concurrency)
- Integrating Apple frameworks (Core Data, CloudKit, HealthKit, ARKit)
- Migrating UIKit code to SwiftUI or adopting modern Swift patterns
Consider alternatives when:
- You need cross-platform mobile (React Native, Flutter) — use a mobile agent
- You need backend Swift (Vapor) — use a backend agent
- You need Android development — use a Kotlin/Android agent
Quick Start
# .claude/agents/swift-champion.yml name: Swift Champion Advisor model: claude-sonnet tools: - Read - Write - Edit - Bash - Glob - Grep description: Swift and Apple platform specialist for SwiftUI, UIKit, concurrency, and iOS/macOS development
Example invocation:
claude "Design a SwiftUI app architecture for a fitness tracker — with MVVM pattern, Core Data persistence, HealthKit integration, and widget extensions"
Core Concepts
Swift Architecture Patterns
| Pattern | Use Case | SwiftUI Support |
|---|---|---|
| MVVM | Standard UI-data separation | Native with @Observable |
| TCA (Composable Architecture) | Complex state management | Point-Free library |
| Clean Architecture | Enterprise apps | Layer separation |
| MV (Model-View) | Simple apps, SwiftUI native | Direct data binding |
SwiftUI State Management
// Observable macro (Swift 5.9+) @Observable class UserViewModel { var name: String = "" var isLoading: Bool = false var error: Error? func loadUser() async { isLoading = true defer { isLoading = false } do { let user = try await userService.fetchUser() name = user.name } catch { self.error = error } } } // View consuming the observable struct UserView: View { @State private var viewModel = UserViewModel() var body: some View { VStack { if viewModel.isLoading { ProgressView() } else { Text(viewModel.name) } } .task { await viewModel.loadUser() } } }
Configuration
| Parameter | Description | Default |
|---|---|---|
swift_version | Swift language version | 5.9+ |
ui_framework | UI framework (swiftui, uikit, appkit) | swiftui |
architecture | App architecture (mvvm, tca, clean, mv) | mvvm |
platforms | Target platforms (ios, macos, watchos, tvos) | ios |
min_deployment | Minimum deployment target | iOS 17 |
Best Practices
-
Use @Observable over ObservableObject for new projects. The @Observable macro (Swift 5.9+) provides more granular view updates than ObservableObject — views only re-render when properties they actually read change, not when any @Published property changes.
-
Embrace structured concurrency with async/await and TaskGroups. Replace completion handlers and delegate callbacks with async functions. Use
Task {}for launching concurrent work from SwiftUI, andTaskGroupfor parallel operations. AvoidDispatchQueue.main.async— SwiftUI handles main-thread updates automatically. -
Use the Environment for dependency injection. Register dependencies using custom
EnvironmentKeytypes and access them via@Environmentin views. This keeps views testable and allows previews to use mock implementations. -
Design reusable view components with protocols and generics. SwiftUI's composition model excels when views are small, focused, and composable. Extract common patterns (loading states, error handling, empty states) into reusable view modifiers or wrapper views.
-
Test ViewModels independently from SwiftUI views. Business logic in @Observable classes can be unit-tested without any UI framework. Test the ViewModel's state transitions, error handling, and data transformations with XCTest, keeping view tests for integration verification.
Common Issues
SwiftUI previews crash or show stale content. Preview crashes are usually caused by force-unwrapped optionals, missing environment objects, or file system dependencies. Provide mock data for previews, inject dependencies via Environment, and restart Xcode's preview provider when it gets stuck.
Navigation in SwiftUI is confusing between NavigationStack and NavigationView. Use NavigationStack (iOS 16+) with navigationDestination(for:) for type-safe navigation. NavigationView is deprecated. For complex navigation, use a coordinator pattern with @Observable navigation state.
Core Data and SwiftUI integration causes unexpected view updates. @FetchRequest triggers view updates for any change in the fetch request's result set. Use SectionedFetchRequest for grouped data, and consider moving Core Data operations to a background context to avoid blocking the main thread.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
API Endpoint Builder
Agent that scaffolds complete REST API endpoints with controller, service, route, types, and tests. Supports Express, Fastify, and NestJS.
Documentation Auto-Generator
Agent that reads your codebase and generates comprehensive documentation including API docs, architecture guides, and setup instructions.
Ai Ethics Advisor Partner
All-in-one agent covering ethics, responsible, development, specialist. Includes structured workflows, validation checks, and reusable patterns for ai specialists.