← ClaudeAtlas

swiftui-architecturelisted

SwiftUI app architecture — MVVM + Coordinator pattern, Observation framework (@Observable view models, @Bindable in views, replacing ObservableObject/@Published on the iOS 17 floor), NavigationStack + type-safe NavigationPath routing owned by a coordinator, state-ownership rules (@State/@Binding/@Environment/@Bindable), Combine bridging for callback APIs, and UIKit interop (UIViewRepresentable, UIHostingController) for camera preview and background-blur masking. Use when building a SwiftUI screen, wiring a view model, adding navigation/routing, deciding which state-ownership property wrapper applies, or bridging a UIKit/Combine API into SwiftUI. Requires the swift module. Not for iOS SDK frameworks (ios-platform) or pure language questions (swift).
hmj1026/dhpk · ★ 1 · Web & Frontend · score 72
Install: claude install-skill hmj1026/dhpk
# SwiftUI architecture — MVVM + Coordinator Load references on demand: - `references/mvvm-coordinator.md` — layer responsibilities, DI/factory, Coordinator protocol. - `references/observation-state.md` — `@Observable`/`@Bindable` vs `ObservableObject`, ownership. - `references/navigation.md` — `NavigationStack`/`NavigationPath`, type-safe routes. - `references/interop.md` — Combine bridge + `UIViewRepresentable`/`UIHostingController`. --- ## Core rules 1. **Views are thin and declarative.** No business logic, no persistence, no networking in a `View`. A view reads state from its view model and sends intents back. Logic that isn't "how to render" belongs in the view model or a service. 2. **View models are `@Observable @MainActor`.** On the iOS 17 floor prefer the Observation framework (`@Observable`) over `ObservableObject` + `@Published`. Don't mix the two paradigms in one type. Inject dependencies (services) via the initializer behind protocols — never `import`-reach into singletons. 3. **Navigation is owned by a Coordinator, not scattered in views.** A `NavigationStack` bound to a coordinator-held `NavigationPath`; views append typed route values, the coordinator maps routes → destination views. 4. **State ownership is explicit.** `@State` for value-typed view-local state; `@Bindable` for a two-way binding to an `@Observable` model; `@Binding` for delegated ownership; `@Environment` for ambient dependencies. Owning the same state in