AgentSkillsCN

swiftui-architecture

在构建 SwiftUI 视图、管理状态、配置共享服务或进行架构决策时——请优先采用 SwiftUI,而非 UIKit 或传统设计模式;通过 @State、@Binding、@Observable 以及 @Environment 等机制,实现纯 SwiftUI 的数据流,无需 ViewModel。

SKILL.md
--- frontmatter
name: swiftui-architecture
description: WHEN building SwiftUI views, managing state, setting up shared services, or making architectural decisions; NOT for UIKit or legacy patterns; provides pure SwiftUI data flow without ViewModels using @State, @Binding, @Observable, and @Environment.

Modern SwiftUI Architecture

Concise entry point for pure SwiftUI architecture without ViewModels. Use the references for patterns, examples, and edge cases.

Start Here

  • State management: references/state-management.md
  • Observable services: references/observable-patterns.md
  • Async work: references/async-patterns.md
  • Navigation: references/navigation-patterns.md
  • UI components: references/lists.md, references/scrollview.md, references/forms.md, references/grids.md, references/sheets.md, references/tabs.md
  • Anti-patterns: references/anti-patterns.md

Typical Flow

  1. Choose state ownership and data flow (references/state-management.md).
  2. Model shared logic as @Observable services (references/observable-patterns.md).
  3. Wire navigation with AppRouter (references/navigation-patterns.md).
  4. Build UI using component guides.
  5. Audit against anti-patterns (references/anti-patterns.md).