$npx -y skills add johnrogers/claude-swift-engineering --skill swiftui-advancedUse when implementing gesture composition (simultaneous, sequenced, exclusive), adaptive layouts (ViewThatFits, AnyLayout, size classes), or choosing architecture patterns (MVVM vs TCA vs vanilla, State-as-Bridge). Covers advanced SwiftUI patterns beyond basic views.
| 1 | # SwiftUI Advanced |
| 2 | |
| 3 | Advanced SwiftUI patterns for gesture composition, adaptive layouts, architecture decisions, and performance optimization. |
| 4 | |
| 5 | ## Reference Loading Guide |
| 6 | |
| 7 | **ALWAYS load reference files if there is even a small chance the content may be required.** It's better to have the context than to miss a pattern or make a mistake. |
| 8 | |
| 9 | | Reference | Load When | |
| 10 | |-----------|-----------| |
| 11 | | **[Gestures](references/gestures.md)** | Composing multiple gestures, GestureState, custom recognizers | |
| 12 | | **[Adaptive Layout](references/adaptive-layout.md)** | ViewThatFits, AnyLayout, size classes, iOS 26 free-form windows | |
| 13 | | **[Architecture](references/architecture.md)** | MVVM vs TCA decision, State-as-Bridge, property wrapper selection | |
| 14 | | **[Performance](references/performance.md)** | Instruments 26, view body optimization, unnecessary updates | |
| 15 | |
| 16 | ## Core Workflow |
| 17 | |
| 18 | 1. **Identify pattern category** from user's question |
| 19 | 2. **Load relevant reference** for detailed patterns and code examples |
| 20 | 3. **Apply pattern** following the decision trees and anti-patterns |
| 21 | 4. **Verify** using provided checklists or profiling guidance |
| 22 | |
| 23 | ## Decision Trees |
| 24 | |
| 25 | ### Gesture Composition |
| 26 | - Both gestures at same time? -> `.simultaneously` |
| 27 | - One must complete before next? -> `.sequenced` |
| 28 | - Only one should win? -> `.exclusively` |
| 29 | |
| 30 | ### Layout Adaptation |
| 31 | - Pick best-fitting variant? -> `ViewThatFits` |
| 32 | - Animated H/V switch? -> `AnyLayout` |
| 33 | - Need actual dimensions? -> `onGeometryChange` |
| 34 | |
| 35 | ### Architecture Selection |
| 36 | - Small app, Apple patterns? -> @Observable + State-as-Bridge |
| 37 | - Complex presentation logic? -> MVVM with @Observable |
| 38 | - Rigorous testability needed? -> TCA |
| 39 | |
| 40 | ## Common Mistakes |
| 41 | |
| 42 | 1. **Gesture composition order matters** — `.simultaneously` and `.sequenced` have different trigger timing. Swapping them silently changes behavior. Understand gesture semantics before using. |
| 43 | |
| 44 | 2. **ViewThatFits over-used** — ViewThatFits remeasures on every view change. For animated H/V switches, use `AnyLayout` instead. Use ViewThatFits only for static variant selection. |
| 45 | |
| 46 | 3. **onGeometryChange triggering unnecessary updates** — Reading geometry changes geometry, which triggers updates, which changes geometry... circular. Use `.onGeometryChange` only with proper state management to avoid loops. |
| 47 | |
| 48 | 4. **Architecture mismatch mid-project** — Starting with @Observable + State-as-Bridge then realizing you need TCA is expensive. Choose architecture upfront based on complexity (small app = @Observable, complex = TCA). |
| 49 | |
| 50 | 5. **Ignoring view body optimization** — Computing expensive calculations in view body repeatedly kills performance. Move calculations to properties or models. Profile with Instruments 26 before optimizing prematurely. |