CloudKit Code Review
Quick Reference
references/records.md |
| CKSubscription, push notifications, silent sync |
references/subscriptions.md |
| CKShare, participants, permissions, acceptance |
references/sharing.md |
Review Checklist
- - [ ] Account status checked before private/shared database operations
- [ ] Custom zones used (not default zone) for production data
- [ ] All CloudKit errors handled with
retryAfterSeconds respected - [ ]
serverRecordChanged conflicts handled with proper merge logic - [ ]
CKErrorPartialFailure parsed for individual record errors - [ ] Batch operations used (
CKModifyRecordsOperation) not individual saves - [ ] Large binary data stored as
CKAsset (records have 1MB limit) - [ ] Record keys type-safe (enums) not string literals
- [ ] UI updates dispatched to main thread from callbacks
- [ ]
CKAccountChangedNotification observed for account switches - [ ] Subscriptions have unique IDs to prevent duplicates
- [ ] CKShare uses custom zone (sharing requires custom zones)
When to Load References
- - Reviewing container/database setup or zones -> container-setup.md
- Reviewing record CRUD or relationships -> records.md
- Reviewing push notifications or sync triggers -> subscriptions.md
- Reviewing sharing or collaboration features -> sharing.md
Output Format
Report issues using: INLINECODE6
Examples:
- - INLINECODE7
- INLINECODE8
- INLINECODE9
Review Questions
- 1. What happens when the user is signed out of iCloud?
- Does error handling respect rate limiting (
retryAfterSeconds)? - Are conflicts resolved or does data get overwritten silently?
- Is the schema deployed to production before App Store release?
- Are shared records in custom zones (required for CKShare)?
CloudKit 代码审查
快速参考
references/records.md |
| CKSubscription、推送通知、静默同步 |
references/subscriptions.md |
| CKShare、参与者、权限、接受 |
references/sharing.md |
审查清单
- - [ ] 在私有/共享数据库操作前检查账户状态
- [ ] 生产数据使用自定义区域(而非默认区域)
- [ ] 所有 CloudKit 错误均已处理,并遵循 retryAfterSeconds
- [ ] serverRecordChanged 冲突已通过适当的合并逻辑处理
- [ ] CKErrorPartialFailure 已解析以获取单个记录错误
- [ ] 使用批量操作(CKModifyRecordsOperation)而非单个保存
- [ ] 大型二进制数据存储为 CKAsset(记录有 1MB 限制)
- [ ] 记录键类型安全(使用枚举)而非字符串字面量
- [ ] UI 更新从回调分发到主线程
- [ ] 监听 CKAccountChangedNotification 以处理账户切换
- [ ] 订阅具有唯一 ID 以防止重复
- [ ] CKShare 使用自定义区域(共享需要自定义区域)
何时加载参考文档
- - 审查容器/数据库设置或区域 -> container-setup.md
- 审查记录 CRUD 或关系 -> records.md
- 审查推送通知或同步触发器 -> subscriptions.md
- 审查共享或协作功能 -> sharing.md
输出格式
使用以下格式报告问题:[文件:行号] 问题标题
示例:
- - [AppDelegate.swift:24] CKContainer 不在自定义区域中
- [SyncManager.swift:156] 未处理的 CKErrorPartialFailure
- [DataStore.swift:89] 缺少 retryAfterSeconds 退避
审查问题
- 1. 当用户退出 iCloud 时会发生什么?
- 错误处理是否遵循速率限制(retryAfterSeconds)?
- 冲突是否得到解决,还是数据会被静默覆盖?
- 在 App Store 发布前,模式是否已部署到生产环境?
- 共享记录是否在自定义区域中(CKShare 必需)?