Swift 技能创建
- 作者仓库星标 0
- 作者仓库 skills-registry
Swift/SwiftUI Best Practices
SwiftUI View Composition
- Break views into small, single-responsibility components; extract reusable pieces into
Viewstructs - Use
@ViewBuilderfor conditional and grouped content; prefer composition over deep nesting - Apply modifiers consistently -- chain them in a logical order: layout -> appearance -> accessibility
- Use
ViewModifierprotocol for reusable modifier groups shared across views - Keep view bodies free of business logic; move computation to ViewModels or use computed properties on the model
Swift Concurrency
- Use
async/awaitas the primary concurrency model; avoid completion handlers in new code - Adopt
Actorfor shared mutable state isolation:actor DataStore { ... } - Use
TaskGroupfor structured concurrency when spawning dynamic child tasks - Apply
.taskmodifier in SwiftUI for view-scoped async work that cancels on disappear - Use
Sendableconformance to guarantee thread-safe value types across concurrency boundaries
SwiftData
- Define models with
@Modelmacro; use@Relationshipfor references and@Attributefor constraints - Use
ModelContainerto configure storage: in-memory for previews, persistent for production - Query with
@Queryin SwiftUI views; apply#Predicatefor type-safe filtering and sorting - Keep model types simple -- derive computed properties for presentation logic rather than storing derived data
- Use
ModelContextdirectly in ViewModels for batch inserts, deletes, and background saves
UIKit Interop
- Use
UIViewControllerRepresentableandUIViewRepresentableto wrap UIKit components in SwiftUI - Delegate pattern: implement the delegate protocol in a coordinator class nested inside the representable
- Use
UIHostingControllerto embed SwiftUI views within UIKit navigation flows - Prefer SwiftUI-native solutions before falling back to UIKit; only interop when no SwiftUI equivalent exists
visionOS Spatial Computing
- Use
RealityViewfor 3D content andImmersiveSpacefor full-room experiences - Apply
Volumefor bounded 3D windows andWindowfor traditional 2D-style panels - Use ARKit skeleton tracking and hand tracking via
HandTrackingProviderfor spatial input - Design for comfort: keep content at comfortable distances, avoid rapid depth changes, provide rest states
- Test spatial UI in the visionOS simulator with varied room layouts before device testing
Testing and Quality
- Use Swift Testing framework (
@Test,@Suite) for new test targets alongside XCTest for compatibility - Write
PreviewProvideror#Previewmacros for every SwiftUI view to enable live canvas development - Apply SwiftLint or SwiftFormat consistently; enforce rules in CI with
swift-format - Use Instruments for profiling: Time Profiler, Allocations, and Leaks for performance validation
<!-- tomevault:4.0:skill_md:2026-05-23 -->Source: calcosmic/Aether — distributed by TomeVault.
- 流狐分类
- 工程开发
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- Windows
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Break views into small, single-responsibility components; extract reusable pieces into View structs Use @ViewBuilder for conditional and grouped content; prefer composition over deep nesting Apply modifiers consistently -- chain them in a logical order: layout…
Use async/await as the primary concurrency model; avoid completion handlers in new code Adopt Actor for shared mutable state isolation: actor DataStore { ... } Use TaskGroup for structured concurrency when spawning dynamic child tasks
Define models with @Model macro; use @Relationship for references and @Attribute for constraints Use ModelContainer to configure storage: in-memory for previews, persistent for production Query with @Query in SwiftUI views; apply Predicate for type-safe…
Use UIViewControllerRepresentable and UIViewRepresentable to wrap UIKit components in SwiftUI Delegate pattern: implement the delegate protocol in a coordinator class nested inside the representable Use UIHostingController to embed SwiftUI views within UIKit…
Use RealityView for 3D content and ImmersiveSpace for full-room experiences Apply Volume for bounded 3D windows and Window for traditional 2D-style panels Use ARKit skeleton tracking and hand tracking via HandTrackingProvider for spatial input
Use Swift Testing framework (@Test, @Suite) for new test targets alongside XCTest for compatibility Write PreviewProvider or Preview macros for every SwiftUI view to enable live canvas development Apply SwiftLint or SwiftFormat consistently; enforce rules in…
# Swift/SwiftUI Best Practices
## SwiftUI View Composition
- Break views into small, single-responsibility components; extract reusable pieces into `View` structs
- Use `@ViewBuilder` for conditional and grouped content; prefer composition over deep nesting
- Apply modifiers consistently -- chain them in a logical order: layout -> appearance -> accessibility
- Use `ViewModifier` protocol for reusable modifier groups shared across views
- Keep view bodies free of business logic; move computation to ViewModels or use computed properties on the model
## Swift Concurrency
- Use `async/await` as the primary concurrency model; avoid completion handlers in new code
- Adopt `Actor` for shared mutable state isolation: `actor DataStore { ... }`
- Use `TaskGroup` for structured concurrency when spawning dynamic child tasks
- Apply `.task` modifier in SwiftUI for view-scoped async work that cancels on disappear
- Use `Sendable` conformance to guarantee thread-safe value types across concurrency boundaries
## SwiftData
- Define models with `@Model` macro; use `@Relationship` for references and `@Attribute` for constraints
- Use `ModelContainer` to configure storage: in-memory for previews, persistent for production
- Query with `@Query` in SwiftUI views; apply `#Predicate` for type-safe filtering and sorting
- Keep model types simple -- derive computed properties for presentation logic rather than storing derived data
- Use `ModelContext` directly in ViewModels for batch inserts, deletes, and background saves
## UIKit Interop
- Use `UIViewControllerRepresentable` and `UIViewRepresentable` to wrap UIKit components in SwiftUI
- Delegate pattern: implement the delegate protocol in a coordinator class nested inside the representable
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> SwiftUI View Composition → Swift Concurrency → SwiftData → UIKit Interop → visionOS Spatial Computing → Testing and Quality
要点 -> --- > Source: [calcosmic/Aether](https://github.com/calcosmic/Aether) — distributed by [TomeVault](https://tomevault.io).
文件/命令 -> View · @ViewBuilder · ViewModifier · async/await · Actor · actor DataStore { ... } · TaskGroup · .task
内容 SHA-256 -> a8bad948b29e
原文结构
适用与边界
原文中的明确线索
View、@ViewBuilder、ViewModifier、async/await、Actor、actor DataStore { ... }、TaskGroup、.task