1---2name: ios-application-dev3description: iOS application development guide covering UIKit, SnapKit, and SwiftUI. Includes touch targets, safe areas, navigation patterns, Dynamic Type, Dark Mode, accessibility, collection views, common UI components, and SwiftUI design guidelines. For detailed references on specific topics, see the reference files. Use when: developing iOS apps, implementing UI, reviewing iOS code, working with UIKit/SnapKit/SwiftUI layouts, building iPhone interfaces, Swift mobile development, Apple HIG compliance, iOS accessibility implementation.4license: MIT5---6
7# iOS Application Development Guide
8
9A practical guide for building iOS applications using UIKit, SnapKit, and SwiftUI. Focuses on proven patterns and Apple platform conventions.
10
11## Quick Reference
12
13### UIKit
14
15| Purpose | Component |
16|---------|-----------|
17| Main sections | `UITabBarController` |
18| Drill-down | `UINavigationController` |
19| Focused task | Sheet presentation |
20| Critical choice | `UIAlertController` |
21| Secondary actions | `UIContextMenuInteraction` |
22| List content | `UICollectionView` + `DiffableDataSource` |
23| Sectioned list | `DiffableDataSource` + `headerMode` |
24| Grid layout | `UICollectionViewCompositionalLayout` |
25| Search | `UISearchController` |
26| Share | `UIActivityViewController` |
27| Location (once) | `CLLocationButton` |
28| Feedback | `UIImpactFeedbackGenerator` |
29| Linear layout | `UIStackView` |
30| Custom shapes | `CAShapeLayer` + `UIBezierPath` |
31| Gradients | `CAGradientLayer` |
32| Modern buttons | `UIButton.Configuration` |
33| Dynamic text | `UIFontMetrics` + `preferredFont` |
34| Dark mode | Semantic colors (`.systemBackground`, `.label`) |
35| Permissions | Contextual request + `AVCaptureDevice` |
36| Lifecycle | `UIApplication` notifications |
37
38### SwiftUI
39
40| Purpose | Component |
41|---------|-----------|
42| Main sections | `TabView` + `tabItem` |
43| Drill-down | `NavigationStack` + `NavigationPath` |
44| Focused task | `.sheet` + `presentationDetents` |
45| Critical choice | `.alert` |
46| Secondary actions | `.contextMenu` |
47| List content | `List` + `.insetGrouped` |
48| Search | `.searchable` |
49| Share | `ShareLink` |
50| Location (once) | `LocationButton` |
51| Feedback | `UIImpactFeedbackGenerator` |
52| Progress (known) | `ProgressView(value:total:)` |
53| Progress (unknown) | `ProgressView()` |
54| Dynamic text | `.font(.body)` semantic styles |
55| Dark mode | `.primary`, `.secondary`, `Color(.systemBackground)` |
56| Scene lifecycle | `@Environment(\.scenePhase)` |
57| Reduce motion | `@Environment(\.accessibilityReduceMotion)` |
58| Dynamic type | `@Environment(\.dynamicTypeSize)` |
59
60## Core Principles
61
62### Layout
63- Touch targets >= 44pt
64- Content within safe areas (SwiftUI respects by default, use `.ignoresSafeArea()` only for backgrounds)
65- Use 8pt spacing increments (8, 16, 24, 32, 40, 48)
66- Primary actions in thumb zone
67- Support all screen sizes (iPhone SE 375pt to Pro Max 430pt)
68
69### Typography
70- UIKit: `preferredFont(forTextStyle:)` + `adjustsFontForContentSizeCategory = true`
71- SwiftUI: semantic text styles `.headline`, `.body`, `.caption`
72- Custom fonts: `UIFontMetrics` / `Font.custom(_:size:relativeTo:)`
73- Adapt layout at accessibility sizes (minimum 11pt)
74
75### Colors
76- Use semantic system colors (`.systemBackground`, `.label`, `.primary`, `.secondary`)
77- Asset catalog variants for custom colors (Any/Dark Appearance)
78- No color-only information (pair with icons or text)
79- Contrast ratio >= 4.5:1 for normal text, 3:1 for large text
80
81### Accessibility
82- Labels on icon buttons (`.accessibilityLabel()`)
83- Reduce motion respected (`@Environment(\.accessibilityReduceMotion)`)
84- Logical reading order (`.accessibilitySortPriority()`)
85- Support Bold Text, Increase Contrast preferences
86
87### Navigation
88- Tab bar (3-5 sections) stays visible during navigation
89- Back swipe works (never override system gestures)
90- State preserved across tabs (`@SceneStorage`, `@State`)
91- Never use hamburger menus
92
93### Privacy & Permissions
94- Request permissions in context (not at launch)
95- Custom explanation before system dialog
96- Support Sign in with Apple
97- Respect ATT denial
98
99## Checklist
100
101### Layout
102- [ ] Touch targets >= 44pt
103- [ ] Content within safe areas
104- [ ] Primary actions in thumb zone (bottom half)
105- [ ] Flexible widths for all screen sizes (SE to Pro Max)
106- [ ] Spacing aligns to 8pt grid
107
108### Typography
109- [ ] Semantic text styles or UIFontMetrics-scaled custom fonts
110- [ ] Dynamic Type supported up to accessibility sizes
111- [ ] Layouts reflow at large sizes (no truncation)
112- [ ] Minimum text size 11pt
113
114### Colors
115- [ ] Semantic system colors or light/dark asset variants
116- [ ] Dark Mode is intentional (not just inverted)
117- [ ] No color-only information
118- [ ] Text contrast >= 4.5:1 (normal) / 3:1 (large)
119- [ ] Single accent color for interactive elements
120
121### Accessibility
122- [ ] VoiceOver labels on all interactive elements
123- [ ] Logical reading order
124- [ ] Bold Text preference respected
125- [ ] Reduce Motion disables decorative animations
126- [ ] All gestures have alternative access paths
127
128### Navigation
129- [ ] Tab bar for 3-5 top-level sections
130- [ ] No hamburger/drawer menus
131- [ ] Tab bar stays visible during navigation
132- [ ] Back swipe works throughout
133- [ ] State preserved across tabs
134
135### Components
136- [ ] Alerts for critical decisions only
137- [ ] Sheets have dismiss path (button and/or swipe)
138- [ ] List rows >= 44pt tall
139- [ ] Destructive buttons use `.destructive` role
140
141### Privacy
142- [ ] Permissions requested in context (not at launch)
143- [ ] Custom explanation before system permission dialog
144- [ ] Sign in with Apple offered with other providers
145- [ ] Basic features usable without account
146- [ ] ATT prompt shown if tracking, denial respected
147
148### System Integration
149- [ ] App handles interruptions gracefully (calls, background, Siri)
150- [ ] App content indexed for Spotlight
151- [ ] Share Sheet available for shareable content
152
153## References
154
155| Topic | Reference |
156|-------|-----------|
157| Touch Targets, Safe Area, CollectionView | [Layout System](references/layout-system.md) |
158| TabBar, NavigationController, Modal | [Navigation Patterns](references/navigation-patterns.md) |
159| StackView, Button, Alert, Search, ContextMenu | [UIKit Components](references/uikit-components.md) |
160| CAShapeLayer, CAGradientLayer, Core Animation | [Graphics & Animation](references/graphics-animation.md) |
161| Dynamic Type, Semantic Colors, VoiceOver | [Accessibility](references/accessibility.md) |
162| Permissions, Location, Share, Lifecycle, Haptics | [System Integration](references/system-integration.md) |
163| Metal Shaders & GPU | [Metal Shader Reference](references/metal-shader.md) |
164| SwiftUI HIG, Components, Patterns, Anti-Patterns | [SwiftUI Design Guidelines](references/swiftui-design-guidelines.md) |
165| Optionals, Protocols, async/await, ARC, Error Handling | [Swift Coding Standards](references/swift-coding-standards.md) |
166
167---
168
169Swift, SwiftUI, UIKit, SF Symbols, Metal, and Apple are trademarks of Apple Inc. SnapKit is a trademark of its respective owners.