A comprehensive guide to SwiftUI architectural patterns with working examples of NavigationSplitView implementations.
β οΈ Disclaimer: This guide and documentation were created with assistance from GitHub Copilot. While we strive for accuracy, there may be errors or outdated information. Please verify critical information and test thoroughly in your own projects. Contributions and corrections are welcome!
Use MVVM for most apps. It balances simplicity, testability, and maintainability without excessive complexity.
Use MVVM-C if you have complex navigation flows or need ViewModels to be completely independent of navigation.
Avoid VIPER, TCA, and Redux unless you have specific requirements that justify the added complexity.
| Pattern | When to Use | Why |
|---|---|---|
| MVVM | 90% of production apps | β Best balance of simplicity and structure β’ β Easy to test β’ β Minimal boilerplate β’ β Works with SwiftUI's reactive model |
| MVVM-C | Complex navigation, deep linking | β Clear navigation boundaries β’ β Reusable ViewModels β’ β Great for coordinator patterns |
| Pattern | When to Use | Why Be Careful |
|---|---|---|
| TCA | Functional programming teams, high testability needs | |
| Redux | Web developers familiar with Redux | |
| VIPER | Large teams, enterprise apps |
| Pattern | Purpose |
|---|---|
| ViewOnly | Learn SwiftUI basics, prototypes |
π New here? Start with: Documentation/GETTING_STARTED.md
π§ Setting up TCA/Redux? See: SETUP.md
- Open
SwiftUIExamples.xcodeprojin Xcode - Run with βR
- Select an implementation to explore
| Aspect | ViewOnly | MVVM β | MVVM-C β | TCA | Redux | VIPER | MVC | Clean | MVI | VIP | Modular |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Complexity | Simple | Moderate | Moderate | High | Moderate | Very High | Simple | Very High | Moderate | Very High | Very High |
| Learning Curve | Easy | Moderate | Moderate | Steep | Moderate | Steep | Easy | Steep | Moderate | Steep | Steep |
| Testability | Poor | Excellent | Excellent | Excellent | Excellent | Excellent | Poor | Excellent | Excellent | Excellent | Excellent |
| Boilerplate | Minimal | Low | Low | High | High | Very High | Minimal | Very High | High | Very High | High |
| Dev Speed | Fast | Fast | Fast | Slow | Moderate | Slow | Fast | Slow | Moderate | Slow | Slow |
| Team Size | 1-2 | 2-10 | 3-10 | 3-10 | 2-10 | 5+ | 1-3 | 5+ | 2-10 | 5+ | 10+ |
| Best For | Learning | Most apps | Complex nav | Functional teams | Web background | Enterprise | UIKit/Legacy | DDD/Domain | Android teams | Alt VIPER | Multi-team |
| Dependencies | None | None | None | TCA library | Optional | None | None | None | Optional | None | SPM |
| File Count | ~10 | ~15 | ~17 | ~12 | ~15 | ~20 | ~8 | ~25+ | ~15 | ~18 | Varies |
| Status | β | β | β | β | β | β | π« Not for UI | π Planned | π Planned | π Planned | π Planned |
β = Recommended for production
β
= Implemented in this repo
π = Planned / Reference only
π« = Not recommended for SwiftUI
| Document | Purpose | Time |
|---|---|---|
| CONCEPTUAL_OVERVIEW.md | Visual pattern comparison | 15 min |
| ViewOnly_Architecture.md | Simple pattern deep-dive | 30 min |
| MVVM_Architecture.md | Production pattern guide | 45 min |
| MVVMC_Architecture.md | Coordinator pattern guide | 45 min |
| TCA_Architecture.md | TCA pattern deep-dive | 45 min |
| Redux_Architecture.md | Redux pattern deep-dive | 45 min |
| VIPER_Architecture.md | Enterprise pattern guide | 60 min |
| DATA_FLOW_EXPLANATION.md | Data flow patterns | 20 min |
- Start with ViewOnly pattern
- Learn
@State,@Binding, and basic SwiftUI concepts - Move to MVVM when ready for production
- Study MVVM pattern (recommended)
- Implement with Models, ViewModels, and Views
- Add Coordinator (MVVM-C) if navigation becomes complex
- Evaluate if MVVM is sufficient (usually is)
- Consider TCA only for functional programming teams
- Avoid VIPER unless working on large enterprise apps
Examples/
Examples/
βββ ViewOnly/ # Simple pattern (learning)
βββ MVVM/ # β Recommended for most apps
β βββ Models/ # Pure data structures
β βββ ViewModels/ # Business logic (@Observable)
β βββ Views/ # SwiftUI UI components
βββ MVVMC/ # β For complex navigation
β βββ Models/
β βββ ViewModels/ # Business logic only
β βββ Coordinators/ # Navigation logic
β βββ Views/
βββ TCA/ # Functional architecture
βββ Redux/ # Unidirectional data flow
βββ VIPER/ # Maximum separation
Documentation/
βββ GETTING_STARTED.md # οΏ½ Start here
βββ CONCEPTUAL_OVERVIEW.md # Pattern diagrams
βββ *_Architecture.md # Detailed guides
βββ IMPLEMENTATION_SUMMARY.md # Technical reference
- Building most iOS/macOS apps
- Want testable code without excessive complexity
- Working with small to medium teams
- Need to ship features quickly
- Want to stay close to SwiftUI's patterns
- Navigation logic is complex (deep linking, flow coordination)
- ViewModels need to be navigation-agnostic
- Building modular features that can be navigated differently
- Need clear separation between business and navigation logic
- You don't have specific requirements justifying them
- Team is small or inexperienced with the pattern
- Speed of development is important
- Maintaining simplicity is valued
These patterns are not implemented in this repository but are worth knowing about:
Status: π« Not Recommended for SwiftUI
Key Characteristics:
- Classic iOS pattern from UIKit era
- Controller mediates between Model and View
- In SwiftUI, leads to "Massive View Controllers" problem
- SwiftUI's declarative nature makes traditional MVC awkward
- State management becomes unclear with SwiftUI's reactive updates
Why not use it: SwiftUI's architecture naturally pushes away from MVC. MVVM is the spiritual successor and works much better with SwiftUI's reactive patterns.
Status: π Advanced pattern to consider
Key Characteristics:
- Domain-centric with concentric layers (Entities β Use Cases β Interface Adapters β Frameworks)
- Business logic completely independent of UI and frameworks
- Strong separation of concerns with dependency inversion
- Can combine with MVVM, VIPER, or other presentation patterns
- Excellent for domain-driven design (DDD)
When to consider: Large enterprise apps with complex business rules that change independently of UI. Overkill for most apps.
Status: π Niche alternative
Key Characteristics:
- User actions are captured as "Intents"
- Intents trigger Model updates
- Model changes drive View rendering
- Unidirectional data flow (similar to Redux/TCA)
- Popular in Android development, less common in iOS
When to consider: If your team has Android experience or you prefer thinking in terms of user intent over actions.
Status: π Alternative to VIPER
Key Characteristics:
- Clean Swift architecture pattern
- Unidirectional data flow cycle: View β Interactor β Presenter β View
- No Router component (navigation handled differently)
- Heavy use of protocols for testing
- Less component separation than VIPER
When to consider: Alternative to VIPER if you prefer the VIP data flow cycle. Still has high complexity.
Status: π Organizational strategy
Key Characteristics:
- Organizes code by feature/domain rather than layer
- Each module is a separate Swift Package with clear boundaries
- Modules can use any internal pattern (MVVM, TCA, etc.)
- Enables parallel team development
- Improves build times and enforces separation
When to consider: Large apps with multiple teams. Can be combined with any presentation pattern. Adds significant project setup complexity.
Status: π Functional alternative
Key Characteristics:
- Functional programming pattern from Elm language
- Model + Update + View structure
- Pure functions and immutable state
- Inspiration for Redux and TCA
- Messages instead of Actions
When to consider: TCA is the iOS equivalent - use that instead unless you specifically need Elm's exact model.
- Hacking with Swift - Paul Hudson's comprehensive free tutorials, articles, and projects. Features "100 Days of SwiftUI" challenge.
- Swift by Sundell - In-depth articles, tips, and best practices by John Sundell. Excellent for intermediate to advanced developers.
- Ray Wenderlich (Kodeco) - High-quality tutorials, books, and video courses. Well-known in the iOS community.
- AppCoda - Beginner-friendly tutorials covering Swift and iOS development fundamentals.
- CodeWithChris - YouTube channel with beginner-friendly Swift and SwiftUI tutorials.
- Sean Allen - Swift, iOS development, and software engineering career advice.
- Stewart Lynch - Practical SwiftUI tutorials and tips.
- Kavsoft - Advanced SwiftUI animations and UI implementations.
- Swift Apprentice - Comprehensive beginner to advanced Swift book by Ray Wenderlich team.
- SwiftUI Apprentice - Learn SwiftUI by building real apps.
- iOS Programming: The Big Nerd Ranch Guide - Classic iOS development book.
- Codecademy - Learn Swift - Interactive Swift course with hands-on exercises.
- Swift Playgrounds - Apple's interactive app for learning Swift on iPad and Mac.
- Swift Forums - Official Swift community forums.
- r/SwiftUI - Active Reddit community for SwiftUI discussions.
- r/iOSProgramming - General iOS development subreddit.
- Swift.org - Official Swift language website with documentation and community resources.
MIT License - Use freely for learning and production.