WidgetKit Code Review
Quick Reference
| Issue Type | Reference |
|---|
| TimelineProvider, entries, reload policies | references/timeline.md |
| Widget families, containerBackground, deep linking |
references/views.md |
| AppIntentConfiguration, EntityQuery, @Parameter |
references/intents.md |
| Refresh budget, memory limits, caching |
references/performance.md |
Review Checklist
- - [ ]
placeholder(in:) returns immediately without async work - [ ] Timeline entries spaced at least 5 minutes apart
- [ ]
getSnapshot checks context.isPreview for gallery previews - [ ]
containerBackground(for:) used for iOS 17+ compatibility - [ ]
widgetURL used for systemSmall (not Link) - [ ] No Button views (use Link or widgetURL)
- [ ] No AsyncImage or UIViewRepresentable in widget views
- [ ] Images downsampled to widget display size (~30MB limit)
- [ ] App Groups configured for data sharing between app and widget
- [ ] EntityQuery implements
defaultResult() for non-optional parameters - [ ] New intent parameters handle nil for existing widgets after updates
- [ ]
reloadTimelines called strategically (not on every data change)
When to Load References
- - TimelineProvider implementation or refresh issues -> timeline.md
- Widget sizes, Lock Screen, containerBackground -> views.md
- Configurable widgets, AppIntent migration -> intents.md
- Memory issues, caching, budget management -> performance.md
Review Questions
- 1. Does the widget provide fallback entries for when system delays refresh?
- Are Lock Screen families (accessoryCircular/Rectangular/Inline) handled appropriately?
- Would migrating from IntentConfiguration break existing user widgets?
- Is timeline populated with future entries or does it rely on frequent refreshes?
- Is data cached via App Groups for widget access?
WidgetKit 代码审查
快速参考
references/views.md |
| AppIntentConfiguration、EntityQuery、@Parameter |
references/intents.md |
| 刷新预算、内存限制、缓存 |
references/performance.md |
审查清单
- - [ ] placeholder(in:) 立即返回,不执行异步操作
- [ ] 时间线条目间隔至少5分钟
- [ ] getSnapshot 检查 context.isPreview 以处理画廊预览
- [ ] 使用 containerBackground(for:) 确保 iOS 17+ 兼容性
- [ ] 对 systemSmall 使用 widgetURL(而非 Link)
- [ ] 不使用 Button 视图(改用 Link 或 widgetURL)
- [ ] 小组件视图中不使用 AsyncImage 或 UIViewRepresentable
- [ ] 图片降采样至小组件显示尺寸(约30MB限制)
- [ ] 配置 App Groups 以实现应用与小组件间的数据共享
- [ ] EntityQuery 为可选参数实现 defaultResult()
- [ ] 新意图参数处理更新后现有小组件的 nil 情况
- [ ] 策略性调用 reloadTimelines(而非每次数据变更都调用)
何时加载参考文档
- - TimelineProvider 实现或刷新问题 -> timeline.md
- 小组件尺寸、锁屏、containerBackground -> views.md
- 可配置小组件、AppIntent 迁移 -> intents.md
- 内存问题、缓存、预算管理 -> performance.md
审查问题
- 1. 当系统延迟刷新时,小组件是否提供备用条目?
- 锁屏家族(accessoryCircular/Rectangular/Inline)是否得到适当处理?
- 从 IntentConfiguration 迁移是否会破坏现有用户小组件?
- 时间线是否填充了未来条目,还是依赖频繁刷新?
- 是否通过 App Groups 缓存数据以供小组件访问?