guide-swiftdata
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGuide Skill — This is an expert workflow/pattern guide, not API reference documentation. Originally from twostraws/SwiftData-Agent-Skill by Paul Hudson. MIT License.
指南技能 — 这是一份专家级工作流/模式指南,而非API参考文档。 最初由Paul Hudson发布于twostraws/SwiftData-Agent-Skill,采用MIT许可证。
SwiftData Patterns
SwiftData 模式
Write and review SwiftData code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems — do not nitpick or invent issues.
编写和审查SwiftData代码时,确保代码正确、使用现代API并遵循项目约定。仅报告真实存在的问题——不要吹毛求疵或编造问题。
Core Instructions
核心指导原则
- Target Swift 6.2 or later, using modern Swift concurrency.
- Prefer SwiftData across the board. Do not suggest Core Data unless the feature cannot be solved with SwiftData.
- Do not introduce third-party frameworks without asking first.
- 目标为Swift 6.2或更高版本,使用现代Swift并发机制。
- 全面优先使用SwiftData。除非某个功能无法通过SwiftData实现,否则不要建议使用Core Data。
- 未经询问,不要引入第三方框架。
Review Process
审查流程
- Check for core SwiftData issues using .
references/core-rules.md - Check that predicates are safe and supported using .
references/predicates.md - If the project uses CloudKit, check for CloudKit-specific constraints using .
references/cloudkit.md - If the project targets iOS 18+, check for indexing opportunities using .
references/indexing.md - If the project targets iOS 26+, check for class inheritance patterns using .
references/class-inheritance.md
If doing partial work, load only the relevant reference files.
- 使用检查核心SwiftData问题。
references/core-rules.md - 使用检查谓词是否安全且受支持。
references/predicates.md - 如果项目使用CloudKit,使用检查CloudKit特定约束。
references/cloudkit.md - 如果项目目标为iOS 18+,使用检查索引优化机会。
references/indexing.md - 如果项目目标为iOS 26+,使用检查类继承模式。
references/class-inheritance.md
如果仅处理部分工作,只需加载相关的参考文件。
References
参考资料
| Topic | Reference |
|---|---|
Autosave, relationships, delete rules, | |
| Supported predicates, dangerous patterns that crash at runtime, unsupported methods | |
CloudKit constraints: no | |
| Database indexing (iOS 18+), single and compound property indexes | |
Model subclassing (iOS 26+), | |
| 主题 | 参考文件 |
|---|---|
自动保存、关联关系、删除规则、 | |
| 受支持的谓词、运行时会崩溃的危险模式、不受支持的方法 | |
CloudKit约束:不支持 | |
| 数据库索引(iOS 18+)、单一属性索引与复合属性索引 | |
模型子类化(iOS 26+)、 | |