watchos-code-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesewatchOS Code Review
watchOS代码审查
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 |
| 问题类型 | 参考链接 |
|---|---|
| 应用生命周期、场景、后台模式、扩展运行时 | references/lifecycle.md |
| ClockKit、WidgetKit、时间线提供器、智能堆栈 | references/complications.md |
| WCSession、消息传递、文件传输、可达性 | references/connectivity.md |
| 内存限制、后台刷新、电池优化 | references/performance.md |
Review Checklist
审查清单
- SwiftUI App protocol used with for lifecycle events
@WKApplicationDelegateAdaptor - read from root view (not sheets/modals where it's always
scenePhase).active - started only while app is active (not from background)
WKExtendedRuntimeSession - Workout sessions recovered in (not just delegate)
applicationDidFinishLaunching - Background tasks scheduled at least 5 minutes apart; next scheduled before completing current
- (not
URLSessionDownloadTask) used for background network requestsDataTask - WidgetKit used instead of ClockKit for watchOS 9+ complications
- Timeline includes future entries (not just current state); gaps avoided
- implemented for Smart Stack prioritization
TimelineEntryRelevance - WCSession delegate set before ; singleton pattern used
activate() - checked before
isReachable;sendMessagefor critical datatransferUserInfo - Received files moved synchronously before delegate callback returns
- 使用带有的SwiftUI App协议处理生命周期事件
@WKApplicationDelegateAdaptor - 从根视图读取(而非始终为
scenePhase的弹窗/模态视图).active - 仅在应用处于活跃状态时启动(而非从后台启动)
WKExtendedRuntimeSession - 在中恢复锻炼会话(而非仅通过委托)
applicationDidFinishLaunching - 后台任务调度间隔至少5分钟;在完成当前任务前调度下一个任务
- 后台网络请求使用(而非
URLSessionDownloadTask)DataTask - 对于watchOS 9+的复杂功能,使用WidgetKit而非ClockKit
- 时间线包含未来条目(而非仅当前状态);避免出现间隔
- 实现以支持智能堆栈优先级排序
TimelineEntryRelevance - 在调用前设置WCSession委托;使用单例模式
activate() - 调用前检查
sendMessage;对关键数据使用isReachabletransferUserInfo - 在委托回调返回前同步移动接收的文件
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
- 审查应用生命周期、后台模式或扩展会话时 -> lifecycle.md
- 审查复杂功能、小组件或时间线提供器时 -> complications.md
- 审查WCSession、iPhone-Apple Watch通信时 -> connectivity.md
- 审查内存、电池或性能问题时 -> performance.md
Review Questions
审查问题
- Is the app using modern SwiftUI lifecycle with delegate adaptor?
- Are background tasks completing properly (calling )?
setTaskCompletedWithSnapshot - Is UI update frequency reduced when is true?
isLuminanceReduced - Are WatchConnectivity delegate callbacks dispatching to main thread?
- Is nested within another
TabView? (Memory leak on watchOS)TabView
- 应用是否使用带有委托适配器的现代SwiftUI生命周期?
- 后台任务是否正确完成(调用)?
setTaskCompletedWithSnapshot - 当为true时,是否降低了UI更新频率?
isLuminanceReduced - WatchConnectivity委托回调是否调度到主线程?
- 是否在另一个中嵌套了
TabView?(watchOS上会导致内存泄漏)TabView