@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,499 +1,402 @@
1
1
  ---
2
2
  name: avkit
3
- description: "Create media playback experiences using AVKit. Use when adding video players with AVPlayerViewController, enabling Picture-in-Picture, routing media with AirPlay, using SwiftUI VideoPlayer views, configuring transport controls, displaying subtitles and closed captions, or integrating AVFoundation playback with system UI."
3
+ description: "AVKit playback UI: AVPlayerViewController, SwiftUI VideoPlayer, Picture-in-Picture, AirPlay routing, transport controls, subtitles and closed captions, audio session and background mode, AVFoundation playback in system UI. Use when building a video player or adding PiP, AirPlay, transport controls or captions."
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
  # AVKit
9
9
 
10
- High-level media playback UI built on AVFoundation. Provides system-standard
11
- video players, Picture-in-Picture, AirPlay routing, transport controls, and
12
- subtitle/caption display. Targets Swift 6.3 / iOS 26+.
10
+ AVKit is the playback UI layer over AVFoundation. It supplies the standard
11
+ player, Picture-in-Picture (PiP), AirPlay, transport controls and subtitle and
12
+ caption display. Code here is written for iOS 26 with Swift 6.3.
13
13
 
14
- ## Contents
15
-
16
- - [Setup](#setup)
17
- - [AVPlayerViewController](#avplayerviewcontroller)
18
- - [SwiftUI VideoPlayer](#swiftui-videoplayer)
19
- - [Picture-in-Picture](#picture-in-picture)
20
- - [AirPlay](#airplay)
21
- - [Transport Controls and Playback Speed](#transport-controls-and-playback-speed)
22
- - [Subtitles and Closed Captions](#subtitles-and-closed-captions)
23
- - [Common Mistakes](#common-mistakes)
24
- - [Review Checklist](#review-checklist)
25
- - [References](#references)
14
+ Covers: PiP for standard and custom players, AirPlay routing with
15
+ `AVRoutePickerView`, playback speeds and interstitial ads.
26
16
 
27
17
  ## Setup
28
18
 
29
- ### Audio Session Configuration
19
+ ### Audio session and background mode
30
20
 
31
- Playback apps need an audio session category and the matching background mode
32
- when they support background audio, AirPlay, or PiP.
21
+ Background audio, AirPlay and PiP all depend on two things: an audio session
22
+ in the playback category, and the background mode that goes with it.
33
23
 
34
- 1. Enable Background Modes > Audio, AirPlay, and Picture in Picture (the
35
- `audio` value in `UIBackgroundModes`)
36
- 2. Set the audio session category to `.playback`
37
- 3. Defer `setActive(true)` until playback begins so you do not interrupt other
38
- audio prematurely
24
+ 1. In Signing & Capabilities, add Background Modes and tick "Audio, AirPlay,
25
+ and Picture in Picture". That adds `audio` to `UIBackgroundModes`.
26
+ 2. Set the category to `.playback`, with mode `.moviePlayback` for film and
27
+ video content.
28
+ 3. Activate the session only when playback actually starts, so the app does not
29
+ silence other audio before the user presses play.
39
30
 
40
31
  ```swift
41
32
  import AVFoundation
42
33
 
43
- func configureAudioSessionForPlayback() {
44
- let session = AVAudioSession.sharedInstance()
45
- do {
46
- try session.setCategory(.playback, mode: .moviePlayback)
47
- } catch {
48
- print("Audio session category failed: \(error)")
34
+ enum PlaybackAudio {
35
+ static func configure() {
36
+ do {
37
+ let session = AVAudioSession.sharedInstance()
38
+ try session.setCategory(.playback, mode: .moviePlayback)
39
+ } catch {
40
+ assertionFailure("Audio session category failed: \(error)")
41
+ }
49
42
  }
50
- }
51
43
 
52
- func activateAudioSessionWhenPlaybackBegins() {
53
- do {
44
+ static func activateForPlayback() throws {
54
45
  try AVAudioSession.sharedInstance().setActive(true)
55
- } catch {
56
- print("Audio session activation failed: \(error)")
57
46
  }
58
47
  }
59
48
  ```
60
49
 
61
50
  ### Imports
62
51
 
63
- ```swift
64
- import AVKit // AVPlayerViewController, VideoPlayer, PiP
65
- import AVFoundation // AVPlayer, AVPlayerItem, AVAsset
66
- ```
52
+ - `import AVKit` for `AVPlayerViewController`, `VideoPlayer` and PiP.
53
+ - `import AVFoundation` for `AVPlayer`, `AVPlayerItem` and `AVAsset`.
67
54
 
68
55
  ## AVPlayerViewController
69
56
 
70
- `AVPlayerViewController` is the standard UIKit player. It provides system
71
- playback controls, PiP, AirPlay, subtitles, and frame analysis out of the box.
72
- Do not subclass it.
73
-
74
- ### Basic Presentation (Full Screen)
57
+ The standard UIKit player. It brings the system controls, PiP, AirPlay,
58
+ subtitles and video frame analysis. Apple does not support subclassing it;
59
+ configure it and use its delegate instead.
75
60
 
76
61
  ```swift
62
+ import AVFoundation
77
63
  import AVKit
64
+ import UIKit
65
+
66
+ final class LessonViewController: UIViewController {
67
+ private let playerScreen = AVPlayerViewController()
78
68
 
79
- func presentPlayer(from viewController: UIViewController, url: URL) {
80
- let player = AVPlayer(url: url)
81
- let playerVC = AVPlayerViewController()
82
- playerVC.player = player
69
+ func presentFullScreen(_ url: URL) {
70
+ let viewer = AVPlayerViewController()
71
+ viewer.player = AVPlayer(url: url)
72
+ present(viewer, animated: true) {
73
+ viewer.player?.play()
74
+ }
75
+ }
83
76
 
84
- viewController.present(playerVC, animated: true) {
85
- player.play()
77
+ func embed(_ url: URL, in holder: UIView) {
78
+ playerScreen.player = AVPlayer(url: url)
79
+ addChild(playerScreen)
80
+ holder.addSubview(playerScreen.view)
81
+ playerScreen.view.translatesAutoresizingMaskIntoConstraints = false
82
+ NSLayoutConstraint.activate([
83
+ playerScreen.view.topAnchor.constraint(equalTo: holder.topAnchor),
84
+ playerScreen.view.bottomAnchor.constraint(equalTo: holder.bottomAnchor),
85
+ playerScreen.view.leadingAnchor.constraint(equalTo: holder.leadingAnchor),
86
+ playerScreen.view.trailingAnchor.constraint(equalTo: holder.trailingAnchor)
87
+ ])
88
+ playerScreen.didMove(toParent: self)
86
89
  }
87
90
  }
88
91
  ```
89
92
 
90
- ### Inline (Embedded) Playback
93
+ ### Key properties
91
94
 
92
- Add `AVPlayerViewController` as a child view controller for inline playback.
93
- Call `addChild`, add the view with constraints, then call `didMove(toParent:)`.
95
+ | Property | Effect |
96
+ |---|---|
97
+ | `showsPlaybackControls` | shows or hides the system controls |
98
+ | `videoGravity` | `.resizeAspect` fits the frame, `.resizeAspectFill` crops to fill |
99
+ | `entersFullScreenWhenPlaybackBegins` | goes full screen when play starts |
100
+ | `exitsFullScreenWhenPlaybackEnds` | leaves full screen at the end |
101
+ | `updatesNowPlayingInfoCenter` | keeps `MPNowPlayingInfoCenter` in sync automatically |
102
+ | `contentOverlayView` | holds non-interactive views (logos, watermarks) between the video and the controls |
94
103
 
95
- ```swift
96
- func embedPlayer(in parent: UIViewController, container: UIView, url: URL) {
97
- let playerVC = AVPlayerViewController()
98
- playerVC.player = AVPlayer(url: url)
99
-
100
- parent.addChild(playerVC)
101
- container.addSubview(playerVC.view)
102
- playerVC.view.translatesAutoresizingMaskIntoConstraints = false
103
- NSLayoutConstraint.activate([
104
- playerVC.view.leadingAnchor.constraint(equalTo: container.leadingAnchor),
105
- playerVC.view.trailingAnchor.constraint(equalTo: container.trailingAnchor),
106
- playerVC.view.topAnchor.constraint(equalTo: container.topAnchor),
107
- playerVC.view.bottomAnchor.constraint(equalTo: container.bottomAnchor)
108
- ])
109
- playerVC.didMove(toParent: parent)
110
- }
111
- ```
104
+ ### Delegate
112
105
 
113
- ### Key Properties
106
+ `AVPlayerViewControllerDelegate` reports full-screen transitions, the PiP
107
+ lifecycle, ad interstitials and changes to the selected media options. To move your own
108
+ UI in step with the full-screen animation, use the transition coordinator:
114
109
 
115
110
  ```swift
116
- playerVC.showsPlaybackControls = true // Show/hide system controls
117
- playerVC.videoGravity = .resizeAspect // .resizeAspectFill to crop
118
- playerVC.entersFullScreenWhenPlaybackBegins = false
119
- playerVC.exitsFullScreenWhenPlaybackEnds = true
120
- playerVC.updatesNowPlayingInfoCenter = true // Auto-updates MPNowPlayingInfoCenter
121
- ```
122
-
123
- Use `contentOverlayView` to add non-interactive views (watermarks, logos)
124
- between the video and transport controls.
111
+ import AVKit
112
+ import UIKit
125
113
 
126
- ### Delegate
114
+ @MainActor
115
+ final class FullScreenSync: NSObject, @preconcurrency AVPlayerViewControllerDelegate {
116
+ var chrome: UIView?
127
117
 
128
- Adopt `AVPlayerViewControllerDelegate` to respond to full-screen transitions,
129
- PiP lifecycle events, interstitial playback, and media selection changes.
130
- Use the transition coordinator's `animate(alongsideTransition:completion:)` to
131
- synchronize your UI with full-screen animations.
118
+ func playerViewController(_ playerViewController: AVPlayerViewController,
119
+ willBeginFullScreenPresentationWithAnimationCoordinator coordinator: any UIViewControllerTransitionCoordinator) {
120
+ coordinator.animate(alongsideTransition: { _ in self.chrome?.alpha = 0 }, completion: nil)
121
+ }
122
+ }
123
+ ```
132
124
 
133
- ### Display Readiness
125
+ ### Showing the player only when it has a frame
134
126
 
135
- Observe `isReadyForDisplay` before showing the player to avoid a black flash:
127
+ Observe `isReadyForDisplay` and reveal the player when it turns `true`; this
128
+ avoids a black flash.
136
129
 
137
130
  ```swift
138
- let observation = playerVC.observe(\.isReadyForDisplay) { observed, _ in
139
- if observed.isReadyForDisplay {
140
- // Safe to show the player view
131
+ import AVKit
132
+
133
+ @MainActor
134
+ func revealWhenReady(_ viewer: AVPlayerViewController) -> NSKeyValueObservation {
135
+ viewer.view.alpha = 0
136
+ return viewer.observe(\.isReadyForDisplay, options: [.new]) { observed, _ in
137
+ MainActor.assumeIsolated {
138
+ if observed.isReadyForDisplay { observed.view.alpha = 1 }
139
+ }
141
140
  }
142
141
  }
143
142
  ```
144
143
 
145
144
  ## SwiftUI VideoPlayer
146
145
 
147
- The `VideoPlayer` SwiftUI view wraps AVKit's playback UI.
148
-
149
- ### Basic Usage
146
+ `VideoPlayer` is the SwiftUI view for AVKit's playback UI.
150
147
 
151
148
  ```swift
152
- import SwiftUI
153
149
  import AVKit
150
+ import SwiftUI
154
151
 
155
- struct PlayerView: View {
152
+ struct TrailerView: View {
153
+ let source: URL
156
154
  @State private var player: AVPlayer?
157
155
 
158
156
  var body: some View {
159
157
  Group {
160
158
  if let player {
161
- VideoPlayer(player: player)
162
- .frame(height: 300)
159
+ VideoPlayer(player: player) {
160
+ VStack {
161
+ Spacer()
162
+ Text("Preview")
163
+ .font(.caption)
164
+ .padding(6)
165
+ .background(.ultraThinMaterial, in: Capsule())
166
+ }
167
+ }
168
+ .frame(height: 240)
163
169
  } else {
164
170
  ProgressView()
165
171
  }
166
172
  }
167
173
  .task {
168
- let url = URL(string: "https://example.com/video.m3u8")!
169
- player = AVPlayer(url: url)
170
- }
171
- }
172
- }
173
- ```
174
-
175
- ### Video Overlay
176
-
177
- Add a SwiftUI overlay above the video content and below the system playback
178
- controls. The overlay can be interactive, but it only receives events the system
179
- controls do not handle.
180
-
181
- ```swift
182
- VideoPlayer(player: player) {
183
- VStack {
184
- Spacer()
185
- HStack {
186
- Image("logo")
187
- .resizable()
188
- .frame(width: 40, height: 40)
189
- .padding()
190
- Spacer()
174
+ player = AVPlayer(url: source)
191
175
  }
192
176
  }
193
177
  }
194
178
  ```
195
179
 
196
- ### UIKit Hosting for Advanced Control
197
-
198
- `VideoPlayer` does not expose all `AVPlayerViewController` properties. For PiP
199
- configuration, delegate callbacks, or playback speed control, wrap
200
- `AVPlayerViewController` in a `UIViewControllerRepresentable`. See the full
201
- pattern in [references/avkit-patterns.md](references/avkit-patterns.md).
180
+ - The trailing closure is a video overlay. It sits above the picture and below
181
+ the system controls. It may contain interactive views, but those only receive
182
+ events that the system controls did not handle.
183
+ - `VideoPlayer` exposes only part of what `AVPlayerViewController` offers. For
184
+ PiP settings, delegate callbacks or playback speeds, wrap
185
+ `AVPlayerViewController` in a `UIViewControllerRepresentable` (see
186
+ [the patterns reference](references/avkit-patterns.md#wrapping-avplayerviewcontroller-for-swiftui)).
202
187
 
203
188
  ## Picture-in-Picture
204
189
 
205
- PiP lets users watch video in a floating window while using other apps.
206
- `AVPlayerViewController` supports PiP automatically once the app is configured,
207
- the device supports PiP, and the current `AVPlayerItem` is playable video
208
- content in an `AVPlayer`-compatible format. Audio-only items, unsupported
209
- containers/codecs, or items that are not ready to display video can make PiP
210
- unavailable even when app and device setup are correct. For custom player UIs,
211
- use `AVPictureInPictureController` directly.
190
+ `AVPlayerViewController` provides PiP by itself once three conditions hold:
191
+ setup is done, the hardware can do PiP, and the `AVPlayerItem` now loaded holds
192
+ playable video in a format AVPlayer handles. Audio-only items, unsupported
193
+ containers or codecs, and items not yet ready to display can all leave PiP
194
+ unavailable even when setup is correct. Custom player UIs drive
195
+ `AVPictureInPictureController` themselves.
212
196
 
213
197
  ### Prerequisites
214
198
 
215
- 1. Audio session category set to `.playback` (see [Setup](#setup))
216
- 2. Background Modes > Audio, AirPlay, and Picture in Picture enabled
217
- 3. Ready `AVPlayerItem` with playable video media, not audio-only content
218
- 4. Current playback context allows PiP; for custom players, observe `isPictureInPicturePossible`
199
+ 1. Audio session category `.playback`.
200
+ 2. Background mode `audio` enabled (shown in Xcode as "Audio, AirPlay, and Picture in Picture").
201
+ 3. A ready `AVPlayerItem` containing playable video, not only audio.
202
+ 4. A playback context that allows PiP; custom players watch
203
+ `isPictureInPicturePossible`.
219
204
 
220
- ### Standard Player PiP
205
+ ### Standard player
221
206
 
222
- PiP is enabled by default on `AVPlayerViewController`. Control automatic
223
- activation and inline-to-PiP transitions:
207
+ PiP is on by default. Turn it off with `allowsPictureInPicturePlayback = false`.
208
+ For an inline (not full-screen) player, set
209
+ `canStartPictureInPictureAutomaticallyFromInline = true` to enter PiP
210
+ automatically when the app goes to the background.
224
211
 
225
- ```swift
226
- let playerVC = AVPlayerViewController()
227
- playerVC.player = player
228
-
229
- // PiP enabled by default; set false to disable
230
- playerVC.allowsPictureInPicturePlayback = true
212
+ ### Restoring the app UI when PiP ends
231
213
 
232
- // Auto-start PiP when app backgrounds (for inline/non-fullscreen players)
233
- playerVC.canStartPictureInPictureAutomaticallyFromInline = true
234
- ```
214
+ When the user taps the button to return from PiP, the app must put the player
215
+ back on screen and then pass `true` to the completion handler so the system
216
+ can finish its animation.
235
217
 
236
- ### Restoring the UI When PiP Stops
218
+ ```swift
219
+ import AVKit
220
+ import UIKit
237
221
 
238
- When the user taps the restore button in PiP, implement the delegate method to
239
- re-present your player. Call the completion handler with `true` to signal the
240
- system to finish the restore animation.
222
+ @MainActor
223
+ final class PiPReturn: NSObject, @preconcurrency AVPlayerViewControllerDelegate {
224
+ weak var host: UIViewController?
241
225
 
242
- ```swift
243
- func playerViewController(
244
- _ playerViewController: AVPlayerViewController,
245
- restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void
246
- ) {
247
- // Re-present or re-embed the player view controller
248
- present(playerViewController, animated: false) {
249
- completionHandler(true)
226
+ func playerViewController(_ playerViewController: AVPlayerViewController,
227
+ restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
228
+ guard let host, playerViewController.presentingViewController == nil else {
229
+ completionHandler(true)
230
+ return
231
+ }
232
+ host.present(playerViewController, animated: false) {
233
+ completionHandler(true)
234
+ }
250
235
  }
251
236
  }
252
237
  ```
253
238
 
254
- ### Custom Player PiP
239
+ ### Custom players
255
240
 
256
- For custom player UIs, use `AVPictureInPictureController` with an `AVPlayerLayer`
257
- or sample buffer content source. Check device support before creating PiP UI,
258
- then check the controller's `isPictureInPicturePossible` before starting PiP in
259
- the current playback context. See [references/avkit-patterns.md](references/avkit-patterns.md)
260
- for full custom player and sample buffer PiP patterns.
241
+ Build an `AVPictureInPictureController` from an `AVPlayerLayer` or from a
242
+ sample-buffer content source.
261
243
 
262
- ```swift
263
- guard AVPictureInPictureController.isPictureInPictureSupported() else { return }
264
- let pipController = AVPictureInPictureController(playerLayer: playerLayer)
265
- pipController.delegate = self
266
- pipController.canStartPictureInPictureAutomaticallyFromInline = true
267
-
268
- // Call this from the user's PiP button action, never automatically.
269
- if pipController.isPictureInPicturePossible {
270
- pipController.startPictureInPicture()
271
- }
272
- ```
244
+ - Check `AVPictureInPictureController.isPictureInPictureSupported()` before
245
+ showing any PiP control.
246
+ - Check `isPictureInPicturePossible` right before `startPictureInPicture()`.
247
+ - Call `startPictureInPicture()` only from the user's tap on a PiP button,
248
+ never on your own.
249
+ - The controller also has `canStartPictureInPictureAutomaticallyFromInline` and
250
+ a `delegate`.
273
251
 
274
- ### Linear Playback During Ads
252
+ Full layer-based and sample-buffer examples are in
253
+ [the patterns reference](references/avkit-patterns.md#custom-player-with-avplayerlayer).
275
254
 
276
- Interstitial breaks can come from the media stream/manifest, which AVFoundation
277
- exposes through `AVPlayerItem.interstitialTimeRanges`, or from an app-owned
278
- `AVPlayerInterstitialEventController` schedule. Do not assign
279
- `interstitialTimeRanges` directly on iOS. Use `requiresLinearPlayback` only to
280
- prevent seeking during required ad or legal segments:
255
+ ### Ads and linear playback
281
256
 
282
- ```swift
283
- // During an ad
284
- playerVC.requiresLinearPlayback = true
257
+ Interstitial breaks come either from the stream itself (HLS interstitials,
258
+ which the item reports through `interstitialTimeRanges`) or from a schedule the app owns,
259
+ built with `AVPlayerInterstitialEventController`. On iOS,
260
+ `interstitialTimeRanges` is read-only; do not try to assign it.
285
261
 
286
- // After the ad completes
287
- playerVC.requiresLinearPlayback = false
288
- ```
262
+ Set `requiresLinearPlayback = true` only while a required ad or legal segment
263
+ plays, to block seeking, and set it back to `false` afterwards.
289
264
 
290
265
  ## AirPlay
291
266
 
292
- `AVPlayerViewController` supports AirPlay automatically when app configuration,
293
- media, routes, and device support allow external playback. No additional code is
294
- required when using the standard player. The system displays the AirPlay button
295
- in the transport controls when AirPlay-capable devices are available.
267
+ `AVPlayerViewController` supports AirPlay with no extra code when the setup,
268
+ media, available routes and device allow it. The AirPlay button appears in the
269
+ controls whenever a receiver is available.
296
270
 
297
271
  ### AVRoutePickerView
298
272
 
299
- Add a standalone AirPlay route picker button outside the player UI:
273
+ For an AirPlay button outside the player, use `AVRoutePickerView`:
300
274
 
301
275
  ```swift
302
276
  import AVKit
303
-
304
- func addRoutePicker(to containerView: UIView) {
305
- let routePicker = AVRoutePickerView(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
306
- routePicker.activeTintColor = .systemBlue
307
- routePicker.prioritizesVideoDevices = true // Show video-capable routes first
308
- containerView.addSubview(routePicker)
277
+ import UIKit
278
+
279
+ @MainActor
280
+ func castButton() -> AVRoutePickerView {
281
+ let picker = AVRoutePickerView(frame: CGRect(origin: .zero, size: CGSize(width: 44, height: 44)))
282
+ picker.activeTintColor = .systemTeal
283
+ picker.prioritizesVideoDevices = true
284
+ return picker
309
285
  }
310
286
  ```
311
287
 
312
- ### External Playback
313
-
314
- `AVPlayer` allows external playback by default. Leave it enabled for AirPlay,
315
- or set it explicitly when code elsewhere may disable it:
316
-
317
- ```swift
318
- player.allowsExternalPlayback = true
319
- ```
320
-
321
- Set `usesExternalPlaybackWhileExternalScreenIsActive` only when you want the
322
- player to automatically switch to external playback while an external screen
323
- mode is active.
324
-
325
- ## Transport Controls and Playback Speed
326
-
327
- ### Custom Playback Speeds
328
-
329
- Provide user-selectable playback speeds in the player UI:
330
-
331
- ```swift
332
- let playerVC = AVPlayerViewController()
333
- playerVC.speeds = [
334
- AVPlaybackSpeed(rate: 0.5, localizedName: "Half Speed"),
335
- AVPlaybackSpeed(rate: 1.0, localizedName: "Normal"),
336
- AVPlaybackSpeed(rate: 1.5, localizedName: "1.5x"),
337
- AVPlaybackSpeed(rate: 2.0, localizedName: "Double Speed")
338
- ]
339
- ```
340
-
341
- Use `AVPlaybackSpeed.systemDefaultSpeeds` to restore the default speed options.
342
-
343
- ### Skipping and Seeking
344
-
345
- On iOS, use the standard transport controls and `AVPlayer.seek(...)` for custom
346
- app controls. `AVPlayerViewController` skipping behavior APIs such as
347
- `isSkipForwardEnabled`, `isSkipBackwardEnabled`, and `skippingBehavior` are
348
- tvOS-focused; keep them out of iOS player implementations.
349
-
350
- ### Now Playing Integration
351
-
352
- `AVPlayerViewController` updates `MPNowPlayingInfoCenter` automatically by
353
- default. Disable this if you manage Now Playing info manually:
288
+ `prioritizesVideoDevices = true` lists video-capable receivers first.
354
289
 
355
- ```swift
356
- playerVC.updatesNowPlayingInfoCenter = false
357
- ```
290
+ ### External playback
358
291
 
359
- ## Subtitles and Closed Captions
292
+ - `AVPlayer.allowsExternalPlayback` is `true` by default. Leave it on for
293
+ AirPlay, or set it explicitly if other code might have turned it off.
294
+ - `usesExternalPlaybackWhileExternalScreenIsActive` is only for making the
295
+ player switch to external playback automatically while an external screen is
296
+ in use. It is not something AirPlay generally needs.
360
297
 
361
- AVKit handles subtitle and closed caption display automatically when the media
362
- contains appropriate text tracks. Users control subtitle preferences in
363
- Settings > Accessibility > Subtitles & Captioning.
298
+ ## Transport controls and speed
364
299
 
365
- ### Programmatic Selection
300
+ ### Custom speeds
366
301
 
367
302
  ```swift
368
- let asset = player.currentItem?.asset
303
+ import AVKit
369
304
 
370
- if let group = try await asset?.loadMediaSelectionGroup(for: .legible),
371
- let english = group.options.first(where: { option in
372
- option.locale?.language.languageCode?.identifier == "en"
373
- }) {
374
- player.currentItem?.select(english, in: group)
305
+ @MainActor
306
+ func offerLectureSpeeds(_ viewer: AVPlayerViewController) {
307
+ viewer.speeds = [
308
+ AVPlaybackSpeed(rate: 0.75, localizedName: "0.75x"),
309
+ AVPlaybackSpeed(rate: 1, localizedName: "1x"),
310
+ AVPlaybackSpeed(rate: 1.25, localizedName: "1.25x"),
311
+ AVPlaybackSpeed(rate: 1.75, localizedName: "1.75x")
312
+ ]
375
313
  }
376
- ```
377
-
378
- `allowedSubtitleOptionLanguages`, `requiresFullSubtitles`, and the
379
- `AVPlayerViewControllerDelegate` media-selection callback are tvOS-only. For iOS,
380
- load the asset's `.legible` media selection group and select an option on the
381
- `AVPlayerItem` when the app needs a default.
382
-
383
- ### Providing Subtitle Tracks in HLS
384
314
 
385
- Subtitles and closed captions are embedded in HLS manifests. AVKit reads them
386
- from `AVMediaSelectionGroup` on the `AVAsset`. For local files, use media that
387
- already includes legible subtitle or closed-caption tracks, or author those
388
- tracks into the playable asset before presenting it with AVKit.
389
-
390
- ## Common Mistakes
391
-
392
- ### DON'T: Subclass AVPlayerViewController
393
-
394
- Apple explicitly states this is unsupported. It may cause undefined behavior or
395
- crash on future OS versions.
396
-
397
- ```swift
398
- // WRONG
399
- class MyPlayerVC: AVPlayerViewController { } // Unsupported
400
-
401
- // CORRECT: Use composition with delegation
402
- let playerVC = AVPlayerViewController()
403
- playerVC.delegate = coordinator
315
+ @MainActor
316
+ func restoreDefaultSpeeds(_ viewer: AVPlayerViewController) {
317
+ viewer.speeds = AVPlaybackSpeed.systemDefaultSpeeds
318
+ }
404
319
  ```
405
320
 
406
- ### DON'T: Skip audio session configuration for PiP
321
+ ### Skipping and seeking
407
322
 
408
- PiP and background playback depend on the playback audio session category and
409
- the Audio, AirPlay, and Picture in Picture background mode.
323
+ On iOS rely on the standard transport controls, and use `AVPlayer.seek(...)`
324
+ behind any custom buttons. `isSkipForwardEnabled`, `isSkipBackwardEnabled` and
325
+ `skippingBehavior` are tvOS APIs; keep them out of iOS code.
410
326
 
411
- ```swift
412
- // WRONG: Default audio session
413
- let playerVC = AVPlayerViewController()
414
- playerVC.player = player // PiP won't work
415
-
416
- // CORRECT: Configure the category, then activate when playback starts
417
- try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
418
- try AVAudioSession.sharedInstance().setActive(true)
419
- let playerVC = AVPlayerViewController()
420
- playerVC.player = player
421
- ```
327
+ ### Now Playing
422
328
 
423
- ### DON'T: Forget the PiP restore delegate or its completion handler
329
+ `AVPlayerViewController` updates `MPNowPlayingInfoCenter` by default. Set
330
+ `updatesNowPlayingInfoCenter = false` if the app manages Now Playing itself.
424
331
 
425
- Without `restoreUserInterfaceForPictureInPictureStopWithCompletionHandler`, the
426
- system cannot return the user to your player. Failing to call
427
- `completionHandler(true)` leaves the system in an inconsistent state.
332
+ ## Subtitles and closed captions
428
333
 
429
- ```swift
430
- // WRONG: No delegate method or missing completionHandler call
431
- // User taps restore in PiP -> nothing happens or animation hangs
432
-
433
- // CORRECT
434
- func playerViewController(
435
- _ playerViewController: AVPlayerViewController,
436
- restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void
437
- ) {
438
- present(playerViewController, animated: false) {
439
- completionHandler(true)
440
- }
441
- }
442
- ```
443
-
444
- ### DON'T: Create AVPlayer in a SwiftUI view's init
445
-
446
- Creating the player eagerly causes performance issues. SwiftUI may recreate the
447
- view multiple times.
334
+ When the media has text tracks, AVKit shows subtitles and captions
335
+ automatically according to the user's choices in Settings > Accessibility >
336
+ Subtitles & Captioning.
448
337
 
449
338
  ```swift
450
- // WRONG: Created on every view init
451
- struct PlayerView: View {
452
- let player = AVPlayer(url: videoURL) // Re-created on every view evaluation
453
-
454
- var body: some View { VideoPlayer(player: player) }
455
- }
456
-
457
- // CORRECT: Use @State and defer creation
458
- struct PlayerView: View {
459
- @State private var player: AVPlayer?
339
+ import AVFoundation
460
340
 
461
- var body: some View {
462
- VideoPlayer(player: player)
463
- .task { player = AVPlayer(url: videoURL) }
464
- }
341
+ @MainActor
342
+ func chooseSubtitles(language code: String, for item: AVPlayerItem) async throws {
343
+ let media = item.asset
344
+ guard let legible = try await media.loadMediaSelectionGroup(for: .legible) else { return }
345
+ let match = legible.options.first { $0.locale?.language.languageCode?.identifier == code }
346
+ item.select(match, in: legible)
465
347
  }
466
348
  ```
467
349
 
468
- ## Review Checklist
469
-
470
- - [ ] Audio session category set to `.playback` with `mode: .moviePlayback`
471
- - [ ] Audio session activation deferred until playback begins
472
- - [ ] Audio, AirPlay, and Picture in Picture background mode added to `UIBackgroundModes`
350
+ - `allowedSubtitleOptionLanguages`, `requiresFullSubtitles` and the delegate
351
+ callback for media selection exist only on tvOS. On iOS, select within the item's
352
+ `.legible` group as above.
353
+ - HLS carries subtitles and captions in its manifests, and AVKit reads them
354
+ from the `AVAsset`'s `AVMediaSelectionGroup`.
355
+ - Local files need the legible tracks already inside the file, or authored
356
+ into the asset.
357
+
358
+ ## Common mistakes
359
+
360
+ - **Subclassing `AVPlayerViewController`.** Apple does not support it and it
361
+ can break on a future OS. Compose it and use the delegate.
362
+ - **Leaving the default audio session.** PiP will not work. Set
363
+ `.playback` with `.moviePlayback`, and activate when playback begins.
364
+ - **No PiP restore handler, or no `completionHandler(true)`.** Without the
365
+ handler the user cannot get back to the player; without the completion call
366
+ the restore does nothing or the animation hangs.
367
+ - **`AVPlayer` as a stored property of a SwiftUI view.** It is recreated every
368
+ time the view value is rebuilt. Hold an optional in `@State` and create it in
369
+ `.task`.
370
+
371
+ ## Review checklist
372
+
373
+ - [ ] Audio session is `.playback` with `.moviePlayback`
374
+ - [ ] The session is activated only when playback starts
375
+ - [ ] `UIBackgroundModes` contains `audio`
473
376
  - [ ] `AVPlayerViewController` is not subclassed
474
- - [ ] PiP tested with supported video media, not only app/device setup
475
- - [ ] PiP restore delegate method implemented and calls `completionHandler(true)`
476
- - [ ] Custom PiP checks both device support and current `isPictureInPicturePossible`
477
- - [ ] Custom PiP starts only from explicit user interaction
478
- - [ ] `AVPlayer` deferred to `.task` in SwiftUI (not created eagerly)
479
- - [ ] `canStartPictureInPictureAutomaticallyFromInline` set for inline players
480
- - [ ] `requiresLinearPlayback` toggled only during required ad/legal segments
481
- - [ ] tvOS-only skipping APIs are not used for iOS transport controls
482
- - [ ] External playback is not disabled accidentally when AirPlay is required
483
- - [ ] Subtitle selection tested with actual media tracks
484
- - [ ] Video gravity set appropriately (`.resizeAspect` vs `.resizeAspectFill`)
485
- - [ ] `isReadyForDisplay` observed before showing the player view
486
- - [ ] Error handling for network-streamed content (HLS failures, timeouts)
377
+ - [ ] PiP was tried with real, supported video media
378
+ - [ ] The PiP restore delegate method exists and calls `completionHandler(true)`
379
+ - [ ] Custom PiP checks device support and `isPictureInPicturePossible`
380
+ - [ ] Custom PiP starts only from an explicit user action
381
+ - [ ] SwiftUI creates the `AVPlayer` in `.task`
382
+ - [ ] Inline players set `canStartPictureInPictureAutomaticallyFromInline`
383
+ - [ ] `requiresLinearPlayback` is `true` only while a mandatory ad or legal notice plays
384
+ - [ ] tvOS-only skipping APIs are absent from iOS code
385
+ - [ ] External playback is not switched off where AirPlay is expected
386
+ - [ ] Subtitle selection was tested with media that has real text tracks
387
+ - [ ] `videoGravity` suits the content
388
+ - [ ] `isReadyForDisplay` gates when the player appears
389
+ - [ ] Streaming errors (HLS failures, timeouts) are handled
487
390
 
488
391
  ## References
489
392
 
490
- - Advanced patterns (custom player UI, interstitials, background playback, error handling): [references/avkit-patterns.md](references/avkit-patterns.md)
491
- - [AVKit framework](https://sosumi.ai/documentation/avkit)
492
- - [AVPlayerViewController](https://sosumi.ai/documentation/avkit/avplayerviewcontroller)
493
- - [VideoPlayer (SwiftUI)](https://sosumi.ai/documentation/avkit/videoplayer)
494
- - [AVPictureInPictureController](https://sosumi.ai/documentation/avkit/avpictureinpicturecontroller)
495
- - [AVRoutePickerView](https://sosumi.ai/documentation/avkit/avroutepickerview)
496
- - [AVPlaybackSpeed](https://sosumi.ai/documentation/avkit/avplaybackspeed)
497
- - [Configuring your app for media playback](https://sosumi.ai/documentation/avfoundation/configuring-your-app-for-media-playback)
498
- - [Adopting Picture in Picture in a Standard Player](https://sosumi.ai/documentation/avkit/adopting-picture-in-picture-in-a-standard-player)
499
- - [Playing video content in a standard user interface](https://sosumi.ai/documentation/avkit/playing-video-content-in-a-standard-user-interface)
393
+ - [AVKit patterns](references/avkit-patterns.md) - custom AVPlayerLayer player with PiP, sample-buffer PiP, interstitials, background playback, errors, playback observation, frame analysis, HDR, SwiftUI player model, representable wrapper
394
+ - [AVKit](https://developer.apple.com/documentation/avkit)
395
+ - [AVPlayerViewController](https://developer.apple.com/documentation/avkit/avplayerviewcontroller)
396
+ - [VideoPlayer](https://developer.apple.com/documentation/avkit/videoplayer)
397
+ - [AVPictureInPictureController](https://developer.apple.com/documentation/avkit/avpictureinpicturecontroller)
398
+ - [AVRoutePickerView](https://developer.apple.com/documentation/avkit/avroutepickerview)
399
+ - [AVPlaybackSpeed](https://developer.apple.com/documentation/avkit/avplaybackspeed)
400
+ - [Apple guide: media playback configuration](https://developer.apple.com/documentation/avfoundation/configuring-your-app-for-media-playback)
401
+ - [Apple guide: PiP in the standard player](https://developer.apple.com/documentation/avkit/adopting-picture-in-picture-in-a-standard-player)
402
+ - [Apple guide: video in the standard interface](https://developer.apple.com/documentation/avkit/playing-video-content-in-a-standard-user-interface)