ios-swiftui-architect
Architect-level iOS design with SwiftUI and UIKit — view and state ownership, Observation and Swift concurrency, lifecycle and scene phase, navigation stacks, UIKit interop, and the platform integration points that decide app quality. Use when building or restructuring an iOS app.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- ios-swiftui-architect
- license
- MIT
- metadata
- { "crusor-path": "mobile-architect/platforms-architect/ios-swiftui-architect", "crusor-domain": "mobile-architect", "crusor-origin": "original", "crusor-sources": "developer.apple.com/documentation/swiftui; developer.apple.com/documentation/observation; developer.apple.com/documentation/swift/concurrency", "crusor-triggers": "swiftui, uikit, ios app, swift concurrency, observable, navigationstack, scene phase, ipad, ios 18, swift", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level iOS design with SwiftUI and UIKit — view and state ownership, Observation and Swift concurrency, lifecycle and scene phase, navigation stacks, UIKit interop, and the platform integration points that decide app quality. Use when building or restructuring an iOS app.
- compatibility
- iOS 17+, SwiftUI, UIKit interop, Swift 6 concurrency
03 SKILL.md 正文
iOS / SwiftUI Architect
SwiftUI is a declaration of state, not a place to put logic. The architecture is deciding who owns state, who computes it, and where the async work lives.
When to use
- Building a new iOS app or screen set.
- Migrating UIKit to SwiftUI incrementally.
- State or navigation code that has become tangled.
When NOT to use
- The work is cross-platform UI →
react-native-architect/flutter-architect. - The problem is the backend contract.
Decision 1 — State ownership
| Property wrapper | Owns | Use |
|---|---|---|
@State |
local view value | ephemeral UI (toggle, text field) |
@Observable model |
screen state | view model, injected |
@Environment |
dependency or shared value | DI, theme, session |
@Bindable |
two-way into observable | form fields |
@StateObject/@ObservedObject (legacy) |
pre-Observation code | migrate deliberately |
- One owner per piece of state. Two views writing the same concept is the source of most SwiftUI bugs.
- View bodies are pure projections: no networking, no side effects, no heavy computation.
- Derive rather than store: computed properties over duplicated state.
Decision 2 — Concurrency
- Swift concurrency with actor isolation; UI-adjacent types
@MainActor. - Long work in detached tasks or a repository layer; never in
bodyor.taskwithout cancellation. - Cancel on disappear; structured concurrency instead of stray
Task { }chains. Sendableconformance is a design statement about your models — model types as value types where possible.- Async sequences for streams (location, notifications) with explicit teardown.
Decision 3 — Navigation
NavigationStackwith a path value type owned by one coordinator; deep links map into that path.- One route enum per flow, typed, not string identifiers scattered in views.
- Sheets/full-screen covers are presentation state, not navigation state — decide and be consistent.
- iPad: consider
NavigationSplitViewfrom the start; retrofitting is expensive.
Decision 4 — UIKit interop
- Wrap UIKit in
UIViewRepresentable/UIViewControllerRepresentablebehind a narrow interface. - Heavy camera, map, text editing, or collection views may stay UIKit — that is a valid architecture, not a failure.
- Do not mix navigation systems: one stack, one owner.
Decision 5 — Platform integration
- App lifecycle via
scenePhase; persist and restore state deliberately. - Background tasks are opportunistic and time-boxed; never assume execution.
- Widgets, Live Activities, App Intents, and Shortcuts each have their own process and data sharing (App Group) — design the shared store once.
- Permissions requested in context with an explanation, not en masse at launch.
Decision 6 — Quality bar
- SwiftUI previews for every screen with fixture data; no preview that runs networking.
- XCTest for domain and view models; UI tests for the money path only.
- Instruments for launch, hitching, and memory before release.
- Localisation from day one: string catalogs, no concatenation, RTL checks.
Failure modes at scale
- View model recreated on every body evaluation, refetching data in a loop.
- Networking inside
body, causing cascading re-renders. - Two
NavigationStacks in one hierarchy; back gestures break silently. Task { }inonAppearwithout cancellation, duplicating requests on scroll.- State distributed across five
@Stateproperties in three views.
Verification receipts
- State ownership map: which type owns which screen's state.
- Concurrency audit: no un-cancelled tasks,
@MainActoron UI models. - Navigation paths typed and deep links tested.
- Preview and test coverage for each screen's states (loading, empty, error).
- Launch and memory trace on the oldest supported device.
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.