@mmerterden/multi-agent-pipeline 20.7.0 → 20.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +0 -10
  3. package/docs/facts.json +1 -1
  4. package/manifest.json +266 -267
  5. package/package.json +2 -2
  6. package/pipeline/scripts/_notices.mjs +1 -1
  7. package/pipeline/skills/.skill-manifest.json +68 -68
  8. package/pipeline/skills/shared/README.md +70 -70
  9. package/pipeline/skills/shared/external/alarmkit/SKILL.md +373 -381
  10. package/pipeline/skills/shared/external/alarmkit/evals/evals.json +23 -18
  11. package/pipeline/skills/shared/external/alarmkit/references/alarmkit-patterns.md +328 -378
  12. package/pipeline/skills/shared/external/app-clips/SKILL.md +260 -160
  13. package/pipeline/skills/shared/external/app-clips/evals/evals.json +27 -27
  14. package/pipeline/skills/shared/external/app-clips/references/data-handoff-notifications-location.md +150 -83
  15. package/pipeline/skills/shared/external/app-clips/references/routing-and-experiences.md +135 -83
  16. package/pipeline/skills/shared/external/app-clips/references/size-capabilities-and-promotion.md +143 -85
  17. package/pipeline/skills/shared/external/app-intents/SKILL.md +302 -304
  18. package/pipeline/skills/shared/external/app-intents/evals/evals.json +21 -21
  19. package/pipeline/skills/shared/external/app-intents/references/appintents-advanced.md +594 -894
  20. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +339 -277
  21. package/pipeline/skills/shared/external/app-store-optimization/evals/evals.json +27 -23
  22. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +105 -122
  23. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +143 -166
  24. package/pipeline/skills/shared/external/app-store-review/SKILL.md +307 -326
  25. package/pipeline/skills/shared/external/app-store-review/evals/evals.json +21 -21
  26. package/pipeline/skills/shared/external/app-store-review/references/privacy-manifest.md +105 -67
  27. package/pipeline/skills/shared/external/app-store-review/references/review-checklists.md +114 -101
  28. package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +333 -360
  29. package/pipeline/skills/shared/external/apple-on-device-ai/evals/evals.json +24 -27
  30. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-conversion.md +215 -322
  31. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-optimization.md +161 -256
  32. package/pipeline/skills/shared/external/apple-on-device-ai/references/foundation-models.md +277 -387
  33. package/pipeline/skills/shared/external/apple-on-device-ai/references/mlx-swift.md +196 -210
  34. package/pipeline/skills/shared/external/authentication/SKILL.md +265 -381
  35. package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
  36. package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +133 -178
  37. package/pipeline/skills/shared/external/authentication/references/passkeys.md +111 -147
  38. package/pipeline/skills/shared/external/avkit/SKILL.md +267 -364
  39. package/pipeline/skills/shared/external/avkit/evals/evals.json +26 -26
  40. package/pipeline/skills/shared/external/avkit/references/avkit-patterns.md +375 -493
  41. package/pipeline/skills/shared/external/background-processing/SKILL.md +270 -382
  42. package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
  43. package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +169 -317
  44. package/pipeline/skills/shared/external/callkit-voip/SKILL.md +290 -371
  45. package/pipeline/skills/shared/external/callkit-voip/evals/evals.json +24 -24
  46. package/pipeline/skills/shared/external/callkit-voip/references/callkit-patterns.md +175 -343
  47. package/pipeline/skills/shared/external/cloudkit-sync/SKILL.md +292 -381
  48. package/pipeline/skills/shared/external/cloudkit-sync/evals/evals.json +33 -30
  49. package/pipeline/skills/shared/external/cloudkit-sync/references/cloudkit-patterns.md +227 -355
  50. package/pipeline/skills/shared/external/contacts-framework/SKILL.md +197 -346
  51. package/pipeline/skills/shared/external/contacts-framework/evals/evals.json +19 -21
  52. package/pipeline/skills/shared/external/contacts-framework/references/contacts-patterns.md +169 -308
  53. package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +226 -376
  54. package/pipeline/skills/shared/external/core-bluetooth/evals/evals.json +25 -22
  55. package/pipeline/skills/shared/external/core-bluetooth/references/ble-patterns.md +257 -337
  56. package/pipeline/skills/shared/external/core-data/SKILL.md +292 -368
  57. package/pipeline/skills/shared/external/core-data/evals/evals.json +30 -27
  58. package/pipeline/skills/shared/external/core-motion/SKILL.md +235 -324
  59. package/pipeline/skills/shared/external/core-motion/evals/evals.json +31 -27
  60. package/pipeline/skills/shared/external/core-motion/references/motion-patterns.md +210 -310
  61. package/pipeline/skills/shared/external/core-nfc/SKILL.md +292 -366
  62. package/pipeline/skills/shared/external/core-nfc/evals/evals.json +22 -24
  63. package/pipeline/skills/shared/external/core-nfc/references/nfc-patterns.md +233 -329
  64. package/pipeline/skills/shared/external/coreml/SKILL.md +323 -367
  65. package/pipeline/skills/shared/external/coreml/evals/evals.json +24 -21
  66. package/pipeline/skills/shared/external/coreml/references/coreml-swift-integration.md +562 -565
  67. package/pipeline/skills/shared/external/cryptokit/SKILL.md +253 -394
  68. package/pipeline/skills/shared/external/cryptokit/evals/evals.json +20 -18
  69. package/pipeline/skills/shared/external/cryptokit/references/cryptokit-patterns.md +299 -488
  70. package/pipeline/skills/shared/external/debugging-instruments/SKILL.md +270 -323
  71. package/pipeline/skills/shared/external/debugging-instruments/evals/evals.json +27 -30
  72. package/pipeline/skills/shared/external/debugging-instruments/references/instruments-guide.md +167 -315
  73. package/pipeline/skills/shared/external/debugging-instruments/references/lldb-patterns.md +140 -193
  74. package/pipeline/skills/shared/external/device-integrity/SKILL.md +230 -353
  75. package/pipeline/skills/shared/external/device-integrity/evals/evals.json +25 -21
  76. package/pipeline/skills/shared/external/device-integrity/references/device-integrity-patterns.md +159 -197
  77. package/pipeline/skills/shared/external/energykit/SKILL.md +225 -392
  78. package/pipeline/skills/shared/external/energykit/evals/evals.json +29 -28
  79. package/pipeline/skills/shared/external/energykit/references/energykit-patterns.md +174 -470
  80. package/pipeline/skills/shared/external/eventkit-calendar/SKILL.md +261 -383
  81. package/pipeline/skills/shared/external/eventkit-calendar/evals/evals.json +25 -22
  82. package/pipeline/skills/shared/external/eventkit-calendar/references/eventkit-patterns.md +165 -268
  83. package/pipeline/skills/shared/external/healthkit/SKILL.md +252 -303
  84. package/pipeline/skills/shared/external/healthkit/evals/evals.json +24 -23
  85. package/pipeline/skills/shared/external/healthkit/references/healthkit-patterns.md +369 -523
  86. package/pipeline/skills/shared/external/homekit-matter/SKILL.md +233 -348
  87. package/pipeline/skills/shared/external/homekit-matter/evals/evals.json +27 -22
  88. package/pipeline/skills/shared/external/homekit-matter/references/matter-commissioning.md +199 -305
  89. package/pipeline/skills/shared/external/ios-accessibility/SKILL.md +368 -340
  90. package/pipeline/skills/shared/external/ios-accessibility/evals/evals.json +28 -27
  91. package/pipeline/skills/shared/external/ios-accessibility/references/a11y-patterns.md +314 -260
  92. package/pipeline/skills/shared/external/ios-accessibility/references/media-accessibility.md +97 -67
  93. package/pipeline/skills/shared/external/ios-accessibility/references/nutrition-labels.md +165 -101
  94. package/pipeline/skills/shared/external/ios-localization/SKILL.md +258 -371
  95. package/pipeline/skills/shared/external/ios-localization/evals/evals.json +23 -23
  96. package/pipeline/skills/shared/external/ios-localization/references/formatstyle-locale.md +283 -491
  97. package/pipeline/skills/shared/external/ios-localization/references/string-catalogs.md +313 -440
  98. package/pipeline/skills/shared/external/ios-networking/SKILL.md +265 -341
  99. package/pipeline/skills/shared/external/ios-networking/evals/evals.json +24 -24
  100. package/pipeline/skills/shared/external/ios-networking/references/background-websocket.md +425 -652
  101. package/pipeline/skills/shared/external/ios-networking/references/file-storage-patterns.md +143 -285
  102. package/pipeline/skills/shared/external/ios-networking/references/lightweight-clients.md +93 -53
  103. package/pipeline/skills/shared/external/ios-networking/references/network-framework.md +231 -456
  104. package/pipeline/skills/shared/external/ios-networking/references/urlsession-patterns.md +517 -784
  105. package/pipeline/skills/shared/external/ios-simulator/SKILL.md +265 -393
  106. package/pipeline/skills/shared/external/ios-simulator/evals/evals.json +21 -21
  107. package/pipeline/skills/shared/external/ios-simulator/references/simctl-commands.md +177 -270
  108. package/pipeline/skills/shared/external/live-activities/SKILL.md +318 -360
  109. package/pipeline/skills/shared/external/live-activities/evals/evals.json +21 -21
  110. package/pipeline/skills/shared/external/live-activities/references/activitykit-patterns.md +478 -710
  111. package/pipeline/skills/shared/external/mapkit-location/SKILL.md +295 -267
  112. package/pipeline/skills/shared/external/mapkit-location/evals/evals.json +28 -24
  113. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-corelocation-patterns.md +378 -532
  114. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-patterns.md +397 -499
  115. package/pipeline/skills/shared/external/metrickit-diagnostics/SKILL.md +165 -348
  116. package/pipeline/skills/shared/external/metrickit-diagnostics/evals/evals.json +26 -23
  117. package/pipeline/skills/shared/external/metrickit-diagnostics/references/metrickit-patterns.md +123 -130
  118. package/pipeline/skills/shared/external/musickit-audio/SKILL.md +189 -315
  119. package/pipeline/skills/shared/external/musickit-audio/evals/evals.json +22 -21
  120. package/pipeline/skills/shared/external/musickit-audio/references/musickit-patterns.md +181 -270
  121. package/pipeline/skills/shared/external/natural-language/SKILL.md +188 -340
  122. package/pipeline/skills/shared/external/natural-language/evals/evals.json +21 -21
  123. package/pipeline/skills/shared/external/natural-language/references/translation-patterns.md +171 -225
  124. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +258 -392
  125. package/pipeline/skills/shared/external/passkit-wallet/evals/evals.json +30 -29
  126. package/pipeline/skills/shared/external/passkit-wallet/references/wallet-passes.md +164 -231
  127. package/pipeline/skills/shared/external/pdfkit/SKILL.md +312 -344
  128. package/pipeline/skills/shared/external/pdfkit/evals/evals.json +19 -19
  129. package/pipeline/skills/shared/external/pdfkit/references/pdfkit-patterns.md +413 -624
  130. package/pipeline/skills/shared/external/pencilkit-drawing/SKILL.md +242 -358
  131. package/pipeline/skills/shared/external/pencilkit-drawing/evals/evals.json +25 -21
  132. package/pipeline/skills/shared/external/pencilkit-drawing/references/pencilkit-patterns.md +161 -226
  133. package/pipeline/skills/shared/external/permissionkit/SKILL.md +282 -400
  134. package/pipeline/skills/shared/external/permissionkit/evals/evals.json +27 -30
  135. package/pipeline/skills/shared/external/permissionkit/references/permissionkit-patterns.md +237 -350
  136. package/pipeline/skills/shared/external/photos-camera-media/SKILL.md +276 -325
  137. package/pipeline/skills/shared/external/photos-camera-media/references/av-playback.md +299 -545
  138. package/pipeline/skills/shared/external/photos-camera-media/references/camera-capture.md +344 -588
  139. package/pipeline/skills/shared/external/photos-camera-media/references/image-loading-caching.md +316 -660
  140. package/pipeline/skills/shared/external/photos-camera-media/references/photokit-patterns.md +270 -416
  141. package/pipeline/skills/shared/external/push-notifications/SKILL.md +312 -340
  142. package/pipeline/skills/shared/external/push-notifications/evals/evals.json +27 -26
  143. package/pipeline/skills/shared/external/push-notifications/references/notification-patterns.md +328 -485
  144. package/pipeline/skills/shared/external/push-notifications/references/rich-notifications.md +327 -560
  145. package/pipeline/skills/shared/external/realitykit-ar/SKILL.md +218 -410
  146. package/pipeline/skills/shared/external/realitykit-ar/evals/evals.json +24 -27
  147. package/pipeline/skills/shared/external/realitykit-ar/references/realitykit-patterns.md +221 -348
  148. package/pipeline/skills/shared/external/shareplay-activities/SKILL.md +222 -393
  149. package/pipeline/skills/shared/external/shareplay-activities/evals/evals.json +23 -24
  150. package/pipeline/skills/shared/external/shareplay-activities/references/shareplay-patterns.md +280 -420
  151. package/pipeline/skills/shared/external/speech-recognition/SKILL.md +217 -421
  152. package/pipeline/skills/shared/external/speech-recognition/evals/evals.json +23 -26
  153. package/pipeline/skills/shared/external/speech-recognition/references/speechanalyzer-patterns.md +133 -125
  154. package/pipeline/skills/shared/external/storekit/SKILL.md +228 -204
  155. package/pipeline/skills/shared/external/storekit/evals/evals.json +27 -24
  156. package/pipeline/skills/shared/external/storekit/references/app-review-guidelines.md +98 -109
  157. package/pipeline/skills/shared/external/storekit/references/core-patterns.md +298 -242
  158. package/pipeline/skills/shared/external/storekit/references/storekit-advanced.md +356 -649
  159. package/pipeline/skills/shared/external/swift-api-design-guidelines/SKILL.md +274 -399
  160. package/pipeline/skills/shared/external/swift-api-design-guidelines/evals/evals.json +22 -24
  161. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/argument-labels-and-parameters.md +107 -108
  162. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/conventions-and-special-rules.md +93 -165
  163. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md +99 -137
  164. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/side-effects-and-mutating-pairs.md +77 -120
  165. package/pipeline/skills/shared/external/swift-architecture/SKILL.md +334 -350
  166. package/pipeline/skills/shared/external/swift-architecture/evals/evals.json +22 -22
  167. package/pipeline/skills/shared/external/swift-charts/SKILL.md +208 -394
  168. package/pipeline/skills/shared/external/swift-charts/evals/evals.json +27 -30
  169. package/pipeline/skills/shared/external/swift-charts/references/charts-patterns.md +351 -762
  170. package/pipeline/skills/shared/external/swift-codable/SKILL.md +339 -343
  171. package/pipeline/skills/shared/external/swift-codable/evals/evals.json +20 -20
  172. package/pipeline/skills/shared/external/swift-concurrency/SKILL.md +303 -351
  173. package/pipeline/skills/shared/external/swift-concurrency/evals/evals.json +27 -24
  174. package/pipeline/skills/shared/external/swift-concurrency/references/approachable-concurrency.md +65 -80
  175. package/pipeline/skills/shared/external/swift-concurrency/references/async-algorithms.md +48 -84
  176. package/pipeline/skills/shared/external/swift-concurrency/references/bridging-interop.md +134 -79
  177. package/pipeline/skills/shared/external/swift-concurrency/references/concurrency-patterns.md +145 -167
  178. package/pipeline/skills/shared/external/swift-concurrency/references/diagnostics.md +62 -50
  179. package/pipeline/skills/shared/external/swift-concurrency/references/swiftui-concurrency.md +92 -121
  180. package/pipeline/skills/shared/external/swift-concurrency/references/synchronization-primitives.md +177 -241
  181. package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +258 -234
  182. package/pipeline/skills/shared/external/swift-language/SKILL.md +342 -382
  183. package/pipeline/skills/shared/external/swift-language/evals/evals.json +24 -27
  184. package/pipeline/skills/shared/external/swift-language/references/swift-attributes-interop.md +79 -56
  185. package/pipeline/skills/shared/external/swift-language/references/swift-patterns-extended.md +297 -340
  186. package/pipeline/skills/shared/external/swift-security/SKILL.md +180 -161
  187. package/pipeline/skills/shared/external/swift-security/evals/evals.json +25 -25
  188. package/pipeline/skills/shared/external/swift-security/references/biometric-authentication.md +314 -469
  189. package/pipeline/skills/shared/external/swift-security/references/certificate-trust.md +408 -476
  190. package/pipeline/skills/shared/external/swift-security/references/common-anti-patterns.md +260 -530
  191. package/pipeline/skills/shared/external/swift-security/references/compliance-owasp-mapping.md +270 -477
  192. package/pipeline/skills/shared/external/swift-security/references/credential-storage-patterns.md +573 -571
  193. package/pipeline/skills/shared/external/swift-security/references/cryptokit-public-key.md +370 -441
  194. package/pipeline/skills/shared/external/swift-security/references/cryptokit-symmetric.md +332 -433
  195. package/pipeline/skills/shared/external/swift-security/references/keychain-access-control.md +346 -468
  196. package/pipeline/skills/shared/external/swift-security/references/keychain-fundamentals.md +352 -472
  197. package/pipeline/skills/shared/external/swift-security/references/keychain-item-classes.md +431 -432
  198. package/pipeline/skills/shared/external/swift-security/references/keychain-sharing.md +328 -425
  199. package/pipeline/skills/shared/external/swift-security/references/migration-legacy-stores.md +341 -579
  200. package/pipeline/skills/shared/external/swift-security/references/secure-enclave.md +396 -457
  201. package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
  202. package/pipeline/skills/shared/external/swift-testing/SKILL.md +188 -175
  203. package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
  204. package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +80 -84
  205. package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
  206. package/pipeline/skills/shared/external/swiftdata/SKILL.md +392 -256
  207. package/pipeline/skills/shared/external/swiftdata/evals/evals.json +24 -24
  208. package/pipeline/skills/shared/external/swiftdata/references/core-data-coexistence.md +206 -402
  209. package/pipeline/skills/shared/external/swiftdata/references/indexing.md +59 -52
  210. package/pipeline/skills/shared/external/swiftdata/references/predicate-pitfalls.md +57 -33
  211. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-advanced.md +354 -747
  212. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-queries.md +300 -508
  213. package/pipeline/skills/shared/external/swiftlint/SKILL.md +175 -226
  214. package/pipeline/skills/shared/external/swiftlint/references/adoption-and-configuration.md +141 -208
  215. package/pipeline/skills/shared/external/swiftlint/references/custom-rules-and-analyze.md +100 -109
  216. package/pipeline/skills/shared/external/swiftlint/references/plugins-run-scripts-and-integrations.md +159 -179
  217. package/pipeline/skills/shared/external/swiftlint/references/rule-reference.md +383 -18
  218. package/pipeline/skills/shared/external/swiftlint/references/rules-suppressions-and-baselines.md +143 -229
  219. package/pipeline/skills/shared/external/swiftui-animation/SKILL.md +283 -366
  220. package/pipeline/skills/shared/external/swiftui-animation/references/animation-advanced.md +396 -608
  221. package/pipeline/skills/shared/external/swiftui-animation/references/core-animation-bridge.md +336 -385
  222. package/pipeline/skills/shared/external/swiftui-gestures/SKILL.md +239 -349
  223. package/pipeline/skills/shared/external/swiftui-gestures/references/gesture-patterns.md +228 -310
  224. package/pipeline/skills/shared/external/swiftui-layout-components/SKILL.md +260 -249
  225. package/pipeline/skills/shared/external/swiftui-layout-components/references/form.md +92 -74
  226. package/pipeline/skills/shared/external/swiftui-layout-components/references/grids.md +112 -177
  227. package/pipeline/skills/shared/external/swiftui-layout-components/references/list.md +61 -64
  228. package/pipeline/skills/shared/external/swiftui-layout-components/references/scrollview.md +94 -134
  229. package/pipeline/skills/shared/external/swiftui-liquid-glass/SKILL.md +193 -225
  230. package/pipeline/skills/shared/external/swiftui-liquid-glass/references/liquid-glass.md +173 -327
  231. package/pipeline/skills/shared/external/swiftui-navigation/SKILL.md +193 -168
  232. package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
  233. package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +132 -133
  234. package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
  235. package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +106 -140
  236. package/pipeline/skills/shared/external/swiftui-patterns/SKILL.md +316 -252
  237. package/pipeline/skills/shared/external/swiftui-patterns/references/architecture-patterns.md +341 -332
  238. package/pipeline/skills/shared/external/swiftui-patterns/references/deprecated-migration.md +547 -854
  239. package/pipeline/skills/shared/external/swiftui-patterns/references/design-polish.md +485 -537
  240. package/pipeline/skills/shared/external/swiftui-patterns/references/platform-and-sharing.md +417 -499
  241. package/pipeline/skills/shared/external/swiftui-performance/SKILL.md +213 -376
  242. package/pipeline/skills/shared/external/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +86 -175
  243. package/pipeline/skills/shared/external/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +89 -195
  244. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-hangs-in-your-app.md +95 -182
  245. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-improving-swiftui-performance.md +71 -149
  246. package/pipeline/skills/shared/external/swiftui-performance/references/wwdc-session-sources.md +21 -27
  247. package/pipeline/skills/shared/external/swiftui-uikit-interop/SKILL.md +303 -295
  248. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/hosting-migration.md +204 -387
  249. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/representable-recipes.md +469 -683
  250. package/pipeline/skills/shared/external/swiftui-webkit/SKILL.md +140 -186
  251. package/pipeline/skills/shared/external/swiftui-webkit/references/loading-and-observation.md +75 -86
  252. package/pipeline/skills/shared/external/swiftui-webkit/references/local-content-and-custom-schemes.md +63 -60
  253. package/pipeline/skills/shared/external/swiftui-webkit/references/migration-and-fallbacks.md +69 -137
  254. package/pipeline/skills/shared/external/swiftui-webkit/references/navigation-and-javascript.md +95 -67
  255. package/pipeline/skills/shared/external/tipkit/SKILL.md +220 -335
  256. package/pipeline/skills/shared/external/tipkit/references/tipkit-patterns.md +356 -494
  257. package/pipeline/skills/shared/external/vision-framework/SKILL.md +260 -375
  258. package/pipeline/skills/shared/external/vision-framework/references/vision-requests.md +393 -515
  259. package/pipeline/skills/shared/external/vision-framework/references/visionkit-scanner.md +363 -539
  260. package/pipeline/skills/shared/external/weatherkit/SKILL.md +152 -310
  261. package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
  262. package/pipeline/skills/shared/external/widgetkit/SKILL.md +216 -288
  263. package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +414 -719
  264. package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
@@ -1,477 +1,314 @@
1
1
  ---
2
2
  name: swiftui-performance
3
- description: "Audit and improve SwiftUI runtime performance: slow rendering, janky scrolling, high CPU or memory, excessive view updates, layout thrash, body cost, identity churn, lazy loading, Instruments profiling. Use when diagnosing a SwiftUI performance problem; for a symptom-first audit ending in a written report use swiftui-performance-audit."
3
+ description: "SwiftUI performance: slow rendering, janky scrolling, high CPU/memory, excess updates, layout thrash, costly body, identity churn, lazy loading, Observation dependencies, Instruments profiling. Use when auditing, diagnosing or improving SwiftUI performance from code or a trace. Not for report-style audits (swiftui-performance-audit)."
4
4
  metadata:
5
- source: "dpearson2699/swift-ios-skills (PolyForm Perimeter 1.0.0)"
5
+ source: multi-agent-pipeline
6
6
  ---
7
7
 
8
8
  # SwiftUI Performance
9
9
 
10
- Audit SwiftUI view performance end-to-end, from instrumentation and baselining to root-cause analysis and concrete remediation steps.
11
-
12
- ## Contents
13
-
14
- - [Workflow Decision Tree](#workflow-decision-tree)
15
- - [1. Code-First Review](#1-code-first-review)
16
- - [2. Guide the User to Profile](#2-guide-the-user-to-profile)
17
- - [3. Analyze and Diagnose](#3-analyze-and-diagnose)
18
- - [4. Remediate](#4-remediate)
19
- - [Common Code Smells (and Fixes)](#common-code-smells-and-fixes)
20
- - [5. Verify](#5-verify)
21
- - [Outputs](#outputs)
22
- - [Instruments Profiling](#instruments-profiling)
23
- - [Identity and Lifetime](#identity-and-lifetime)
24
- - [Lazy Loading Patterns](#lazy-loading-patterns)
25
- - [State and Observation Optimization](#state-and-observation-optimization)
26
- - [Common Mistakes](#common-mistakes)
27
- - [Review Checklist](#review-checklist)
28
- - [References](#references)
29
-
30
- ## Workflow Decision Tree
31
-
32
- - If the user provides code, start with "Code-First Review."
33
- - If the user only describes symptoms, ask for minimal code/context, then do "Code-First Review."
34
- - If code review is inconclusive, go to "Guide the User to Profile" and ask for a trace or screenshots.
35
-
36
- ## 1. Code-First Review
37
-
38
- Collect:
39
- - Target view/feature code.
40
- - Data flow: state, environment, observable models.
41
- - Symptoms and reproduction steps.
42
-
43
- Focus on:
44
- - View invalidation storms from broad state changes.
45
- - Unstable identity in lists (`id` churn, `UUID()` per render).
46
- - Top-level conditional view swapping (`if/else` returning different root branches).
47
- - Heavy work in `body` (formatting, sorting, image decoding).
48
- - Layout thrash (deep stacks, `GeometryReader`, preference chains).
49
- - Large images without downsampling or resizing.
50
- - Over-animated hierarchies (implicit animations on large trees).
51
-
52
- Provide:
53
- - Likely root causes with code references.
54
- - Suggested fixes and refactors.
55
- - If needed, a minimal repro or instrumentation suggestion.
56
-
57
- ## 2. Guide the User to Profile
58
-
59
- Explain how to collect data with Instruments:
60
- - Use the SwiftUI template in Instruments.
61
- - Profile a **Release build** on a real device when possible.
62
- - Reproduce the exact interaction (scroll, navigation, animation).
63
- - Capture SwiftUI timeline and Time Profiler.
64
- - Export or screenshot the relevant lanes and the call tree.
65
-
66
- Ask for:
67
- - Trace export or screenshots of SwiftUI lanes + Time Profiler call tree.
68
- - Device/OS/build configuration.
69
-
70
- ## 3. Analyze and Diagnose
71
-
72
- Prioritize likely SwiftUI culprits:
73
- - View invalidation storms from broad state changes.
74
- - Unstable identity in lists (`id` churn, `UUID()` per render).
75
- - Top-level conditional view swapping (`if/else` returning different root branches).
76
- - Heavy work in `body` (formatting, sorting, image decoding).
77
- - Layout thrash (deep stacks, `GeometryReader`, preference chains).
78
- - Large images without downsampling or resizing.
79
- - Over-animated hierarchies (implicit animations on large trees).
80
-
81
- Summarize findings with evidence from traces/logs.
82
-
83
- ## 4. Remediate
84
-
85
- Apply targeted fixes:
86
- - Narrow state scope (`@State`/`@Observable` closer to leaf views).
87
- - Stabilize identities for `ForEach` and lists.
88
- - Move heavy work out of `body` (precompute, cache, `@State`).
89
- - Use `equatable()` or value wrappers for expensive subtrees.
90
- - Downsample images before rendering.
91
- - Reduce layout complexity or use fixed sizing where possible.
92
-
93
- ## Common Code Smells (and Fixes)
94
-
95
- Look for these patterns during code review.
96
-
97
- ### Expensive formatters in `body`
10
+ Baseline: iOS 26 and Xcode 26. Observation needs iOS 17; APIs that need a
11
+ later release say so.
98
12
 
99
- ```swift
100
- var body: some View {
101
- let number = NumberFormatter() // slow allocation
102
- let measure = MeasurementFormatter() // slow allocation
103
- Text(measure.string(from: .init(value: meters, unit: .meters)))
104
- }
105
- ```
13
+ A symptom-first audit whose deliverable is a written report belongs to
14
+ `swiftui-performance-audit`. General LLDB and Instruments technique is in
15
+ `debugging-instruments`.
106
16
 
107
- Prefer cached formatters in a model or a dedicated helper:
17
+ ## Where to Start
108
18
 
109
- ```swift
110
- final class DistanceFormatter {
111
- static let shared = DistanceFormatter()
112
- let number = NumberFormatter()
113
- let measure = MeasurementFormatter()
114
- }
115
- ```
19
+ | You have | Do this |
20
+ |----------|---------|
21
+ | The code | Start with the code review below |
22
+ | Only a description of the symptom | Ask for the smallest amount of code and context that shows it, then review the code |
23
+ | A code review that found nothing convincing | Walk the user through a profiling session and ask for the trace or screenshots |
116
24
 
117
- ### Computed properties that do heavy work
25
+ ## 1. Review the Code
118
26
 
119
- ```swift
120
- var filtered: [Item] {
121
- items.filter { $0.isEnabled } // runs on every body eval
122
- }
123
- ```
27
+ Collect three things: the view or feature code, how data flows into it (state,
28
+ environment, observable models), and the symptom with steps to reproduce.
124
29
 
125
- Prefer precompute or cache on change:
30
+ Look for these, most frequent first:
126
31
 
127
- ```swift
128
- @State private var filtered: [Item] = []
129
- // update filtered when inputs change
130
- ```
32
+ - A broad state change that invalidates far more views than it needs to.
33
+ - List identity that is not stable: ids that change, a `UUID()` made during
34
+ render.
35
+ - A root `if`/`else` that swaps between two different view trees.
36
+ - Expensive work inside `body`: formatting, sorting, image decoding.
37
+ - Layout thrash from deep stacks, `GeometryReader` or chains of preferences.
38
+ - Large images shown without downsampling.
39
+ - Implicit animations applied to large subtrees.
131
40
 
132
- ### Sorting/filtering in `body` or `ForEach`
41
+ Report the likely causes with references to the code, the fixes or refactors,
42
+ and where useful a small repro or an instrumentation idea.
133
43
 
134
- ```swift
135
- // DON'T: sorts or filters on every body evaluation
136
- ForEach(items.sorted(by: sortRule)) { item in Row(item) }
137
- ForEach(items.filter { $0.isEnabled }) { item in Row(item) }
138
- ```
44
+ ## 2. Profile When Code Is Not Enough
139
45
 
140
- Prefer precomputed, cached collections with stable identity. Update on input change, not in `body`.
46
+ Ask the user to:
141
47
 
142
- ### Unstable identity
48
+ 1. Profile with the SwiftUI template in Instruments (Cmd+I).
49
+ 2. Use a Release build on a real device whenever possible.
50
+ 3. Repeat the exact interaction: the scroll, the push, the animation.
51
+ 4. Capture the SwiftUI lanes and Time Profiler, then export the trace or take
52
+ screenshots of the lanes and the call tree.
53
+ 5. Send those along with the device, OS version and build configuration.
143
54
 
144
- ```swift
145
- ForEach(items, id: \.self) { item in
146
- Row(item)
147
- }
148
- ```
55
+ The full lane-by-lane workflow is in
56
+ [the SwiftUI Instrument guide](references/optimizing-swiftui-performance-instruments.md).
149
57
 
150
- Avoid `id: \.self` for non-stable values; use a stable ID.
58
+ ## 3. Diagnose
151
59
 
152
- ### Top-level conditional view swapping
60
+ Use the same list as the code review (broad invalidation, unstable identity,
61
+ swapped roots, heavy bodies, layout thrash, oversized images, too much
62
+ animation) and tie every conclusion to evidence from the trace or logs.
153
63
 
154
- ```swift
155
- var content: some View {
156
- if isEditing {
157
- editingView
158
- } else {
159
- readOnlyView
160
- }
161
- }
162
- ```
64
+ ## 4. Fix
163
65
 
164
- Prefer one stable base view and localize conditions to sections/modifiers (for example inside `toolbar`, row content, `overlay`, or `disabled`). This reduces root identity churn and helps SwiftUI diffing stay efficient.
66
+ - Move state closer to the leaves that read it (`@State`, `@Observable`).
67
+ - Give `ForEach` and `List` identities that do not change.
68
+ - Take heavy work out of `body`: compute once, cache, keep results in `@State`
69
+ or the model.
70
+ - Put `equatable()` or a small value wrapper around expensive subtrees.
71
+ - Downsample images before they reach the view.
72
+ - Simplify layout, or use fixed sizes where the design allows.
165
73
 
166
- ### Image decoding on the main thread
74
+ ### Smells and their fixes
167
75
 
168
76
  ```swift
169
- Image(uiImage: UIImage(data: data)!)
170
- ```
171
-
172
- Prefer decode/downsample off the main thread and store the result.
173
-
174
- ### Broad dependencies in observable models
175
-
176
- ```swift
177
- @Observable class Model {
178
- var items: [Item] = []
77
+ struct FuelRow: View {
78
+ let litres: Double
79
+ var body: some View {
80
+ Text(FuelFormat.shared.string(from: litres as NSNumber) ?? "")
81
+ }
179
82
  }
180
83
 
181
- var body: some View {
182
- Row(isFavorite: model.items.contains(item))
84
+ enum FuelFormat {
85
+ static let shared: NumberFormatter = {
86
+ let formatter = NumberFormatter()
87
+ formatter.maximumFractionDigits = 1
88
+ return formatter
89
+ }()
183
90
  }
184
91
  ```
185
92
 
186
- Prefer granular view models or per-item state to reduce update fan-out.
187
-
188
- ## 5. Verify
189
-
190
- Ask the user to re-run the same capture and compare with baseline metrics.
191
- Summarize the delta (CPU, frame drops, memory peak) if provided.
93
+ Building a `NumberFormatter` or `MeasurementFormatter` in `body` costs time on
94
+ every evaluation. Keep one cached instance as above, or use a `FormatStyle`.
192
95
 
193
- ## Outputs
194
-
195
- Provide:
196
- - A short metrics table (before/after if available).
197
- - Top issues (ordered by impact).
198
- - Proposed fixes with estimated effort.
199
-
200
- ## Instruments Profiling
201
-
202
- Use the **SwiftUI instrument template** in Xcode (Cmd+I to profile). Key instruments: SwiftUI View Body (body evaluation counts), SwiftUI View Properties (state change tracking), Time Profiler, and Hangs.
96
+ ```swift
97
+ struct TripList: View {
98
+ let trips: [Trip]
99
+ let query: String
100
+ @State private var visible: [Trip] = []
203
101
 
204
- Add `Self._printChanges()` in debug builds to log which property triggered a view update:
102
+ var body: some View {
103
+ List(visible) { trip in
104
+ TripRow(trip: trip)
105
+ }
106
+ .onChange(of: trips, initial: true) { refresh() }
107
+ .onChange(of: query) { refresh() }
108
+ }
205
109
 
206
- ```swift
207
- var body: some View {
208
- #if DEBUG
209
- let _ = Self._printChanges() // "MyView: @self, _count changed."
210
- #endif
211
- Text("Count: \(count)")
110
+ private func refresh() {
111
+ visible = trips
112
+ .filter { query.isEmpty || $0.name.localizedStandardContains(query) }
113
+ .sorted { $0.departure < $1.departure }
114
+ }
212
115
  }
213
116
  ```
214
117
 
215
- See [references/optimizing-swiftui-performance-instruments.md](references/optimizing-swiftui-performance-instruments.md) for the full profiling workflow.
216
-
217
- ## Identity and Lifetime
218
-
219
- ### Structural Identity vs Explicit Identity
118
+ A computed property that filters, or `ForEach(items.sorted(by:))` and
119
+ `ForEach(items.filter { ... })`, redo the work on every evaluation. Keep the
120
+ result in `@State` (or the model) and refresh it only when an input changes;
121
+ the stored array also keeps identities stable.
220
122
 
221
- SwiftUI assigns every view an **identity** used to track its lifetime, state, and animations.
123
+ | Smell | Fix |
124
+ |-------|-----|
125
+ | `ForEach(tags, id: \.self)` over values that can repeat or change | Use a stable identifier |
126
+ | Root `if isEditing { EditorView() } else { ReaderView() }` | Keep one base view and put the condition inside sections, row content or modifiers (`toolbar`, `overlay`, `disabled`) |
127
+ | `Image(uiImage: UIImage(data: data)!)` in `body` | Decode and downsample off the main thread, store the resulting image |
128
+ | Every row reads `model.favorites.contains(item)` on one broad `@Observable` | Give rows per-item state or a narrower model so one change does not reach every row |
222
129
 
223
- - **Structural identity** (default): determined by the view's position in the view hierarchy. SwiftUI uses the call-site location in `body` to distinguish views.
224
- - **Explicit identity**: you assign with `.id(_:)` modifier or `ForEach(items, id: \.stableID)`.
225
-
226
- ```swift
227
- // Structural identity: SwiftUI knows these are different views by position
228
- VStack {
229
- Text("First") // position 0
230
- Text("Second") // position 1
231
- }
232
- ```
233
-
234
- ### How Identity Tracks View Lifetime
130
+ ## 5. Verify
235
131
 
236
- When a view's identity changes, SwiftUI treats it as a **new view**:
132
+ Ask the user to repeat the same capture and compare it with the first one:
133
+ CPU, dropped frames and peak memory.
237
134
 
238
- - All `@State` is reset.
239
- - `onAppear` fires again.
240
- - Animations may restart.
241
- - Transition animations play (if defined).
135
+ Deliver:
136
+ - a short before and after metrics table,
137
+ - the main issues ordered by impact,
138
+ - the fixes with a rough effort estimate.
242
139
 
243
- When identity stays the same, SwiftUI updates the **existing view** in place, preserving state and providing smooth transitions.
140
+ ## Instruments
244
141
 
245
- ### AnyView and Identity Reset
142
+ Profile with Cmd+I and the SwiftUI template. In Instruments 26 the SwiftUI
143
+ instrument shows lanes such as Update Groups, Long View Body Updates and the
144
+ Cause and Effect Graph. Older Instruments versions offered separate SwiftUI
145
+ View Body (how often bodies ran) and SwiftUI View Properties (which properties
146
+ changed) instruments. Pair either with Time Profiler and Hangs.
246
147
 
247
- `AnyView` erases type information, forcing SwiftUI to fall back to less efficient diffing:
148
+ To see why a particular view updated while debugging:
248
149
 
249
150
  ```swift
250
- // DON'T: AnyView destroys type identity
251
- func makeView(for item: Item) -> AnyView {
252
- if item.isPremium {
253
- return AnyView(PremiumRow(item: item))
254
- } else {
255
- return AnyView(StandardRow(item: item))
256
- }
257
- }
258
-
259
- // DO: use @ViewBuilder to preserve structural identity
260
- @ViewBuilder
261
- func makeView(for item: Item) -> some View {
262
- if item.isPremium {
263
- PremiumRow(item: item)
264
- } else {
265
- StandardRow(item: item)
151
+ struct ScoreBadge: View {
152
+ let score: Int
153
+ var body: some View {
154
+ #if DEBUG
155
+ let _ = Self._printChanges()
156
+ #endif
157
+ Text(score, format: .number)
266
158
  }
267
159
  }
268
160
  ```
269
161
 
270
- `AnyView` also prevents SwiftUI from detecting which branch changed, causing full subtree replacement instead of targeted updates.
271
-
272
- ### Ternary Modifiers Preserve Structural Identity
273
-
274
- `if`/`else` in a view builder creates `_ConditionalContent` - two separate view branches with distinct identities. When the condition changes, SwiftUI destroys one branch and creates the other, resetting all `@State`.
275
-
276
- For toggling **modifiers** on the same view, use a ternary expression instead:
277
-
278
- ```swift
279
- // DON'T: if/else creates two separate Text views with different identities
280
- if isHighlighted {
281
- Text(title).foregroundStyle(.yellow)
282
- } else {
283
- Text(title).foregroundStyle(.primary)
284
- }
162
+ The console then prints lines such as `ScoreBadge: @self, _score changed.`.
285
163
 
286
- // DO: ternary keeps one Text view, just changes the modifier value
287
- Text(title)
288
- .foregroundStyle(isHighlighted ? .yellow : .primary)
289
- ```
164
+ ## Identity and Lifetime
290
165
 
291
- This preserves the view's identity (and its state) across the condition change, and SwiftUI can animate the transition smoothly.
166
+ Every view has an identity. SwiftUI uses it to decide how long the view lives,
167
+ which state belongs to it, and what to animate.
292
168
 
293
- Use `if`/`else` when the **view type itself** differs between branches. Use ternary when only a **property or modifier** changes.
169
+ - **Structural identity** is the default: the view's type and position in the
170
+ hierarchy.
171
+ - **Explicit identity** comes from `.id(_:)` or from the id in
172
+ `ForEach(items, id: \.code)`.
294
173
 
295
- ### id() Modifier Impacts
174
+ | Identity changed | Identity kept |
175
+ |------------------|---------------|
176
+ | All `@State` starts over | The view is updated in place |
177
+ | `onAppear` runs again | State survives |
178
+ | Animations can restart and transitions play | Changes animate smoothly |
296
179
 
297
- The `.id()` modifier assigns explicit identity. Changing the value **destroys and recreates** the view:
180
+ `AnyView` hides the concrete type, so SwiftUI cannot tell which branch it is
181
+ looking at and falls back to replacing the whole subtree. Return `some View`
182
+ from a `@ViewBuilder` function instead:
298
183
 
299
184
  ```swift
300
- // DON'T: UUID() changes every render, destroying and recreating the view each time
301
- ScrollView {
302
- LazyVStack {
303
- ForEach(items) { item in
304
- Row(item: item)
305
- .id(UUID()) // kills performance -- new identity every render
306
- }
185
+ @ViewBuilder
186
+ func statusView(for status: Shipment.Status) -> some View {
187
+ if status == .delivered {
188
+ Label("Delivered", systemImage: "checkmark.circle")
189
+ } else {
190
+ ProgressView(value: status.progress)
307
191
  }
308
192
  }
309
-
310
- // DO: use a stable identifier
311
- ForEach(items) { item in
312
- Row(item: item)
313
- .id(item.stableID) // identity only changes when the item actually changes
314
- }
315
193
  ```
316
194
 
317
- Intentional `.id()` change is useful for **resetting state** (e.g., `.id(selectedTab)` to reset a scroll position when switching tabs).
318
-
319
- ## Lazy Loading Patterns
320
-
321
- ### LazyVStack and LazyHStack
322
-
323
- Lazy stacks only create views for items currently visible on screen. Off-screen items are not evaluated until scrolled into view.
195
+ An `if`/`else` in a view builder produces `_ConditionalContent`: two separate
196
+ identities. Flipping the condition throws one branch away together with its
197
+ `@State`. When only a value changes, use a ternary so there is one view:
324
198
 
325
199
  ```swift
326
- ScrollView {
327
- LazyVStack {
328
- ForEach(items) { item in
329
- ItemRow(item: item)
330
- }
331
- }
332
- }
200
+ Image(systemName: "star.fill")
201
+ .foregroundStyle(isPinned ? .orange : .secondary)
333
202
  ```
334
203
 
335
- Key behaviors:
336
- - Views are created lazily but **not destroyed** when scrolled off screen (they remain in memory).
337
- - `onAppear` fires when the view first enters the visible area.
338
- - `onDisappear` fires when it leaves, but the view is still alive.
204
+ Rule: `if`/`else` when the view type differs, a ternary when only a property or
205
+ modifier value differs.
339
206
 
340
- ### LazyVGrid and LazyHGrid
207
+ Changing the value passed to `.id()` destroys the view and builds a new one.
208
+ `.id(UUID())` on a row in a `LazyVStack` therefore creates a fresh identity on
209
+ every render. Use `.id(item.code)`. Changing the id on purpose is fine when you
210
+ want a reset, for example `.id(activeTab)` to start a scroll view at the top
211
+ again after switching tabs.
341
212
 
342
- Use lazy grids for multi-column layouts:
213
+ ## Lazy Containers
343
214
 
344
- ```swift
345
- // Adaptive: as many columns as fit with minimum width
346
- let columns = [GridItem(.adaptive(minimum: 150))]
215
+ - `LazyVStack` and `LazyHStack` only build views that are on screen; the rest
216
+ are not evaluated until they scroll in.
217
+ - A view built lazily is not destroyed when it scrolls away; it stays in
218
+ memory.
219
+ - `onAppear` runs when a view first enters the visible area; `onDisappear` runs
220
+ when it leaves, while the view itself stays alive.
221
+ - For several columns use `LazyVGrid` or `LazyHGrid`.
222
+ `GridItem(.adaptive(minimum: 150))` fits as many columns as the width
223
+ allows; three `GridItem(.flexible())` give three equal columns.
347
224
 
348
- ScrollView {
349
- LazyVGrid(columns: columns) {
350
- ForEach(photos) { photo in
351
- PhotoThumbnail(photo: photo)
352
- }
353
- }
225
+ ```swift
226
+ LazyVGrid(columns: [GridItem(.adaptive(minimum: 150))]) {
227
+ ForEach(albums) { AlbumTile(album: $0) }
354
228
  }
355
-
356
- // Fixed: exact number of equal columns
357
- let fixedColumns = [
358
- GridItem(.flexible()),
359
- GridItem(.flexible()),
360
- GridItem(.flexible()),
361
- ]
362
229
  ```
363
230
 
364
- ### When to Use Lazy vs Eager Stacks
365
-
366
- | Scenario | Use |
367
- |----------|-----|
368
- | < 50 items | `VStack` / `HStack` (eager is fine) |
369
- | 50-100 items | Either works; prefer `Lazy` if items are complex |
370
- | > 100 items | `LazyVStack` / `LazyHStack` (required for performance) |
371
- | Always-visible content | `VStack` (no benefit to lazy) |
372
- | Scrollable lists | `LazyVStack` inside `ScrollView`, or `List` |
373
-
374
- **Important:** Do not nest `GeometryReader` inside lazy containers. It forces eager measurement and defeats lazy loading. Use `.onGeometryChange` (iOS 16+) instead.
231
+ | Content | Container |
232
+ |---------|-----------|
233
+ | Fewer than about 50 items | `VStack` or `HStack` is fine |
234
+ | 50 to 100 items | Either; prefer lazy when rows are complex |
235
+ | More than 100 items | `LazyVStack` or `LazyHStack` |
236
+ | Always fully visible | `VStack`; laziness gains nothing |
237
+ | A scrolling list | `LazyVStack` inside `ScrollView`, or `List` |
375
238
 
376
- ## State and Observation Optimization
239
+ Do not put `GeometryReader` inside lazy content: it makes SwiftUI measure
240
+ eagerly. Use `.onGeometryChange(for:of:action:)`, which is available back to
241
+ iOS 16 when building with the Xcode 16 SDK or later.
377
242
 
378
- ### `@Observable` Granular Tracking
243
+ ## Observation
379
244
 
380
- `@Observable` (Observation framework, iOS 17+) tracks property access at the **per-property level**. A view only re-evaluates when properties it actually read in `body` change:
245
+ With `@Observable` (iOS 17), SwiftUI records which properties a `body` reads
246
+ and re-evaluates the view only when one of those changes.
381
247
 
382
248
  ```swift
383
- @Observable class UserProfile {
384
- var name: String = ""
249
+ @Observable
250
+ final class Profile {
251
+ var displayName = ""
252
+ var biography = ""
385
253
  var avatarURL: URL?
386
- var biography: String = ""
387
254
  }
388
255
 
389
- // This view ONLY re-renders when `name` changes -- not when
390
- // biography or avatarURL change, because it only reads `name`
391
- struct NameLabel: View {
392
- let profile: UserProfile
256
+ struct ProfileHeader: View {
257
+ let profile: Profile
393
258
  var body: some View {
394
- Text(profile.name)
259
+ Text(profile.displayName)
395
260
  }
396
261
  }
397
262
  ```
398
263
 
399
- This is a significant improvement over `ObservableObject` + `@Published`, which invalidates all observing views when **any** published property changes.
264
+ `ProfileHeader` ignores changes to `biography` and `avatarURL`. With
265
+ `ObservableObject`, any `@Published` change invalidates every observer.
400
266
 
401
- ### Avoiding Observation Scope Pollution
267
+ A single body that reads many properties still has a wide dependency surface.
268
+ Split it into children that each read what they show: a name row, an email row,
269
+ an avatar view, a settings form.
402
270
 
403
- If a view reads many properties from an `@Observable` model in `body`, it re-renders when **any** of those properties change. Push reads into child views to narrow the scope:
271
+ Computed properties derive values without widening the surface:
404
272
 
405
273
  ```swift
406
- // DON'T: reads name, email, avatar, and settings in one body
407
- struct ProfileView: View {
408
- let model: ProfileModel
409
- var body: some View {
410
- VStack {
411
- Text(model.name) // tracks name
412
- Text(model.email) // tracks email
413
- AsyncImage(url: model.avatar) // tracks avatar
414
- SettingsForm(model.settings) // tracks settings
415
- }
416
- }
417
- }
418
-
419
- // DO: split into child views so each only tracks what it reads
420
- struct ProfileView: View {
421
- let model: ProfileModel
422
- var body: some View {
423
- VStack {
424
- NameRow(model: model) // only tracks name
425
- EmailRow(model: model) // only tracks email
426
- AvatarView(model: model) // only tracks avatar
427
- SettingsForm(model: model) // only tracks settings
428
- }
429
- }
274
+ @Observable
275
+ final class Basket {
276
+ var lines: [BasketLine] = []
277
+ var total: Decimal { lines.reduce(0) { $0 + $1.price * Decimal($1.quantity) } }
430
278
  }
431
279
  ```
432
280
 
433
- ### Computed Properties for Derived State
434
-
435
- Use computed properties on `@Observable` models to derive state without introducing extra stored properties that widen observation scope:
436
-
437
- ```swift
438
- @Observable class ShoppingCart {
439
- var items: [CartItem] = []
440
-
441
- // Views reading `total` only re-render when `items` changes
442
- var total: Decimal {
443
- items.reduce(0) { $0 + $1.price * Decimal($1.quantity) }
444
- }
445
- }
446
- ```
281
+ A view that reads `total` updates only when `lines` changes.
447
282
 
448
283
  ## Common Mistakes
449
284
 
450
- 1. **Profiling Debug builds.** Debug builds include extra runtime checks and disable optimizations, producing misleading perf data. Profile Release builds on a real device.
451
- 2. **Observing an entire model when only one property is needed.** Break large `@Observable` models into focused ones, or use computed properties/closures to narrow observation scope.
452
- 3. **Using `GeometryReader` inside ScrollView items.** GeometryReader forces eager sizing and defeats lazy loading. Prefer `.onGeometryChange` (iOS 16+) or measure outside the lazy container.
453
- 4. **Calling `DateFormatter()` or `NumberFormatter()` inside `body`.** These are expensive to create. Make them static or move them outside the view.
454
- 5. **Animating non-equatable state.** If SwiftUI cannot determine equality, it redraws every frame. Conform state to `Equatable`, then use `.animation(_:value:)` for simple value-bound changes or `.animation(_:body:)` for narrower modifier-scoped implicit animation.
455
- 6. **Large flat `List` without identifiers.** Use `id:` or make items `Identifiable` so SwiftUI can diff efficiently instead of rebuilding the entire list.
456
- 7. **Unnecessary `@State` wrapper objects.** Wrapping a simple value type in a class for `@State` defeats value semantics. Use plain `@State` with structs.
457
- 8. **Blocking `MainActor` with synchronous I/O.** File reads, JSON parsing of large payloads, and image decoding should happen off the main actor. Use `Task.detached` or a custom actor.
285
+ | Mistake | Better |
286
+ |---------|--------|
287
+ | Profiling a Debug build (extra checks, no optimisation) | Profile Release on a device |
288
+ | Observing a whole model to show one field | Split the model, or pass a computed value or closure |
289
+ | `GeometryReader` inside `ScrollView` rows | `.onGeometryChange`, or measure outside the lazy content |
290
+ | `DateFormatter()` or `NumberFormatter()` in `body` | A static instance or a `FormatStyle` |
291
+ | Animating state that is not `Equatable`, so every frame redraws | Make it `Equatable`; use `.animation(_:value:)`, or `.animation(_:body:)` (iOS 17) to limit the animation to specific modifiers |
292
+ | A large `List` without identifiers | `Identifiable` data or `id:` |
293
+ | Wrapping a struct in a class to hold it in `@State` | Store the struct in `@State` directly |
294
+ | Reading files, big JSON or images synchronously on the main actor | A `@concurrent` async function (Swift 6.2), a dedicated actor, or `Task.detached` |
458
295
 
459
296
  ## Review Checklist
460
297
 
461
- - [ ] No `DateFormatter`/`NumberFormatter` allocations inside `body`
462
- - [ ] Large lists use `Identifiable` items or explicit `id:`
463
- - [ ] `@Observable` models expose only the properties views actually read
464
- - [ ] Heavy computation is off `MainActor` (image processing, parsing)
465
- - [ ] `GeometryReader` is not inside a `LazyVStack`/`LazyHStack`/`List`
466
- - [ ] Implicit animations use `.animation(_:value:)` for value-bound changes or `.animation(_:body:)` for narrower modifier scope
467
- - [ ] No synchronous network/file I/O on the main thread
468
- - [ ] Profiling done on Release build, real device
469
- - [ ] `@Observable` view models are `@MainActor`-isolated; types crossing concurrency boundaries are `Sendable`
298
+ - [ ] No formatters created in `body`
299
+ - [ ] Large lists use `Identifiable` data or an explicit `id:`
300
+ - [ ] `@Observable` models expose what views actually read, nothing broader
301
+ - [ ] Heavy computation runs off the main actor
302
+ - [ ] No `GeometryReader` inside `LazyVStack`, `LazyHStack` or `List`
303
+ - [ ] Implicit animations use `.animation(_:value:)` or `.animation(_:body:)`
304
+ - [ ] No synchronous network or file I/O on the main thread
305
+ - [ ] Profiling done in Release on a real device
306
+ - [ ] `@Observable` view models are `@MainActor`; types that cross isolation are `Sendable`
470
307
 
471
308
  ## References
472
309
 
473
- - Demystify SwiftUI performance (WWDC23): [references/demystify-swiftui-performance-wwdc23.md](references/demystify-swiftui-performance-wwdc23.md)
474
- - Optimizing SwiftUI performance with Instruments: [references/optimizing-swiftui-performance-instruments.md](references/optimizing-swiftui-performance-instruments.md)
475
- - Understanding hangs in your app: [references/understanding-hangs-in-your-app.md](references/understanding-hangs-in-your-app.md)
476
- - Understanding and improving SwiftUI performance: [references/understanding-improving-swiftui-performance.md](references/understanding-improving-swiftui-performance.md)
477
- - WWDC transcript sources: [references/wwdc-session-sources.md](references/wwdc-session-sources.md)
310
+ - [Mental model, dependencies and identity](references/demystify-swiftui-performance-wwdc23.md)
311
+ - [Profiling with the SwiftUI Instrument](references/optimizing-swiftui-performance-instruments.md)
312
+ - [Hangs and the main run loop](references/understanding-hangs-in-your-app.md)
313
+ - [Long versus frequent updates](references/understanding-improving-swiftui-performance.md)
314
+ - [Which Apple session or article to consult](references/wwdc-session-sources.md)