watchOS Code Review
Quick Reference
| Issue Type | Reference |
|---|
| App lifecycle, scenes, background modes, extended runtime | references/lifecycle.md |
| ClockKit, WidgetKit, timeline providers, Smart Stack |
references/complications.md |
| WCSession, message passing, file transfer, reachability |
references/connectivity.md |
| Memory limits, background refresh, battery optimization |
references/performance.md |
Review Checklist
- - [ ] SwiftUI App protocol used with
@WKApplicationDelegateAdaptor for lifecycle events - [ ]
scenePhase read from root view (not sheets/modals where it's always .active) - [ ]
WKExtendedRuntimeSession started only while app is active (not from background) - [ ] Workout sessions recovered in
applicationDidFinishLaunching (not just delegate) - [ ] Background tasks scheduled at least 5 minutes apart; next scheduled before completing current
- [ ]
URLSessionDownloadTask (not DataTask) used for background network requests - [ ] WidgetKit used instead of ClockKit for watchOS 9+ complications
- [ ] Timeline includes future entries (not just current state); gaps avoided
- [ ]
TimelineEntryRelevance implemented for Smart Stack prioritization - [ ] WCSession delegate set before
activate(); singleton pattern used - [ ]
isReachable checked before sendMessage; transferUserInfo for critical data - [ ] Received files moved synchronously before delegate callback returns
When to Load References
- - Reviewing app lifecycle, background modes, or extended sessions -> lifecycle.md
- Reviewing complications, widgets, or timeline providers -> complications.md
- Reviewing WCSession, iPhone-Watch communication -> connectivity.md
- Reviewing memory, battery, or performance issues -> performance.md
Review Questions
- 1. Is the app using modern SwiftUI lifecycle with delegate adaptor?
- Are background tasks completing properly (calling
setTaskCompletedWithSnapshot)? - Is UI update frequency reduced when
isLuminanceReduced is true? - Are WatchConnectivity delegate callbacks dispatching to main thread?
- Is
TabView nested within another TabView? (Memory leak on watchOS)
watchOS 代码审查
快速参考
references/complications.md |
| WCSession、消息传递、文件传输、可达性 |
references/connectivity.md |
| 内存限制、后台刷新、电池优化 |
references/performance.md |
审查清单
- - [ ] 使用带有 @WKApplicationDelegateAdaptor 的 SwiftUI App 协议处理生命周期事件
- [ ] 从根视图(而非始终为 .active 的 sheet/模态视图)读取 scenePhase
- [ ] 仅在应用活跃时(而非后台)启动 WKExtendedRuntimeSession
- [ ] 在 applicationDidFinishLaunching(而非仅委托)中恢复锻炼会话
- [ ] 后台任务至少间隔5分钟调度;在当前任务完成前调度下一个任务
- [ ] 后台网络请求使用 URLSessionDownloadTask(而非 DataTask)
- [ ] watchOS 9+ 的复杂功能使用 WidgetKit 而非 ClockKit
- [ ] 时间线包含未来条目(而非仅当前状态);避免时间间隙
- [ ] 实现 TimelineEntryRelevance 以优化智能叠放优先级
- [ ] 在 activate() 之前设置 WCSession 委托;使用单例模式
- [ ] 在 sendMessage 前检查 isReachable;关键数据使用 transferUserInfo
- [ ] 在委托回调返回前同步移动接收到的文件
何时加载参考文档
- - 审查应用生命周期、后台模式或扩展会话 -> lifecycle.md
- 审查复杂功能、小组件或时间线提供程序 -> complications.md
- 审查 WCSession、iPhone-手表通信 -> connectivity.md
- 审查内存、电池或性能问题 -> performance.md
审查问题
- 1. 应用是否使用带有委托适配器的现代 SwiftUI 生命周期?
- 后台任务是否正确完成(调用 setTaskCompletedWithSnapshot)?
- 当 isLuminanceReduced 为 true 时,是否减少了 UI 更新频率?
- WatchConnectivity 委托回调是否分发到主线程?
- TabView 是否嵌套在另一个 TabView 中?(watchOS 上的内存泄漏)