Approach: Production-First Iterative Refactoring — This skill is built for production enterprise codebases where stability and reviewability matter more than speed. Architecture changes are delivered through iterative refactoring — small, focused PRs (≤200 lines, single concern) tracked in a refactoring/ directory. Critical safety issues ship first; cosmetic improvements come last.
UIKit MVVM Architecture (iOS 13+)
Enterprise-grade UIKit MVVM architecture skill. Opinionated: prescribes Combine-bound ViewModels, Coordinator navigation, constructor injection via factories, ViewState enum, DiffableDataSource, and programmatic Auto Layout. Adopts a production-first iterative refactoring approach — every pattern is chosen for testability, reviewability, and safe incremental adoption in large teams. UIKit MVVM remains the dominant production architecture for large-scale iOS apps.
Architecture Layers
View/ViewController → UIViewController + UIView. Binds to ViewModel via Combine/closures/GCD. Renders state.
ViewModel Layer → Zero UIKit imports. Exposes ViewState<T>. Uses @Published (Combine) or closures (GCD).
Coordinator Layer → Manages navigation flow. Creates ViewModels + VCs. Owns UINavigationController.
Repository Layer → Protocol-based data access. Hides data source details.
Service Layer → URLSession, persistence. Injected via protocol. May use GCD or async/await.
Quick Decision Trees
"Should this ViewController have a ViewModel?"
Is there business logic, networking, or complex state?
├── YES → Create a ViewModel (see "Which binding mechanism" below for Combine vs closures)
└── NO → Is it a container/flow controller (tab bar, navigation)?
├── YES → Coordinator manages it, no ViewModel needed
└── NO → No ViewModel needed unless it simplifies testing
"Which binding mechanism should I use?"
Is this a legacy codebase with heavy GCD / completion handlers?
├── YES → Is the goal to extract ViewModels first (keep GCD)?
│ ├── YES → Closures / Bindable<T> + GCD in service layer
│ │ └── Upgrade to Combine later (see migration-patterns.md)
│ └── NO → Adopt Combine during extraction
│ └── @Published + sink (production standard)
└── NO → What is the minimum iOS target?
├── iOS 13+ → Combine: @Published + sink
│ └── One-shot events? → PassthroughSubject
└── < iOS 13 → Closures / Bindable<T> wrapper
"Where do dependencies come from?"
ViewModel always receives dependencies via constructor:
init(service: NetworkServiceProtocol)
Who creates the ViewModel?
├── Coordinator (recommended)
│ └── Coordinator owns factory, creates VM with deps, passes to VC init
├── VC creates it (simpler apps)
│ └── VC receives deps via init, passes to VM init
└── DI Container (large apps, 20+ screens)
└── Container resolves protocols, coordinator pulls from container
"How should I handle navigation?"
Is there more than one navigation flow (auth + main, tabs)?
├── YES → Coordinator pattern with parent/child hierarchy
│ └── AppCoordinator → AuthCoordinator / MainCoordinator → TabCoordinator
└── NO → Single Coordinator wrapping UINavigationController
└── ViewModel signals navigation via closures, never UIKit imports
Workflows
Default workflow: Analyze & Refactor (below). New screen creation applies the same patterns but from a clean slate. In production enterprise codebases, most work is iterative modernization — not greenfield.
Workflow: Analyze & Refactor Existing MVC Codebase
When: First encounter with a legacy UIKit MVC codebase — the most common enterprise scenario.
- Scan for anti-patterns using the detection checklist (
references/anti-patterns.md)
- Create
refactoring/ directory with per-feature plan files (references/refactoring-workflow.md)
- Write each issue with full description (Location, Severity, Problem, Fix) — titles alone get forgotten
- Categorize issues by severity: 🔴 Critical → 🟡 High → 🟢 Medium
- Plan Phase 1 PR: fix critical safety issues only (≤200 lines per PR)
- Execute one PR at a time. New findings go to
refactoring/discovered.md with full descriptions, NOT into current PR
- After completing each fix: mark the task
- [x] and update the Progress table
- Proceed through phases: Critical → ViewModel extraction → Coordinator → Combine bindings → DI
Workflow: Create a New Screen
When: Building a new feature screen from scratch. Apply enterprise patterns from the start.
- Define the data model and repository protocol (
references/testing.md for mock pattern)
- Create ViewModel: plain class with
private(set) var state: ViewState<T> — zero UIKit imports (use @Published + Combine or closures per the binding mechanism decision tree)
- Add
// MARK: - sections: Properties, Init, Actions, Computed Properties
- Create the ViewController with constructor injection:
init(viewModel: MyViewModel)
- Wire Combine bindings in
setupBindings() called from viewDidLoad
- Build UI programmatically with Auto Layout (
references/layout-approaches.md)
- Add Coordinator route and factory method (
references/coordinator-navigation.md)
- Create test file with mock repository (
references/testing.md)
Workflow: Extract ViewModel from Massive ViewController
When: Refactoring an existing MVC screen to MVVM incrementally.
- Identify all state properties in the VC (data, loading flags, error state)
- Create ViewModel class — move state properties to
@Published private(set) var
- Move business logic methods from VC to VM (networking, validation, formatting)
- Add Combine
@Published to VM state, Set<AnyCancellable> to VC
- Replace direct state access in VC with
viewModel.$property.sink bindings
- Remove all
import UIKit from ViewModel — compiler will flag violations
- Write tests for the ViewModel (now possible since VM has no UIKit dependency)
- Verify VC only does: bind, render, forward user actions to VM
Workflow: Introduce Coordinators to Existing MVVM
When: Navigation is scattered across ViewControllers. Adding Coordinators incrementally.
- Start with one flow (e.g., auth flow or a tab's navigation stack)
- Create Coordinator protocol and AppCoordinator (
references/coordinator-navigation.md)
- Move VC creation from VCs/Storyboard segues to Coordinator's factory methods
- Replace
performSegue / pushViewController calls with ViewModel navigation closures
- Wire Coordinator as
UINavigationControllerDelegate for back-button cleanup
- Add child coordinator lifecycle management (didFinish delegate pattern)
- Test Coordinator with mock
UINavigationController (references/testing.md)
Code Generation Rules
- ViewModels import only
Foundation and Combine — never UIKit
- Use
@Published private(set) var for state properties modified only by the ViewModel
- Use
ViewState<T> enum for async data — never separate boolean flags
- Inject dependencies via constructor with protocol types
- Bind in
viewDidLoad using setupBindings() — store in Set<AnyCancellable>
- Always
[weak self] in sink closures when stored in cancellables
- Always
.receive(on: DispatchQueue.main) before UI updates in sink
- Add
// MARK: - sections: Properties, Init, Lifecycle, Bindings, Actions
- Use programmatic Auto Layout —
translatesAutoresizingMaskIntoConstraints = false
- Keep every generated file ≤ 400 lines. Extract child VCs or ViewModel extensions when approaching that limit.
- Before modifying a ViewController, output a brief
<thought> analyzing its current dependencies and retain cycles.
When generating tests, ALWAYS:
- Use protocol mocks with
var stubbed* and var *CallCount tracking
- Test through public interface, never test private methods
- Use
XCTestExpectation + sink + dropFirst() for Combine publisher tests
- Use
await fulfillment(of:) for async tests — NEVER wait(for:) in async contexts. When you write async test code in a response, the actual code example must call await fulfillment(of: [expectation], timeout: 2.0), not wait(for: [expectation], timeout: 2.0). Mentioning the modern API only in a note while the code uses wait(for:) still hangs the test — it's the classic cooperative-pool deadlock. In XCTestCase this is a synchronous blocking call that cannot pump the queue, so the expectation never fulfills:
// ❌ WRONG — deadlocks in async test function
func test_load_updates_items() async {
let exp = expectation(description: "items updated")
let cancellable = sut.$items.dropFirst().sink { _ in exp.fulfill() }
await sut.load()
wait(for: [exp], timeout: 2.0) // cooperative-pool deadlock
_ = cancellable
}
// ✅ CORRECT — releases the cooperative thread via await
func test_load_updates_items() async {
let exp = expectation(description: "items updated")
let cancellable = sut.$items.dropFirst().sink { _ in exp.fulfill() }
await sut.load()
await fulfillment(of: [exp], timeout: 2.0)
_ = cancellable
}
- Include memory leak detection with
addTeardownBlock { [weak sut] in XCTAssertNil(sut) }
Fallback Strategies & Loop Breakers
- Combine Type Erasure: If you get generic type mismatch errors with Combine
AnyPublisher, append .eraseToAnyPublisher() to the pipeline or fall back to closures instead of fighting the type system. Why: Combine's generic types nest deeply (e.g., Publishers.Map<Publishers.Filter<...>, Output>), and type erasure is the standard solution.
- DiffableDataSource Generics: If the compiler complains about
Hashable conformance or type differences in NSDiffableDataSourceSnapshot, verify your CellViewModel uses a unique UUID instead of complex nested generic models. Why: DiffableDataSource compares items by hash — nested models with mutable state produce inconsistent hashes and silent data corruption.
- Revert and Restart: If a ViewController refactor spirals into 50+ compiler errors, stop. Propose reverting the changes and breaking the problem into two smaller phases (e.g., extract networking first, then migrate state). Why: UIKit's implicit dependencies cascade — changing one property often breaks unrelated outlets, delegates, and data sources.
Confidence Checks
Before finalizing generated or refactored code, verify ALL:
□ No duplicate functionality — searched codebase for existing implementations
□ Architecture adherence — follows patterns already established in the project
□ Naming conventions — matches existing project naming style
□ Import check — ViewModel imports only Foundation + Combine, NOT UIKit
□ ViewState — used for all async data, no separate isLoading/error booleans
□ Combine bindings — [weak self] in every sink, .receive(on: .main) before UI updates
□ DI — dependencies injected via protocol, not accessed via singletons
□ Coordinator — navigation handled by Coordinator, not by VC pushing other VCs
□ Memory management — deinit cancels Tasks, no retain cycles in closures
□ Tests — corresponding test file exists or is created alongside
□ PR scope — changes within defined scope, new findings go to `refactoring/discovered.md`
□ File size — new files ≤ 400 lines; existing oversized files have a split task logged
Companion Skills
Before generating async ViewModel or migrating completion handlers: determine the project's concurrency approach. If unclear from context, ask the user.
| Project's concurrency stack |
Companion skill |
Apply when |
async/await, actors, Swift 6 (migrating or greenfield) |
skills/swift-concurrency/SKILL.md |
Migrating completion handlers, writing async ViewModel methods, actor-based state |
DispatchQueue, OperationQueue (staying or auditing existing) |
skills/gcd-operations/SKILL.md |
Reviewing existing queue code, writing queue-based concurrency, thread-safe collections |
| Mixed (GCD stays, new code gets async/await) |
Both skills |
Apply GCD rules to existing code, concurrency rules to new code |
If unclear, ask: "Is the team migrating to Swift Concurrency or keeping GCD/OperationQueue?"
References
| Reference |
When to Read |
references/rules.md |
Do's and Don'ts quick reference: priority rules and critical anti-patterns |
references/binding-mechanisms.md |
Combine @Published + sink, closures, async/await, Input/Output pattern, decision matrix |
references/coordinator-navigation.md |
Coordinator protocol, hierarchy, memory management, back button handling, deep linking |
references/viewcontroller-lifecycle.md |
VC lifecycle, ViewState enum, DiffableDataSource, VC containment, keyboard handling |
references/dependency-injection.md |
Constructor injection, Factory pattern, Storyboard DI, Container/Resolver, @Injected wrapper |
references/layout-approaches.md |
Programmatic Auto Layout, UIStackView, XIBs, Storyboards, decision criteria |
references/testing.md |
Testing Combine publishers, async ViewModels, mocking, memory leak detection, Coordinator tests |
references/anti-patterns.md |
Code review detection checklist, severity-ranked UIKit MVVM violations |
references/migration-patterns.md |
MVC → MVVM, UIKit → SwiftUI, Combine adoption strategies |
references/refactoring-workflow.md |
refactoring/ directory protocol, per-feature plans, PR sizing, phase ordering |
references/file-organization.md |
File size guidelines, ViewModel extension splits, child ViewControllers and subclassing views |
1---2name: uikit-mvvm3description: "Use for hands-on UIKit MVVM questions: setting up Combine bindings between UIViewController and ViewModel (@Published + sink), extracting business logic from massive ViewControllers step by step, testing ViewModels with XCTestExpectation + Combine publishers, fixing [weak self] retain cycles in sink closures, migrating DispatchQueue/GCD completion handlers to Combine, or replacing reloadData() with DiffableDataSource. Also covers Coordinator navigation patterns, constructor injection, ViewState enum, and incremental MVC-to-MVVM refactoring. Trigger on any UIKit architecture decision — even when the user doesn't mention 'MVVM' explicitly."4metadata:5 source: https://skillmd.com/skills/aibot88/uikit-mvvm6 version: 1.0.47---89> **Approach: Production-First Iterative Refactoring** — This skill is built for production enterprise codebases where stability and reviewability matter more than speed. Architecture changes are delivered through iterative refactoring — small, focused PRs (≤200 lines, single concern) tracked in a `refactoring/` directory. Critical safety issues ship first; cosmetic improvements come last.1011# UIKit MVVM Architecture (iOS 13+)1213Enterprise-grade UIKit MVVM architecture skill. Opinionated: prescribes Combine-bound ViewModels, Coordinator navigation, constructor injection via factories, ViewState enum, DiffableDataSource, and programmatic Auto Layout. Adopts a **production-first iterative refactoring** approach — every pattern is chosen for testability, reviewability, and safe incremental adoption in large teams. UIKit MVVM remains the dominant production architecture for large-scale iOS apps.1415## Architecture Layers1617```text18View/ViewController → UIViewController + UIView. Binds to ViewModel via Combine/closures/GCD. Renders state.19ViewModel Layer → Zero UIKit imports. Exposes ViewState<T>. Uses @Published (Combine) or closures (GCD).20Coordinator Layer → Manages navigation flow. Creates ViewModels + VCs. Owns UINavigationController.21Repository Layer → Protocol-based data access. Hides data source details.22Service Layer → URLSession, persistence. Injected via protocol. May use GCD or async/await.23```2425## Quick Decision Trees2627### "Should this ViewController have a ViewModel?"2829```30Is there business logic, networking, or complex state?31├── YES → Create a ViewModel (see "Which binding mechanism" below for Combine vs closures)32└── NO → Is it a container/flow controller (tab bar, navigation)?33 ├── YES → Coordinator manages it, no ViewModel needed34 └── NO → No ViewModel needed unless it simplifies testing35```3637### "Which binding mechanism should I use?"3839```text40Is this a legacy codebase with heavy GCD / completion handlers?41├── YES → Is the goal to extract ViewModels first (keep GCD)?42│ ├── YES → Closures / Bindable<T> + GCD in service layer43│ │ └── Upgrade to Combine later (see migration-patterns.md)44│ └── NO → Adopt Combine during extraction45│ └── @Published + sink (production standard)46└── NO → What is the minimum iOS target?47 ├── iOS 13+ → Combine: @Published + sink48 │ └── One-shot events? → PassthroughSubject49 └── < iOS 13 → Closures / Bindable<T> wrapper50```5152### "Where do dependencies come from?"5354```55ViewModel always receives dependencies via constructor:56 init(service: NetworkServiceProtocol)5758Who creates the ViewModel?59├── Coordinator (recommended)60│ └── Coordinator owns factory, creates VM with deps, passes to VC init61├── VC creates it (simpler apps)62│ └── VC receives deps via init, passes to VM init63└── DI Container (large apps, 20+ screens)64 └── Container resolves protocols, coordinator pulls from container65```6667### "How should I handle navigation?"6869```70Is there more than one navigation flow (auth + main, tabs)?71├── YES → Coordinator pattern with parent/child hierarchy72│ └── AppCoordinator → AuthCoordinator / MainCoordinator → TabCoordinator73└── NO → Single Coordinator wrapping UINavigationController74 └── ViewModel signals navigation via closures, never UIKit imports75```7677## Workflows7879> **Default workflow**: Analyze & Refactor (below). New screen creation applies the same patterns but from a clean slate. In production enterprise codebases, most work is iterative modernization — not greenfield.8081### Workflow: Analyze & Refactor Existing MVC Codebase8283**When:** First encounter with a legacy UIKit MVC codebase — the most common enterprise scenario.84851. Scan for anti-patterns using the detection checklist (`references/anti-patterns.md`)862. Create `refactoring/` directory with per-feature plan files (`references/refactoring-workflow.md`)873. Write each issue with **full description** (Location, Severity, Problem, Fix) — titles alone get forgotten884. Categorize issues by severity: 🔴 Critical → 🟡 High → 🟢 Medium895. Plan Phase 1 PR: fix critical safety issues only (≤200 lines per PR)906. Execute one PR at a time. New findings go to `refactoring/discovered.md` with full descriptions, NOT into current PR917. After completing each fix: mark the task `- [x]` and update the Progress table928. Proceed through phases: Critical → ViewModel extraction → Coordinator → Combine bindings → DI9394### Workflow: Create a New Screen9596**When:** Building a new feature screen from scratch. Apply enterprise patterns from the start.97981. Define the data model and repository protocol (`references/testing.md` for mock pattern)992. Create ViewModel: plain class with `private(set) var state: ViewState<T>` — zero UIKit imports (use `@Published` + Combine or closures per the binding mechanism decision tree)1003. Add `// MARK: -` sections: Properties, Init, Actions, Computed Properties1014. Create the ViewController with constructor injection: `init(viewModel: MyViewModel)`1025. Wire Combine bindings in `setupBindings()` called from `viewDidLoad`1036. Build UI programmatically with Auto Layout (`references/layout-approaches.md`)1047. Add Coordinator route and factory method (`references/coordinator-navigation.md`)1058. Create test file with mock repository (`references/testing.md`)106107### Workflow: Extract ViewModel from Massive ViewController108109**When:** Refactoring an existing MVC screen to MVVM incrementally.1101111. Identify all state properties in the VC (data, loading flags, error state)1122. Create ViewModel class — move state properties to `@Published private(set) var`1133. Move business logic methods from VC to VM (networking, validation, formatting)1144. Add Combine `@Published` to VM state, `Set<AnyCancellable>` to VC1155. Replace direct state access in VC with `viewModel.$property.sink` bindings1166. Remove all `import UIKit` from ViewModel — compiler will flag violations1177. Write tests for the ViewModel (now possible since VM has no UIKit dependency)1188. Verify VC only does: bind, render, forward user actions to VM119120### Workflow: Introduce Coordinators to Existing MVVM121122**When:** Navigation is scattered across ViewControllers. Adding Coordinators incrementally.1231241. Start with one flow (e.g., auth flow or a tab's navigation stack)1252. Create Coordinator protocol and AppCoordinator (`references/coordinator-navigation.md`)1263. Move VC creation from VCs/Storyboard segues to Coordinator's factory methods1274. Replace `performSegue` / `pushViewController` calls with ViewModel navigation closures1285. Wire Coordinator as `UINavigationControllerDelegate` for back-button cleanup1296. Add child coordinator lifecycle management (didFinish delegate pattern)1307. Test Coordinator with mock `UINavigationController` (`references/testing.md`)131132## Code Generation Rules133134<critical_rules>135Whether generating new code or refactoring existing code, every output must be **production-ready and PR-shippable** — small, focused, and testable. ALWAYS:1361371. ViewModels import only `Foundation` and `Combine` — never `UIKit`1382. Use `@Published private(set) var` for state properties modified only by the ViewModel1393. Use `ViewState<T>` enum for async data — never separate boolean flags1404. Inject dependencies via constructor with protocol types1415. Bind in `viewDidLoad` using `setupBindings()` — store in `Set<AnyCancellable>`1426. Always `[weak self]` in `sink` closures when stored in `cancellables`1437. Always `.receive(on: DispatchQueue.main)` before UI updates in sink1448. Add `// MARK: -` sections: Properties, Init, Lifecycle, Bindings, Actions1459. Use programmatic Auto Layout — `translatesAutoresizingMaskIntoConstraints = false`14610. Keep every generated file ≤ 400 lines. Extract child VCs or ViewModel extensions when approaching that limit.14711. Before modifying a ViewController, output a brief `<thought>` analyzing its current dependencies and retain cycles.148</critical_rules>149150When generating tests, ALWAYS:1511521. Use protocol mocks with `var stubbed*` and `var *CallCount` tracking1532. Test through public interface, never test private methods1543. Use `XCTestExpectation` + `sink` + `dropFirst()` for Combine publisher tests1554. Use `await fulfillment(of:)` for async tests — NEVER `wait(for:)` in async contexts. When you write async test code in a response, the **actual code example must call `await fulfillment(of: [expectation], timeout: 2.0)`**, not `wait(for: [expectation], timeout: 2.0)`. Mentioning the modern API only in a note while the code uses `wait(for:)` still hangs the test — it's the classic cooperative-pool deadlock. In XCTestCase this is a synchronous blocking call that cannot pump the queue, so the expectation never fulfills:156157```swift158// ❌ WRONG — deadlocks in async test function159func test_load_updates_items() async {160 let exp = expectation(description: "items updated")161 let cancellable = sut.$items.dropFirst().sink { _ in exp.fulfill() }162 await sut.load()163 wait(for: [exp], timeout: 2.0) // cooperative-pool deadlock164 _ = cancellable165}166167// ✅ CORRECT — releases the cooperative thread via await168func test_load_updates_items() async {169 let exp = expectation(description: "items updated")170 let cancellable = sut.$items.dropFirst().sink { _ in exp.fulfill() }171 await sut.load()172 await fulfillment(of: [exp], timeout: 2.0)173 _ = cancellable174}175```1765. Include memory leak detection with `addTeardownBlock { [weak sut] in XCTAssertNil(sut) }`177178## Fallback Strategies & Loop Breakers179180<fallback_strategies>181When refactoring legacy code, you may encounter stubborn Swift compiler errors. If you fail to fix the same error twice, break the loop:1821831. **Combine Type Erasure:** If you get generic type mismatch errors with Combine `AnyPublisher`, append `.eraseToAnyPublisher()` to the pipeline or fall back to closures instead of fighting the type system. Why: Combine's generic types nest deeply (e.g., `Publishers.Map<Publishers.Filter<...>, Output>`), and type erasure is the standard solution.1842. **DiffableDataSource Generics:** If the compiler complains about `Hashable` conformance or type differences in `NSDiffableDataSourceSnapshot`, verify your `CellViewModel` uses a unique `UUID` instead of complex nested generic models. Why: DiffableDataSource compares items by hash — nested models with mutable state produce inconsistent hashes and silent data corruption.1853. **Revert and Restart:** If a ViewController refactor spirals into 50+ compiler errors, stop. Propose reverting the changes and breaking the problem into two smaller phases (e.g., extract networking first, then migrate state). Why: UIKit's implicit dependencies cascade — changing one property often breaks unrelated outlets, delegates, and data sources.186</fallback_strategies>187188## Confidence Checks189190Before finalizing generated or refactored code, verify ALL:191192```193□ No duplicate functionality — searched codebase for existing implementations194□ Architecture adherence — follows patterns already established in the project195□ Naming conventions — matches existing project naming style196□ Import check — ViewModel imports only Foundation + Combine, NOT UIKit197□ ViewState — used for all async data, no separate isLoading/error booleans198□ Combine bindings — [weak self] in every sink, .receive(on: .main) before UI updates199□ DI — dependencies injected via protocol, not accessed via singletons200□ Coordinator — navigation handled by Coordinator, not by VC pushing other VCs201□ Memory management — deinit cancels Tasks, no retain cycles in closures202□ Tests — corresponding test file exists or is created alongside203□ PR scope — changes within defined scope, new findings go to `refactoring/discovered.md`204□ File size — new files ≤ 400 lines; existing oversized files have a split task logged205```206207## Companion Skills208209> **Before generating async ViewModel or migrating completion handlers:** determine the project's concurrency approach. If unclear from context, ask the user.210211| Project's concurrency stack | Companion skill | Apply when |212|---|---|---|213| `async/await`, actors, Swift 6 (migrating or greenfield) | `skills/swift-concurrency/SKILL.md` | Migrating completion handlers, writing async ViewModel methods, actor-based state |214| `DispatchQueue`, `OperationQueue` (staying or auditing existing) | `skills/gcd-operations/SKILL.md` | Reviewing existing queue code, writing queue-based concurrency, thread-safe collections |215| Mixed (GCD stays, new code gets async/await) | Both skills | Apply GCD rules to existing code, concurrency rules to new code |216217**If unclear, ask:** "Is the team migrating to Swift Concurrency or keeping GCD/OperationQueue?"218219## References220221| Reference | When to Read |222|-----------|-------------|223| `references/rules.md` | Do's and Don'ts quick reference: priority rules and critical anti-patterns |224| `references/binding-mechanisms.md` | Combine @Published + sink, closures, async/await, Input/Output pattern, decision matrix |225| `references/coordinator-navigation.md` | Coordinator protocol, hierarchy, memory management, back button handling, deep linking |226| `references/viewcontroller-lifecycle.md` | VC lifecycle, ViewState enum, DiffableDataSource, VC containment, keyboard handling |227| `references/dependency-injection.md` | Constructor injection, Factory pattern, Storyboard DI, Container/Resolver, @Injected wrapper |228| `references/layout-approaches.md` | Programmatic Auto Layout, UIStackView, XIBs, Storyboards, decision criteria |229| `references/testing.md` | Testing Combine publishers, async ViewModels, mocking, memory leak detection, Coordinator tests |230| `references/anti-patterns.md` | Code review detection checklist, severity-ranked UIKit MVVM violations |231| `references/migration-patterns.md` | MVC → MVVM, UIKit → SwiftUI, Combine adoption strategies |232| `references/refactoring-workflow.md` | `refactoring/` directory protocol, per-feature plans, PR sizing, phase ordering |233| `references/file-organization.md` | File size guidelines, ViewModel extension splits, child ViewControllers and subclassing views |