← 返回
开发者工具 中文

SwiftUI macOS

Expert SwiftUI guidance for macOS apps — covers writing and reviewing code with runtime-level understanding of observation, concurrency, performance, and pla...
为 macOS 应用提供专业的 SwiftUI 指导,覆盖编写与审查代码,具备运行时层面的观察、并发、性能和平台等理解。
kageroumado
开发者工具 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 537
下载
💾 16
安装
1
版本
#appkit#apple#concurrency#latest#macos#observation#swift#swiftui

概述

Guide SwiftUI development for macOS apps. Whether writing new code or reviewing existing code, apply deep understanding of SwiftUI's runtime behavior — how the observation registrar dispatches, how the attribute graph diffs view trees, how actor isolation interacts with view lifecycles.

How to Use

Writing code: Load relevant references before implementation. The patterns here prevent bugs that are expensive to find later — observation cascades, identity thrashing, concurrency overhead. When making architecture decisions (state ownership, view decomposition, AppKit bridging), consult the relevant reference for tradeoffs.

Reviewing code: Check each reference area systematically. Focus on genuine problems — observation inefficiencies, deprecated API, accessibility gaps, concurrency anti-patterns. Don't flag obvious issues or invent problems.

Partial scope: Load only what the task needs. Not every change requires all eight references.

References

ReferenceLoad when
------
references/observation.md@Observable, @State, ForEach, data-driven views, Observations {} streams
references/concurrency.mdTask, async/await, actors, DispatchQueue, AsyncStream, scheduling decisions
references/performance.mdView composition, animations, gestures, large collections, Canvas, TimelineView
references/views.mdView decomposition, navigation, .task(id:), preference keys, custom Layout
references/data.mdState architecture, SwiftData, environment injection, bindings, persistence
references/platform.mdNSViewRepresentable, NSHostingView, multi-window, AppKit bridging, window chrome
references/api.mdAPI choice, deprecated patterns, modern Swift/SwiftUI idioms
references/accessibility.mdVoiceOver, keyboard navigation, Dynamic Type, Reduce Motion

Principles

  • Target macOS 26+, Swift 6.2 with strict concurrency and @MainActor default isolation.
  • Check whether the project enables NonisolatedNonsendingByDefault (SE-0461) — this changes where nonisolated async functions execute. See references/concurrency.md.
  • Prefer SwiftUI-native solutions. Use AppKit (NSViewRepresentable, NSHostingView, NSWindow) only when SwiftUI has no equivalent.
  • Understand the mechanism. When suggesting a pattern, know why it works — what the observation registrar does, what the attribute graph diffing costs, what _modify vs set means for notification. Rules without understanding produce cargo-culted code.
  • Do not introduce third-party frameworks without asking. Apple's open-source Swift packages (swift-collections, swift-algorithms, swift-async-algorithms) are exceptions — prefer them over reimplementing non-trivial data structures or algorithms. See references/api.md.

Examples

User: "Review observation patterns in these sidebar views"

→ Load references/observation.md. Check each file for: state capture in ForEach, non-Equatable types on observed properties, missing @ObservationIgnored on caches, _modify vs set notification waste.

User: "I need to embed an NSCollectionView in SwiftUI"

→ Load references/platform.md. Apply NSViewRepresentable lifecycle, Equatable conformance for update gating, Coordinator for delegates.

User: "This view is re-rendering too much, help me debug it"

→ Load references/performance.md and references/observation.md. Check view identity (structural vs explicit), observation scope (are unrelated properties tracked in the same body?), @State vs @Observable for gesture-driven values.

Review Output

Organize findings by file. For each issue:

  1. File and relevant line(s).
  2. The pattern being violated and why it matters at the runtime level.
  3. Brief before/after code fix.

Skip clean files. End with a prioritized summary of the most impactful changes.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 02:09 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,918
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,476
developer-tools

Agent Browser

matrixy
专为AI智能体优化的无头浏览器自动化CLI,支持无障碍树快照和基于引用的元素选择。
★ 427 📥 118,365