Apple Development
Expert-level guidance for building native Apple applications with Swift and
SwiftUI, following Apple's best practices and Human Interface Guidelines.
Core Capabilities
1. Swift Programming Excellence
Write idiomatic, performant Swift code following modern best practices:
- Type Safety & Optionals: Proper optional handling with
guard, if let,
nil coalescing; avoid force unwrapping
- Value Types First: Prefer
struct over class; use classes for reference
semantics and inheritance
- Protocol-Oriented Programming: Small focused protocols, protocol
extensions with default implementations
- Modern Swift: async/await, property wrappers, Result type, Codable,
Combine
- Memory Management: [weak self] in closures, avoid retain cycles, efficient
resource usage
- Code Organization: Clear file structure, meaningful naming, access
control, MARK comments
When to consult references: For detailed patterns, advanced techniques, or
specific language features, read references/swift-best-practices.md
2. SwiftUI Interface Development
Build modern, declarative user interfaces following SwiftUI patterns:
- State Management: @State, @Binding, @StateObject, @ObservedObject,
@EnvironmentObject, @Environment
- Observable Macro: Modern @Observable pattern for iOS 17+ (no @Published
needed)
- MVVM Pattern: Clean separation with ViewModels, proper data flow
- View Composition: Break complex views into focused, reusable components
- Custom Modifiers: Reusable styling through ViewModifier protocol
- Navigation: NavigationStack, sheets, alerts, confirmation dialogs
- Lists & Performance: LazyVStack, ForEach optimization, equatable views
- Animations: Implicit/explicit animations, transitions, matched geometry
effects
When to consult references: For layout patterns, advanced state management,
or SwiftUI-specific techniques, read references/swiftui-patterns.md
3. Human Interface Guidelines Compliance
Design interfaces that feel native and follow Apple's design principles:
- Platform Conventions: iOS navigation patterns (tab bar, navigation bar),
macOS window management
- Typography: SF Pro font hierarchy, Dynamic Type support, accessibility
- Color: System colors, semantic colors, dark mode support, sufficient
contrast
- Layout: Safe areas, spacing system (4pt grid), standard margins, touch
targets (44x44pt minimum)
- Components: Standard buttons, lists, forms, navigation, sheets, alerts
- Accessibility: VoiceOver labels, Dynamic Type, reduce motion, color
contrast
- Gestures: Tap, swipe, long press, pinch, proper haptic feedback
When to consult references: For detailed HIG requirements, component
specifications, or platform-specific patterns, read
references/human-interface-guidelines.md
4. Apple Frameworks Mastery
Leverage the full Apple ecosystem with deep framework knowledge:
- Foundation: String, Date, FileManager, UserDefaults, Codable, URLSession
- UIKit/AppKit: View controllers, table views, collection views, Auto Layout
- SwiftUI: Declarative UI, state management, navigation, animations
- Networking: URLSession async/await, Codable JSON parsing, error handling
- Data Persistence: Core Data, SwiftData (iOS 17+), UserDefaults, file
system
- Concurrency: async/await, Task, actors, MainActor, TaskGroup
- Combine: Publishers, operators, reactive programming
- CloudKit: Public/private databases, CKRecord CRUD operations
- StoreKit: In-app purchases, subscriptions, transaction handling
- Core Location & MapKit: Location services, mapping, annotations
- HealthKit: Health data queries, authorization, samples
- AVFoundation: Audio/video playback, camera capture
When to consult references: For framework APIs, code samples, or integration
patterns, read references/apple-frameworks.md
5. Performance Optimization
Build fast, efficient applications with optimal resource usage:
- Launch Time: Defer initialization, lazy properties, optimize bundle size
- Memory Management: Fix leaks, reduce footprint, image optimization,
caching
- CPU Optimization: Background queues, efficient algorithms, lazy operations
- Rendering: Optimize view hierarchy, SwiftUI performance, Core Animation
- Network: Reduce data transfer, batch requests, caching, offline mode
- Battery: Minimize location updates, efficient background tasks
- Database: Core Data batch operations, indexes, efficient queries
- Profiling: Instruments (Time Profiler, Allocations, Leaks), MetricKit
When to consult references: For optimization techniques, profiling
workflows, or specific performance patterns, read
references/performance-optimization.md
Development Workflow
Starting a New Project
- Choose Architecture: SwiftUI-first for new apps, UIKit for legacy or
specific requirements
- Set Up Structure: MVVM for SwiftUI, MVC or VIPER for UIKit
- Configure Project:
- Enable Swift strict concurrency checking
- Set deployment target appropriately
- Configure code signing
- Follow Conventions: File per type, MARK comments, proper access control
- Start with HIG: Design following platform patterns before implementing
Writing Code
- Reference Appropriate Documentation: Consult skill references for
detailed guidance
- Follow Swift Best Practices: Type safety, optionals, protocol-oriented
design
- Use Modern APIs: async/await, @Observable (iOS 17+), SwiftUI when
possible
- Test on Real Devices: Simulators don't catch all issues
- Profile Early: Use Instruments to identify bottlenecks
Code Review Checklist
Common Patterns
SwiftUI View with ViewModel
@MainActor
class UserViewModel: ObservableObject {
@Published private(set) var users: [User] = []
@Published private(set) var isLoading = false
private let service: UserServiceProtocol
init(service: UserServiceProtocol = UserService()) {
self.service = service
}
func loadUsers() async {
isLoading = true
do {
users = try await service.fetchUsers()
} catch {
// Handle error
}
isLoading = false
}
}
struct UsersView: View {
@StateObject private var viewModel = UserViewModel()
var body: some View {
Group {
if viewModel.isLoading {
ProgressView()
} else {
List(viewModel.users) { user in
UserRow(user: user)
}
}
}
.task {
await viewModel.loadUsers()
}
}
}
Network Request with async/await
func fetchUser(id: String) async throws -> User {
let url = URL(string: "https://api.example.com/users/\(id)")!
let (data, response) = try await URLSession.shared.data(from: url)
guard let httpResponse = response as? HTTPURLResponse,
(200...299).contains(httpResponse.statusCode) else {
throw NetworkError.serverError
}
return try JSONDecoder().decode(User.self, from: data)
}
Observable Model (iOS 17+)
@Observable
class ViewModel {
var items: [Item] = []
var isLoading = false
func loadItems() async {
isLoading = true
items = await fetchItems()
isLoading = false
}
}
// In SwiftUI - automatically observes changes
struct ContentView: View {
let viewModel = ViewModel()
var body: some View {
List(viewModel.items) { item in
Text(item.name)
}
}
}
Platform-Specific Considerations
iOS
- Support multiple screen sizes (iPhone SE to Pro Max)
- Handle Dynamic Island on iPhone 14 Pro+
- Safe area insets for notch/home indicator
- Tab bar for 3-5 top-level sections
- Pull-to-refresh for content updates
macOS
- Menu bar with standard menus (App, File, Edit, View, Window, Help)
- Window management (resize, minimize, maximize)
- Keyboard shortcuts for all actions
- Toolbar customization
- Right-click context menus
iPad
- Support Split View and Slide Over multitasking
- Adapt layout for different sizes
- Keyboard shortcuts
- Pointer/trackpad support
- Drag and drop between apps
watchOS
- Glanceable information
- Large touch targets (full screen width)
- Digital Crown for scrolling
- Minimal text input
tvOS
- Focus-based navigation (Siri Remote)
- 10-foot viewing distance
- Large, clear text and images
- No touch interaction
Accessibility
Always implement:
- VoiceOver labels for images and controls
- Accessibility hints for complex interactions
- Dynamic Type support for all text
- Minimum 4.5:1 contrast for text
- Reduce Motion support for animations
- Keyboard navigation support (macOS)
Testing
- Unit tests for ViewModels and business logic
- UI tests for critical user flows
- Test on multiple devices and screen sizes
- Test in both light and dark mode
- Test with Dynamic Type at various sizes
- Test with VoiceOver enabled
- Profile with Instruments before release
Resources
This skill includes comprehensive reference documentation:
references/swift-best-practices.md
Complete Swift programming best practices covering code organization, type
safety, optionals, protocol-oriented programming, modern Swift features, memory
management, concurrency, and testing patterns.
references/swiftui-patterns.md
SwiftUI design patterns including view composition, state management, MVVM
architecture, layout techniques, navigation patterns, animations, performance
optimization, and accessibility.
references/human-interface-guidelines.md
Apple's Human Interface Guidelines covering design principles, platform
conventions, typography, color, layout, components, accessibility, gestures, and
platform-specific patterns for iOS, macOS, iPad, watchOS, and tvOS.
references/apple-frameworks.md
Comprehensive reference for Apple frameworks including Foundation, UIKit,
AppKit, networking, Core Data, SwiftData, Combine, CloudKit, StoreKit, Core
Location, MapKit, HealthKit, AVFoundation, and Core Animation.
references/performance-optimization.md
Performance optimization techniques covering app launch, memory management, CPU
optimization, rendering, networking, battery efficiency, database performance,
profiling with Instruments, and testing.
1---2name: apple-dev3description: Comprehensive macOS and iOS development expertise covering Swift best practices, SwiftUI design patterns, Human Interface Guidelines, Apple frameworks, and performance optimization. Use when developing native Apple applications, implementing SwiftUI interfaces, working with Apple frameworks (Foundation, UIKit, AppKit, Core Data, CloudKit, etc.), optimizing app performance, following HIG principles, or writing production-quality Swift code for iOS, macOS, watchOS, or tvOS platforms.4---56# Apple Development78Expert-level guidance for building native Apple applications with Swift and9SwiftUI, following Apple's best practices and Human Interface Guidelines.1011## Core Capabilities1213### 1. Swift Programming Excellence1415Write idiomatic, performant Swift code following modern best practices:1617- **Type Safety & Optionals**: Proper optional handling with `guard`, `if let`,18 nil coalescing; avoid force unwrapping19- **Value Types First**: Prefer `struct` over `class`; use classes for reference20 semantics and inheritance21- **Protocol-Oriented Programming**: Small focused protocols, protocol22 extensions with default implementations23- **Modern Swift**: async/await, property wrappers, Result type, Codable,24 Combine25- **Memory Management**: [weak self] in closures, avoid retain cycles, efficient26 resource usage27- **Code Organization**: Clear file structure, meaningful naming, access28 control, MARK comments2930**When to consult references**: For detailed patterns, advanced techniques, or31specific language features, read `references/swift-best-practices.md`3233### 2. SwiftUI Interface Development3435Build modern, declarative user interfaces following SwiftUI patterns:3637- **State Management**: @State, @Binding, @StateObject, @ObservedObject,38 @EnvironmentObject, @Environment39- **Observable Macro**: Modern @Observable pattern for iOS 17+ (no @Published40 needed)41- **MVVM Pattern**: Clean separation with ViewModels, proper data flow42- **View Composition**: Break complex views into focused, reusable components43- **Custom Modifiers**: Reusable styling through ViewModifier protocol44- **Navigation**: NavigationStack, sheets, alerts, confirmation dialogs45- **Lists & Performance**: LazyVStack, ForEach optimization, equatable views46- **Animations**: Implicit/explicit animations, transitions, matched geometry47 effects4849**When to consult references**: For layout patterns, advanced state management,50or SwiftUI-specific techniques, read `references/swiftui-patterns.md`5152### 3. Human Interface Guidelines Compliance5354Design interfaces that feel native and follow Apple's design principles:5556- **Platform Conventions**: iOS navigation patterns (tab bar, navigation bar),57 macOS window management58- **Typography**: SF Pro font hierarchy, Dynamic Type support, accessibility59- **Color**: System colors, semantic colors, dark mode support, sufficient60 contrast61- **Layout**: Safe areas, spacing system (4pt grid), standard margins, touch62 targets (44x44pt minimum)63- **Components**: Standard buttons, lists, forms, navigation, sheets, alerts64- **Accessibility**: VoiceOver labels, Dynamic Type, reduce motion, color65 contrast66- **Gestures**: Tap, swipe, long press, pinch, proper haptic feedback6768**When to consult references**: For detailed HIG requirements, component69specifications, or platform-specific patterns, read70`references/human-interface-guidelines.md`7172### 4. Apple Frameworks Mastery7374Leverage the full Apple ecosystem with deep framework knowledge:7576- **Foundation**: String, Date, FileManager, UserDefaults, Codable, URLSession77- **UIKit/AppKit**: View controllers, table views, collection views, Auto Layout78- **SwiftUI**: Declarative UI, state management, navigation, animations79- **Networking**: URLSession async/await, Codable JSON parsing, error handling80- **Data Persistence**: Core Data, SwiftData (iOS 17+), UserDefaults, file81 system82- **Concurrency**: async/await, Task, actors, MainActor, TaskGroup83- **Combine**: Publishers, operators, reactive programming84- **CloudKit**: Public/private databases, CKRecord CRUD operations85- **StoreKit**: In-app purchases, subscriptions, transaction handling86- **Core Location & MapKit**: Location services, mapping, annotations87- **HealthKit**: Health data queries, authorization, samples88- **AVFoundation**: Audio/video playback, camera capture8990**When to consult references**: For framework APIs, code samples, or integration91patterns, read `references/apple-frameworks.md`9293### 5. Performance Optimization9495Build fast, efficient applications with optimal resource usage:9697- **Launch Time**: Defer initialization, lazy properties, optimize bundle size98- **Memory Management**: Fix leaks, reduce footprint, image optimization,99 caching100- **CPU Optimization**: Background queues, efficient algorithms, lazy operations101- **Rendering**: Optimize view hierarchy, SwiftUI performance, Core Animation102- **Network**: Reduce data transfer, batch requests, caching, offline mode103- **Battery**: Minimize location updates, efficient background tasks104- **Database**: Core Data batch operations, indexes, efficient queries105- **Profiling**: Instruments (Time Profiler, Allocations, Leaks), MetricKit106107**When to consult references**: For optimization techniques, profiling108workflows, or specific performance patterns, read109`references/performance-optimization.md`110111## Development Workflow112113### Starting a New Project1141151. **Choose Architecture**: SwiftUI-first for new apps, UIKit for legacy or116 specific requirements1171. **Set Up Structure**: MVVM for SwiftUI, MVC or VIPER for UIKit1181. **Configure Project**:119 - Enable Swift strict concurrency checking120 - Set deployment target appropriately121 - Configure code signing1221. **Follow Conventions**: File per type, MARK comments, proper access control1231. **Start with HIG**: Design following platform patterns before implementing124125### Writing Code1261271. **Reference Appropriate Documentation**: Consult skill references for128 detailed guidance1291. **Follow Swift Best Practices**: Type safety, optionals, protocol-oriented130 design1311. **Use Modern APIs**: async/await, @Observable (iOS 17+), SwiftUI when132 possible1331. **Test on Real Devices**: Simulators don't catch all issues1341. **Profile Early**: Use Instruments to identify bottlenecks135136### Code Review Checklist137138- [ ] Follows Swift style guidelines (naming, structure, access control)139- [ ] No force unwrapping (!) except in justified cases140- [ ] Proper memory management (no retain cycles, weak references where needed)141- [ ] UI updates on main thread (@MainActor or DispatchQueue.main)142- [ ] Error handling with proper Error types143- [ ] Accessibility labels and hints where appropriate144- [ ] Dynamic Type support for text145- [ ] Dark mode compatibility tested146- [ ] HIG compliance (spacing, colors, components)147- [ ] Performance profiled (no obvious leaks or slow operations)148149## Common Patterns150151### SwiftUI View with ViewModel152153```swift154@MainActor155class UserViewModel: ObservableObject {156 @Published private(set) var users: [User] = []157 @Published private(set) var isLoading = false158159 private let service: UserServiceProtocol160161 init(service: UserServiceProtocol = UserService()) {162 self.service = service163 }164165 func loadUsers() async {166 isLoading = true167 do {168 users = try await service.fetchUsers()169 } catch {170 // Handle error171 }172 isLoading = false173 }174}175176struct UsersView: View {177 @StateObject private var viewModel = UserViewModel()178179 var body: some View {180 Group {181 if viewModel.isLoading {182 ProgressView()183 } else {184 List(viewModel.users) { user in185 UserRow(user: user)186 }187 }188 }189 .task {190 await viewModel.loadUsers()191 }192 }193}194```195196### Network Request with async/await197198```swift199func fetchUser(id: String) async throws -> User {200 let url = URL(string: "https://api.example.com/users/\(id)")!201 let (data, response) = try await URLSession.shared.data(from: url)202203 guard let httpResponse = response as? HTTPURLResponse,204 (200...299).contains(httpResponse.statusCode) else {205 throw NetworkError.serverError206 }207208 return try JSONDecoder().decode(User.self, from: data)209}210```211212### Observable Model (iOS 17+)213214```swift215@Observable216class ViewModel {217 var items: [Item] = []218 var isLoading = false219220 func loadItems() async {221 isLoading = true222 items = await fetchItems()223 isLoading = false224 }225}226227// In SwiftUI - automatically observes changes228struct ContentView: View {229 let viewModel = ViewModel()230231 var body: some View {232 List(viewModel.items) { item in233 Text(item.name)234 }235 }236}237```238239## Platform-Specific Considerations240241### iOS242243- Support multiple screen sizes (iPhone SE to Pro Max)244- Handle Dynamic Island on iPhone 14 Pro+245- Safe area insets for notch/home indicator246- Tab bar for 3-5 top-level sections247- Pull-to-refresh for content updates248249### macOS250251- Menu bar with standard menus (App, File, Edit, View, Window, Help)252- Window management (resize, minimize, maximize)253- Keyboard shortcuts for all actions254- Toolbar customization255- Right-click context menus256257### iPad258259- Support Split View and Slide Over multitasking260- Adapt layout for different sizes261- Keyboard shortcuts262- Pointer/trackpad support263- Drag and drop between apps264265### watchOS266267- Glanceable information268- Large touch targets (full screen width)269- Digital Crown for scrolling270- Minimal text input271272### tvOS273274- Focus-based navigation (Siri Remote)275- 10-foot viewing distance276- Large, clear text and images277- No touch interaction278279## Accessibility280281Always implement:282283- VoiceOver labels for images and controls284- Accessibility hints for complex interactions285- Dynamic Type support for all text286- Minimum 4.5:1 contrast for text287- Reduce Motion support for animations288- Keyboard navigation support (macOS)289290## Testing291292- Unit tests for ViewModels and business logic293- UI tests for critical user flows294- Test on multiple devices and screen sizes295- Test in both light and dark mode296- Test with Dynamic Type at various sizes297- Test with VoiceOver enabled298- Profile with Instruments before release299300## Resources301302This skill includes comprehensive reference documentation:303304### references/swift-best-practices.md305306Complete Swift programming best practices covering code organization, type307safety, optionals, protocol-oriented programming, modern Swift features, memory308management, concurrency, and testing patterns.309310### references/swiftui-patterns.md311312SwiftUI design patterns including view composition, state management, MVVM313architecture, layout techniques, navigation patterns, animations, performance314optimization, and accessibility.315316### references/human-interface-guidelines.md317318Apple's Human Interface Guidelines covering design principles, platform319conventions, typography, color, layout, components, accessibility, gestures, and320platform-specific patterns for iOS, macOS, iPad, watchOS, and tvOS.321322### references/apple-frameworks.md323324Comprehensive reference for Apple frameworks including Foundation, UIKit,325AppKit, networking, Core Data, SwiftData, Combine, CloudKit, StoreKit, Core326Location, MapKit, HealthKit, AVFoundation, and Core Animation.327328### references/performance-optimization.md329330Performance optimization techniques covering app launch, memory management, CPU331optimization, rendering, networking, battery efficiency, database performance,332profiling with Instruments, and testing.