迅速

工程开发 社区

技能解读

当前原文的自动摘译,尚未人工审校。

SwiftUI 视图组合

将视图分解为小的、单一职责的组件;将可重用的片段提取到 View 结构中 使用 @ViewBuilder 作为条件和分组内容;更喜欢组合而不是深度嵌套 一致地应用修饰符 - 按逻辑顺序链接它们:布局 -> 外观 -> 可访问性 使用 ViewModifier 协议来实现跨视图共享的可重用修饰符组 保持视图主体不受业务逻辑的影响;将计算移至 ViewModel 或在模型上使用计算属性

快速并发

使用async/await作为主要并发模型;避免在新代码中使用完成处理程序采用Actor进行共享可变状态隔离:actor DataStore { ... }在生成动态子任务时使用TaskGroup实现结构化并发在SwiftUI中应用.task修饰符以实现消失时取消的视图范围异步工作使用Sendable一致性来保证跨并发边界的线程安全值类型

斯威夫特数据

使用@Model宏定义模型;使用 @Relationship 作为引用,使用 @Attribute 作为约束 使用 ModelContainer 配置存储:内存中用于预览,持久用于生产 在 SwiftUI 视图中使用 @Query 进行查询;应用#Predicate进行类型安全的过滤和排序保持模型类型简单——为表示逻辑派生计算属性而不是存储派生数据直接在ViewModel中使用ModelContext进行批量插入、删除和后台保存

UIKit互操作

使用 UIViewControllerRepresentable 和 UIViewRepresentable 以 SwiftUI 委托模式包装 UIKit 组件:在嵌套在可表示对象内的协调器类中实现委托协议 使用 UIHostingController 在 UIKit 导航流中嵌入 SwiftUI 视图 在回退到 UIKit 之前优先选择 SwiftUI 原生解决方案;仅当不存在 SwiftUI 等效项时才进行互操作

VisionOS空间计算

使用 RealityView 实现 3D 内容,使用 ImmersiveSpace 实现全房间体验 将 Volume 应用于有界 3D 窗口,将 Window 应用于传统 2D 风格面板 通过 HandTrackingProvider 使用 ARKit 骨架跟踪和手部跟踪进行空间输入 舒适设计:将内容保持在舒适的距离,避免快速深度变化,提供休息状态 在设备测试前具有不同房间布局的visionOS模拟器

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
工程开发
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@tomevault-io · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
Windows
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# 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
- Use `UIHostingController` to 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 `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
- 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 `PreviewProvider` or `#Preview` macros 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

---
> Source: [calcosmic/Aether](https://github.com/calcosmic/Aether) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-23 -->

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。