swift-optimise
Original:🇺🇸 English
Translated
Swift 6.2 and SwiftUI performance optimization for iOS 26 clinic architecture codebases. Covers async/await concurrency patterns, Sendable/actor isolation, view/render performance, and animation performance while preserving modular MVVM-C boundaries across App, Feature, Domain, and Data layers. Use when profiling or optimizing Swift/SwiftUI behavior in clinic modules.
1installs
Sourcepproenca/dot-skills
Added on
NPX Install
npx skill4agent add pproenca/dot-skills swift-optimiseTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Apple Swift/SwiftUI Performance Optimization Best Practices
Comprehensive guide for Swift and SwiftUI performance optimization. Contains 19 rules across 3 categories covering modern concurrency, render performance, and animation performance. Targets iOS 26 / Swift 6.2 with @Observable and Swift 6 strict concurrency.
Clinic Architecture Contract (iOS 26 / Swift 6.2)
All guidance in this skill assumes the clinic modular MVVM-C architecture:
- Feature modules import +
Domainonly (neverDesignSystem, never sibling features)Data - App target is the convergence point and owns , concrete coordinators, and Route Shell wiring
DependencyContainer - stays pure Swift and defines models plus repository,
Domain,*Coordinating, andErrorRoutingcontractsAppError - owns SwiftData/network/sync/retry/background I/O and implements Domain protocols
Data - Read/write flow defaults to stale-while-revalidate reads and optimistic queued writes
- ViewModels call repository protocols directly (no default use-case/interactor layer)
When to Apply
Reference these guidelines when:
- Migrating to Swift 6 strict concurrency (Sendable, actor isolation)
- Replacing Combine publishers with async/await
- Implementing @MainActor isolation and actor-based concurrency
- Decomposing views to reduce state invalidation blast radius
- Optimizing scroll and render performance with lazy containers
- Using Canvas/TimelineView for high-performance rendering
- Profiling with SwiftUI Instruments before optimizing
- Building performant spring animations and transitions
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Concurrency & Async | CRITICAL | |
| 2 | Render & Scroll Performance | HIGH | |
| 3 | Animation Performance | MEDIUM | |
Quick Reference
1. Concurrency & Async (CRITICAL)
- - Replace Combine publishers with async/await
conc-combine-to-async - - Use @MainActor instead of DispatchQueue.main
conc-mainactor-isolation - - Adopt Sendable and Swift 6 strict concurrency
conc-swift6-sendable - - Use .task(id:) for reactive data loading
conc-task-id-pattern - - Replace lock-based shared state with actors
conc-actor-for-shared-state - - Replace NotificationCenter observers with AsyncSequence
conc-asyncsequence-streams
2. Render & Scroll Performance (HIGH)
- - Decompose views to limit state invalidation blast radius
perf-view-decomposition - - Profile with SwiftUI Instruments before optimizing
perf-instruments-profiling - - Use lazy containers for large collections
perf-lazy-containers - - Use Canvas and TimelineView for high-performance rendering
perf-canvas-timeline - - Use drawingGroup for complex graphics
perf-drawinggroup - - Add Equatable conformance to prevent spurious redraws
perf-equatable-views - - Use .task modifier instead of .onAppear for async work
perf-task-modifier - - Use AsyncImage with caching strategy for remote images
perf-async-image
3. Animation Performance (MEDIUM)
- - Use spring animations as default
anim-spring - - Use matchedGeometryEffect for shared transitions
anim-matchedgeometry - - Make animations gesture-driven
anim-gesture-driven - - Use withAnimation for state-driven transitions
anim-with-animation - - Apply transition effects for view insertion and removal
anim-transition-effects
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |