Use when designing, comparing, refactoring, or reviewing architecture for iOS or macOS apps, especially for MVVM, The Composable Architecture (TCA), Clean Architecture, VIPER, Coordinators, Repository and dependency-injection patterns, modular Swift Package structure, Swift 6+, Observation, or architecture-level testing decisions. Do not use for narrow UI-only work that does not involve an app-structure choice.
A curated toolkit of decision frameworks, runnable analyzers, boilerplate generators and reference guides for building maintainable Apple platform applications. This skill has been refreshed for Swift 6 and the new Observation framework, and it introduces guidance for staying current with evolving patterns and third‑party dependencies.
Use this skill when you need to:
Architecture patterns evolve quickly with language features and framework changes. Before recommending a pattern or generating boilerplate, perform targeted research using the web search tools built into the agent. The following list summarises what to check and when:
@Shared) and
improvements to observation and persistence【481379339866622†L27-L36】.【746950836239898†L232-L243】@Reducer macros or Store.publisher behave differently, update your
templates accordingly.async/await), and enable strict concurrency checking
in your build settings to catch data‑race safety issues early【723763396857538†L16-L24】.ObservableObject and
@Published by using the @Observable macro【78975759551952†L201-L217】. The
framework lets you mark a type as observable, track changes within an
instance, and observe those changes in the UI【78975759551952†L209-L214】.site:reddit.com/r/iOSProgramming for
“MVVM vs TCA 2025” and “modern iOS architecture 2025” to understand
developer sentiment. Many practitioners note that TCA’s learning curve and
tight coupling can hinder adoption【285873496392749†L73-L88】, while MVVM
implementations vary and may suffer from weak separation of concerns【285873496392749†L94-L99】.@Observable) or upcoming
language features.Last verified: 2025‑10‑28
This skill contains:
apple-architecture-patterns/
├─ SKILL.md # decision framework and high‑level guidance (this file)
├─ scripts/ # analyzers, graph generators, boilerplate and migration tools
├─ examples/ # mini‑apps demonstrating each pattern (MVVM, TCA, Clean, VIPER, etc.)
├─ references/ # detailed guides for each pattern (mvvm, tca, clean, viper)
└─ templates/ # ready‑made Swift files and folder layouts for rapid prototyping
Rather than crowd this top‑level skill with lengthy tutorials, detailed information lives in separate reference files. Refer to the following for in‑depth treatment:
references/mvvm-guide.md for
updated MVVM practices, including how the @Observable macro simplifies
state management and reduces boilerplate.references/tca-guide.md for
the latest on reducers, stores, effects, shared state and testing.references/clean-guide.md for
domain‑driven layers, strict concurrency, actors and dependency inversion.references/viper-guide.md for
module boundaries, navigation, and tips to avoid boilerplate.Additional resources (migration strategies, comparison matrix, testing
approaches and project structure diagrams) live in the references/ directory as
well.
Deciding on an architecture is not a one‑size‑fits‑all exercise. Use the following high‑level decision tree (rendered in Mermaid syntax) to narrow down options based on team size, domain complexity and legacy constraints:
flowchart TD
A[Start: New or Existing App?] -->|New| B{Team Experience?}
A -->|Existing| M[Audit code with scripts/architecture_analyzer.py]
B -->|Small team, simple domain| MV[Choose MVVM (+Coordinators)]
B -->|Large team or complex business rules| TCA[TCA or Clean Architecture]
TCA --> T1[Need cross‑feature state sharing? Yes → TCA]
MV --> MV1[UI‑first adoption → MVVM + Repository]
T1 --> T2[Strict boundaries & longevity → Clean]
M --> M2{Hotspots?}
M2 -->|Massive VCs| MV2[Introduce ViewModel + Coordinator]
M2 -->|Tight Coupling| R1[Introduce protocols & Repository]
M2 -->|Layer Violations| CLN[Refactor toward Clean/TCA]
| Pattern | Pros | Cons |
|---|---|---|
| MVVM | Lightweight, works well with SwiftUI; easy to adopt; pairs with coordinators | Boundaries are cultural; view models can grow; inconsistent implementations; watch for over‑redrawing unless you use @Observable【285873496392749†L94-L99】 |
| TCA | Unidirectional data flow; excellent testability; composable reducers; new shared state tools【481379339866622†L27-L36】 | Steeper learning curve; ties code to a third‑party library; requires regular updates to avoid breaking changes【746950836239898†L232-L243】 |
| Clean | Clear separation of UI, domain and data; framework agnostic; longevity | Extra layers and indirection; requires documentation and code reviews |
| VIPER | Explicit module boundaries; highly testable | Verbose; heavy for simple screens |
| Coordinators | Separates navigation from views; reusable flows | Coordinators can become large; child‑parent lifecycle management required |
To scale your application:
@Shared only when state truly needs to be shared【481379339866622†L27-L36】.-strict-concurrency=complete) to catch
data races【723763396857538†L16-L24】.templates/adr/ADR-000-template.md).scripts/boilerplate_generator.py to create
consistent folder structures.scripts/architecture_analyzer.py and
scripts/dependency_graph_generator.py in CI to detect layering violations.@Observable) to reduce boilerplate and
improve performance【78975759551952†L201-L217】.Audit a project:
python3 scripts/architecture_analyzer.py --path /path/to/MyApp --out report.json
Generate a dependency graph:
python3 scripts/dependency_graph_generator.py --path /path/to/MyApp --format mermaid --out deps.md
Detect architecture violations:
python3 scripts/violation_detector.py --path /path/to/MyApp --out violations.json
Suggest refactors (e.g. MVC → MVVM → TCA):
python3 scripts/refactor_suggester.py --path /path/to/MyApp --target tca
Scaffold a new feature/app:
python3 scripts/boilerplate_generator.py --arch mvvm --name Profile --into ./Features
Check the installed TCA version:
python3 scripts/check_tca_version.py --package-file /path/to/Package.swift