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