buildanything 1.7.0 → 1.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 (222) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +55 -0
  4. package/README.md +71 -61
  5. package/agents/ios-app-review-guardian.md +49 -0
  6. package/agents/ios-foundation-models-specialist.md +46 -0
  7. package/agents/ios-storekit-specialist.md +52 -0
  8. package/agents/ios-swift-architect.md +102 -0
  9. package/agents/ios-swift-search.md +130 -0
  10. package/agents/ios-swift-ui-design.md +104 -0
  11. package/commands/build.md +80 -176
  12. package/commands/fix.md +65 -0
  13. package/commands/setup.md +73 -0
  14. package/commands/ux-review.md +63 -0
  15. package/commands/verify.md +72 -0
  16. package/hooks/session-start +18 -1
  17. package/package.json +5 -2
  18. package/protocols/brainstorm.md +99 -0
  19. package/protocols/build-fix.md +52 -0
  20. package/protocols/cleanup.md +54 -0
  21. package/protocols/design.md +269 -0
  22. package/protocols/eval-harness.md +61 -0
  23. package/protocols/fake-data-detector.md +64 -0
  24. package/protocols/ios-context.md +235 -0
  25. package/protocols/ios-frameworks-map.md +323 -0
  26. package/protocols/ios-phase-branches.md +162 -0
  27. package/protocols/ios-preflight.md +27 -0
  28. package/protocols/metric-loop.md +93 -0
  29. package/protocols/planning.md +87 -0
  30. package/protocols/smoke-test.md +110 -0
  31. package/protocols/verify.md +67 -0
  32. package/protocols/web-phase-branches.md +201 -0
  33. package/skills/ios/_VENDORED.md +60 -0
  34. package/skills/ios/activitykit/LICENSE +131 -0
  35. package/skills/ios/activitykit/SKILL.md +505 -0
  36. package/skills/ios/activitykit/references/activitykit-patterns.md +868 -0
  37. package/skills/ios/app-intents/LICENSE +131 -0
  38. package/skills/ios/app-intents/SKILL.md +494 -0
  39. package/skills/ios/app-intents/references/appintents-advanced.md +1076 -0
  40. package/skills/ios/apple-on-device-ai/LICENSE +131 -0
  41. package/skills/ios/apple-on-device-ai/SKILL.md +505 -0
  42. package/skills/ios/apple-on-device-ai/references/coreml-conversion.md +425 -0
  43. package/skills/ios/apple-on-device-ai/references/coreml-optimization.md +344 -0
  44. package/skills/ios/apple-on-device-ai/references/foundation-models.md +508 -0
  45. package/skills/ios/apple-on-device-ai/references/mlx-swift.md +285 -0
  46. package/skills/ios/ios-26-platform/SKILL.md +53 -0
  47. package/skills/ios/ios-26-platform/references/automatic-adoption.md +161 -0
  48. package/skills/ios/ios-26-platform/references/backward-compat.md +238 -0
  49. package/skills/ios/ios-26-platform/references/liquid-glass.md +255 -0
  50. package/skills/ios/ios-26-platform/references/swiftui-apis.md +277 -0
  51. package/skills/ios/ios-26-platform/references/toolbar-navigation.md +250 -0
  52. package/skills/ios/ios-bootstrap/SKILL.md +98 -0
  53. package/skills/ios/ios-bootstrap/references/apple-docs-mcp-config.md +28 -0
  54. package/skills/ios/ios-bootstrap/references/new-project-dialog.md +41 -0
  55. package/skills/ios/ios-bootstrap/references/xcode-mcp-config.md +29 -0
  56. package/skills/ios/ios-debugger-agent/LICENSE +21 -0
  57. package/skills/ios/ios-debugger-agent/SKILL.md +58 -0
  58. package/skills/ios/ios-debugger-agent/agents/openai.yaml +4 -0
  59. package/skills/ios/ios-entitlements-generator/SKILL.md +47 -0
  60. package/skills/ios/ios-hig/SKILL.md +41 -0
  61. package/skills/ios/ios-hig/references/accessibility.md +81 -0
  62. package/skills/ios/ios-hig/references/content.md +142 -0
  63. package/skills/ios/ios-hig/references/feedback.md +123 -0
  64. package/skills/ios/ios-hig/references/interaction.md +199 -0
  65. package/skills/ios/ios-hig/references/performance-platform.md +129 -0
  66. package/skills/ios/ios-hig/references/privacy-permissions.md +181 -0
  67. package/skills/ios/ios-hig/references/visual-design.md +84 -0
  68. package/skills/ios/ios-info-plist-hardening/SKILL.md +130 -0
  69. package/skills/ios/ios-maestro-flow-author/SKILL.md +68 -0
  70. package/skills/ios/ios-maestro-flow-author/references/input-and-scroll.yaml +17 -0
  71. package/skills/ios/ios-maestro-flow-author/references/modal-and-dismiss.yaml +14 -0
  72. package/skills/ios/ios-maestro-flow-author/references/onboarding-flow.yaml +16 -0
  73. package/skills/ios/ios-maestro-flow-author/references/tab-navigation.yaml +13 -0
  74. package/skills/ios/ios-maestro-flow-author/references/tap-and-assert.yaml +9 -0
  75. package/skills/ios/swift-accessibility/LICENSE +21 -0
  76. package/skills/ios/swift-accessibility/SKILL.md +371 -0
  77. package/skills/ios/swift-accessibility/examples/before-after-appkit.md +446 -0
  78. package/skills/ios/swift-accessibility/examples/before-after-swiftui.md +441 -0
  79. package/skills/ios/swift-accessibility/examples/before-after-uikit.md +464 -0
  80. package/skills/ios/swift-accessibility/references/assistive-access.md +441 -0
  81. package/skills/ios/swift-accessibility/references/display-settings.md +491 -0
  82. package/skills/ios/swift-accessibility/references/dynamic-type.md +420 -0
  83. package/skills/ios/swift-accessibility/references/media-accessibility.md +421 -0
  84. package/skills/ios/swift-accessibility/references/motor-input.md +393 -0
  85. package/skills/ios/swift-accessibility/references/nutrition-labels.md +362 -0
  86. package/skills/ios/swift-accessibility/references/platform-specifics.md +515 -0
  87. package/skills/ios/swift-accessibility/references/semantic-structure.md +585 -0
  88. package/skills/ios/swift-accessibility/references/testing-auditing.md +507 -0
  89. package/skills/ios/swift-accessibility/references/voice-control.md +317 -0
  90. package/skills/ios/swift-accessibility/references/voiceover-swiftui.md +584 -0
  91. package/skills/ios/swift-accessibility/references/voiceover-uikit.md +519 -0
  92. package/skills/ios/swift-accessibility/references/wcag-mapping.md +167 -0
  93. package/skills/ios/swift-accessibility/resources/audit-template.swift +128 -0
  94. package/skills/ios/swift-accessibility/resources/qa-checklist.md +258 -0
  95. package/skills/ios/swift-concurrency/LICENSE +21 -0
  96. package/skills/ios/swift-concurrency/SKILL.md +171 -0
  97. package/skills/ios/swift-concurrency/references/_index.md +50 -0
  98. package/skills/ios/swift-concurrency/references/actors.md +660 -0
  99. package/skills/ios/swift-concurrency/references/async-algorithms.md +847 -0
  100. package/skills/ios/swift-concurrency/references/async-await-basics.md +266 -0
  101. package/skills/ios/swift-concurrency/references/async-sequences.md +710 -0
  102. package/skills/ios/swift-concurrency/references/core-data.md +560 -0
  103. package/skills/ios/swift-concurrency/references/glossary.md +135 -0
  104. package/skills/ios/swift-concurrency/references/linting.md +155 -0
  105. package/skills/ios/swift-concurrency/references/memory-management.md +569 -0
  106. package/skills/ios/swift-concurrency/references/migration.md +1104 -0
  107. package/skills/ios/swift-concurrency/references/performance.md +593 -0
  108. package/skills/ios/swift-concurrency/references/sendable.md +598 -0
  109. package/skills/ios/swift-concurrency/references/tasks.md +636 -0
  110. package/skills/ios/swift-concurrency/references/testing.md +592 -0
  111. package/skills/ios/swift-concurrency/references/threading.md +495 -0
  112. package/skills/ios/swift-security-expert/LICENSE +21 -0
  113. package/skills/ios/swift-security-expert/SKILL.md +470 -0
  114. package/skills/ios/swift-security-expert/references/biometric-authentication.md +565 -0
  115. package/skills/ios/swift-security-expert/references/certificate-trust.md +592 -0
  116. package/skills/ios/swift-security-expert/references/common-anti-patterns.md +690 -0
  117. package/skills/ios/swift-security-expert/references/compliance-owasp-mapping.md +537 -0
  118. package/skills/ios/swift-security-expert/references/credential-storage-patterns.md +721 -0
  119. package/skills/ios/swift-security-expert/references/cryptokit-public-key.md +505 -0
  120. package/skills/ios/swift-security-expert/references/cryptokit-symmetric.md +497 -0
  121. package/skills/ios/swift-security-expert/references/keychain-access-control.md +508 -0
  122. package/skills/ios/swift-security-expert/references/keychain-fundamentals.md +596 -0
  123. package/skills/ios/swift-security-expert/references/keychain-item-classes.md +476 -0
  124. package/skills/ios/swift-security-expert/references/keychain-sharing.md +458 -0
  125. package/skills/ios/swift-security-expert/references/migration-legacy-stores.md +727 -0
  126. package/skills/ios/swift-security-expert/references/secure-enclave.md +539 -0
  127. package/skills/ios/swift-security-expert/references/testing-security-code.md +781 -0
  128. package/skills/ios/swift-testing-expert/LICENSE +21 -0
  129. package/skills/ios/swift-testing-expert/SKILL.md +79 -0
  130. package/skills/ios/swift-testing-expert/references/_index.md +12 -0
  131. package/skills/ios/swift-testing-expert/references/async-testing-and-waiting.md +127 -0
  132. package/skills/ios/swift-testing-expert/references/expectations.md +145 -0
  133. package/skills/ios/swift-testing-expert/references/fundamentals.md +141 -0
  134. package/skills/ios/swift-testing-expert/references/migration-from-xctest.md +127 -0
  135. package/skills/ios/swift-testing-expert/references/parallelization-and-isolation.md +95 -0
  136. package/skills/ios/swift-testing-expert/references/parameterized-testing.md +284 -0
  137. package/skills/ios/swift-testing-expert/references/performance-and-best-practices.md +187 -0
  138. package/skills/ios/swift-testing-expert/references/traits-and-tags.md +114 -0
  139. package/skills/ios/swift-testing-expert/references/xcode-workflows.md +70 -0
  140. package/skills/ios/swiftdata-pro/LICENSE +21 -0
  141. package/skills/ios/swiftdata-pro/SKILL.md +102 -0
  142. package/skills/ios/swiftdata-pro/agents/openai.yaml +10 -0
  143. package/skills/ios/swiftdata-pro/assets/swiftdata-pro-icon.png +0 -0
  144. package/skills/ios/swiftdata-pro/assets/swiftdata-pro-icon.svg +29 -0
  145. package/skills/ios/swiftdata-pro/references/class-inheritance.md +104 -0
  146. package/skills/ios/swiftdata-pro/references/cloudkit.md +10 -0
  147. package/skills/ios/swiftdata-pro/references/core-rules.md +20 -0
  148. package/skills/ios/swiftdata-pro/references/indexing.md +27 -0
  149. package/skills/ios/swiftdata-pro/references/predicates.md +73 -0
  150. package/skills/ios/swiftui-design-principles/AGENTS.md +21 -0
  151. package/skills/ios/swiftui-design-principles/LICENSE +21 -0
  152. package/skills/ios/swiftui-design-principles/README.md +41 -0
  153. package/skills/ios/swiftui-design-principles/SKILL.md +605 -0
  154. package/skills/ios/swiftui-design-principles/metadata.json +10 -0
  155. package/skills/ios/swiftui-liquid-glass/LICENSE +21 -0
  156. package/skills/ios/swiftui-liquid-glass/SKILL.md +95 -0
  157. package/skills/ios/swiftui-liquid-glass/agents/openai.yaml +4 -0
  158. package/skills/ios/swiftui-liquid-glass/references/liquid-glass.md +280 -0
  159. package/skills/ios/swiftui-performance-audit/LICENSE +21 -0
  160. package/skills/ios/swiftui-performance-audit/SKILL.md +111 -0
  161. package/skills/ios/swiftui-performance-audit/agents/openai.yaml +4 -0
  162. package/skills/ios/swiftui-performance-audit/references/code-smells.md +150 -0
  163. package/skills/ios/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +46 -0
  164. package/skills/ios/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +29 -0
  165. package/skills/ios/swiftui-performance-audit/references/profiling-intake.md +44 -0
  166. package/skills/ios/swiftui-performance-audit/references/report-template.md +47 -0
  167. package/skills/ios/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +33 -0
  168. package/skills/ios/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +52 -0
  169. package/skills/ios/swiftui-pro/LICENSE +21 -0
  170. package/skills/ios/swiftui-pro/SKILL.md +108 -0
  171. package/skills/ios/swiftui-pro/agents/openai.yaml +10 -0
  172. package/skills/ios/swiftui-pro/assets/swiftui-pro-icon.png +0 -0
  173. package/skills/ios/swiftui-pro/assets/swiftui-pro-icon.svg +29 -0
  174. package/skills/ios/swiftui-pro/references/accessibility.md +13 -0
  175. package/skills/ios/swiftui-pro/references/api.md +39 -0
  176. package/skills/ios/swiftui-pro/references/data.md +43 -0
  177. package/skills/ios/swiftui-pro/references/design.md +31 -0
  178. package/skills/ios/swiftui-pro/references/hygiene.md +9 -0
  179. package/skills/ios/swiftui-pro/references/navigation.md +14 -0
  180. package/skills/ios/swiftui-pro/references/performance.md +46 -0
  181. package/skills/ios/swiftui-pro/references/swift.md +56 -0
  182. package/skills/ios/swiftui-pro/references/views.md +35 -0
  183. package/skills/ios/swiftui-ui-patterns/LICENSE +21 -0
  184. package/skills/ios/swiftui-ui-patterns/SKILL.md +100 -0
  185. package/skills/ios/swiftui-ui-patterns/agents/openai.yaml +4 -0
  186. package/skills/ios/swiftui-ui-patterns/references/app-wiring.md +201 -0
  187. package/skills/ios/swiftui-ui-patterns/references/async-state.md +96 -0
  188. package/skills/ios/swiftui-ui-patterns/references/components-index.md +50 -0
  189. package/skills/ios/swiftui-ui-patterns/references/controls.md +57 -0
  190. package/skills/ios/swiftui-ui-patterns/references/deeplinks.md +66 -0
  191. package/skills/ios/swiftui-ui-patterns/references/focus.md +90 -0
  192. package/skills/ios/swiftui-ui-patterns/references/form.md +97 -0
  193. package/skills/ios/swiftui-ui-patterns/references/grids.md +71 -0
  194. package/skills/ios/swiftui-ui-patterns/references/haptics.md +71 -0
  195. package/skills/ios/swiftui-ui-patterns/references/input-toolbar.md +51 -0
  196. package/skills/ios/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
  197. package/skills/ios/swiftui-ui-patterns/references/list.md +86 -0
  198. package/skills/ios/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
  199. package/skills/ios/swiftui-ui-patterns/references/macos-settings.md +71 -0
  200. package/skills/ios/swiftui-ui-patterns/references/matched-transitions.md +59 -0
  201. package/skills/ios/swiftui-ui-patterns/references/media.md +73 -0
  202. package/skills/ios/swiftui-ui-patterns/references/menu-bar.md +101 -0
  203. package/skills/ios/swiftui-ui-patterns/references/navigationstack.md +159 -0
  204. package/skills/ios/swiftui-ui-patterns/references/overlay.md +45 -0
  205. package/skills/ios/swiftui-ui-patterns/references/performance.md +62 -0
  206. package/skills/ios/swiftui-ui-patterns/references/previews.md +48 -0
  207. package/skills/ios/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
  208. package/skills/ios/swiftui-ui-patterns/references/scrollview.md +87 -0
  209. package/skills/ios/swiftui-ui-patterns/references/searchable.md +71 -0
  210. package/skills/ios/swiftui-ui-patterns/references/sheets.md +155 -0
  211. package/skills/ios/swiftui-ui-patterns/references/split-views.md +72 -0
  212. package/skills/ios/swiftui-ui-patterns/references/tabview.md +114 -0
  213. package/skills/ios/swiftui-ui-patterns/references/theming.md +71 -0
  214. package/skills/ios/swiftui-ui-patterns/references/title-menus.md +93 -0
  215. package/skills/ios/swiftui-ui-patterns/references/top-bar.md +49 -0
  216. package/skills/ios/swiftui-view-refactor/LICENSE +21 -0
  217. package/skills/ios/swiftui-view-refactor/SKILL.md +207 -0
  218. package/skills/ios/swiftui-view-refactor/agents/openai.yaml +4 -0
  219. package/skills/ios/swiftui-view-refactor/references/mv-patterns.md +161 -0
  220. package/skills/ios/widgetkit/LICENSE +131 -0
  221. package/skills/ios/widgetkit/SKILL.md +502 -0
  222. package/skills/ios/widgetkit/references/widgetkit-advanced.md +871 -0
@@ -0,0 +1,266 @@
1
+ # Async/Await Basics
2
+
3
+ Use this when:
4
+
5
+ - You are starting fresh with async/await and need foundational patterns.
6
+ - You are converting callback-based code to async/await.
7
+ - You need to understand execution order and the sync-to-async bridge.
8
+
9
+ Skip this file if:
10
+
11
+ - You need parallel execution with task groups or `async let`. Use `tasks.md`.
12
+ - You need stream-based async iteration. Use `async-sequences.md`.
13
+
14
+ Jump to:
15
+
16
+ - Function Declaration
17
+ - Execution Order
18
+ - Parallel Execution with async let
19
+ - URLSession with Async/Await
20
+ - Migration Strategy
21
+
22
+ ## Function Declaration
23
+
24
+ Mark functions with `async` to indicate asynchronous work:
25
+
26
+ ```swift
27
+ func fetchData() async -> Data {
28
+ // async work
29
+ }
30
+
31
+ func fetchData() async throws -> Data {
32
+ // async work that can fail
33
+ }
34
+ ```
35
+
36
+ **Key benefit over closures**: The compiler enforces return values. No forgotten completion handlers.
37
+
38
+ > **Course Deep Dive**: This topic is covered in detail in [Lesson 2.1: Introduction to async/await syntax](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=lesson-reference)
39
+
40
+ ## Calling Async Functions
41
+
42
+ ### From synchronous context
43
+
44
+ Use `Task` to bridge from sync to async:
45
+
46
+ ```swift
47
+ Task {
48
+ let data = try await fetchData()
49
+ }
50
+ ```
51
+
52
+ ### From async context
53
+
54
+ Use `await` directly:
55
+
56
+ ```swift
57
+ func processData() async throws {
58
+ let data = try await fetchData()
59
+ // process data
60
+ }
61
+ ```
62
+
63
+ ## Execution Order
64
+
65
+ Structured concurrency executes top-to-bottom in the order you expect:
66
+
67
+ ```swift
68
+ let first = try await fetchData(1) // Waits for completion
69
+ let second = try await fetchData(2) // Starts after first completes
70
+ let third = try await fetchData(3) // Starts after second completes
71
+ ```
72
+
73
+ Code after `await` only executes once the awaited function returns.
74
+
75
+ > **Course Deep Dive**: This topic is covered in detail in [Lesson 2.2: Understanding the order of execution](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=lesson-reference)
76
+
77
+ ## Parallel Execution with async let
78
+
79
+ Use `async let` to run multiple operations concurrently:
80
+
81
+ ```swift
82
+ async let data1 = fetchData(1)
83
+ async let data2 = fetchData(2)
84
+ async let data3 = fetchData(3)
85
+
86
+ let results = try await [data1, data2, data3]
87
+ ```
88
+
89
+ ### How async let works
90
+
91
+ - **Starts immediately**: The function executes right away, even before `await`
92
+ - **Structured concurrency**: Automatically canceled when leaving scope
93
+ - **Error handling**: If one fails, others are implicitly canceled when awaiting grouped results
94
+ - **No redundant keywords**: Don't use `try await` in the `async let` line itself
95
+
96
+ ```swift
97
+ // Redundant - avoid this
98
+ async let data = try await fetchData()
99
+
100
+ // Correct - errors handled at await point
101
+ async let data = fetchData()
102
+ let result = try await data
103
+ ```
104
+
105
+ ### When to use async let
106
+
107
+ **Use when:**
108
+ - Tasks don't depend on each other
109
+ - Number of tasks known at compile-time
110
+ - Want automatic cancellation on scope exit
111
+
112
+ **Avoid when:**
113
+ - Tasks must run sequentially
114
+ - Need dynamic task spawning (use `TaskGroup`)
115
+ - Need manual cancellation control
116
+
117
+ ### Limitations
118
+
119
+ - Cannot use at top-level declarations (only within function bodies)
120
+ - Tasks not explicitly awaited may be canceled implicitly
121
+
122
+ > **Course Deep Dive**: This topic is covered in detail in [Lesson 2.3: Calling async functions in parallel using async let](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=lesson-reference)
123
+
124
+ ## URLSession with Async/Await
125
+
126
+ URLSession provides async alternatives to closure-based APIs:
127
+
128
+ ```swift
129
+ // Closure-based (old)
130
+ URLSession.shared.dataTask(with: request) { data, response, error in
131
+ guard let data = data, error == nil else { return }
132
+ // handle response
133
+ }.resume()
134
+
135
+ // Async/await (modern)
136
+ let (data, response) = try await URLSession.shared.data(for: request)
137
+ ```
138
+
139
+ ### Benefits over closures
140
+
141
+ - No optional `data` or `response` to unwrap
142
+ - Automatic error throwing
143
+ - Compiler enforces return values
144
+ - Simpler error handling with do-catch
145
+
146
+ ### Complete network request pattern
147
+
148
+ ```swift
149
+ func fetchUser(id: Int) async throws -> User {
150
+ let url = URL(string: "https://api.example.com/users/\(id)")!
151
+ var request = URLRequest(url: url)
152
+ request.httpMethod = "GET"
153
+
154
+ let (data, response) = try await URLSession.shared.data(for: request)
155
+
156
+ guard let httpResponse = response as? HTTPURLResponse,
157
+ (200...299).contains(httpResponse.statusCode) else {
158
+ throw NetworkError.invalidResponse
159
+ }
160
+
161
+ return try JSONDecoder().decode(User.self, from: data)
162
+ }
163
+ ```
164
+
165
+ ### POST requests with JSON
166
+
167
+ ```swift
168
+ func createUser(_ user: User) async throws -> User {
169
+ let url = URL(string: "https://api.example.com/users")!
170
+ var request = URLRequest(url: url)
171
+ request.httpMethod = "POST"
172
+ request.setValue("application/json", forHTTPHeaderField: "Content-Type")
173
+ request.httpBody = try JSONEncoder().encode(user)
174
+
175
+ let (data, response) = try await URLSession.shared.data(for: request)
176
+
177
+ guard let httpResponse = response as? HTTPURLResponse,
178
+ (200...299).contains(httpResponse.statusCode) else {
179
+ throw NetworkError.invalidResponse
180
+ }
181
+
182
+ return try JSONDecoder().decode(User.self, from: data)
183
+ }
184
+ ```
185
+
186
+ > **Course Deep Dive**: This topic is covered in detail in [Lesson 2.4: Performing network requests using URLSession and async/await](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=lesson-reference)
187
+
188
+ ## Typed Errors (Swift 6)
189
+
190
+ Specify exact error types for better API contracts:
191
+
192
+ ```swift
193
+ enum NetworkError: Error {
194
+ case invalidResponse
195
+ case decodingFailed(DecodingError)
196
+ case requestFailed(URLError)
197
+ }
198
+
199
+ func fetchData() async throws(NetworkError) -> Data {
200
+ do {
201
+ let (data, _) = try await URLSession.shared.data(from: url)
202
+ return data
203
+ } catch let error as URLError {
204
+ throw .requestFailed(error)
205
+ } catch {
206
+ throw .invalidResponse
207
+ }
208
+ }
209
+ ```
210
+
211
+ Callers know exactly which errors to handle.
212
+
213
+ ## Migration Strategy
214
+
215
+ When converting closure-based code:
216
+
217
+ 1. **Add new async method alongside old one** - keeps code compiling
218
+ 2. **Update method signature** - add `async`, remove completion parameter
219
+ 3. **Replace closure calls with await** - use URLSession async APIs
220
+ 4. **Remove optional unwrapping** - async APIs return non-optional values
221
+ 5. **Simplify error handling** - use do-catch instead of nested closures
222
+ 6. **Return directly** - compiler enforces return values
223
+
224
+ ## Common Patterns
225
+
226
+ ### Sequential execution (when order matters)
227
+
228
+ ```swift
229
+ let user = try await fetchUser(id: 1)
230
+ let posts = try await fetchPosts(userId: user.id)
231
+ let comments = try await fetchComments(postIds: posts.map(\.id))
232
+ ```
233
+
234
+ ### Parallel execution (when independent)
235
+
236
+ ```swift
237
+ async let user = fetchUser(id: 1)
238
+ async let settings = fetchSettings()
239
+ async let notifications = fetchNotifications()
240
+
241
+ let (userData, settingsData, notificationsData) = try await (user, settings, notifications)
242
+ ```
243
+
244
+ ### Mixed execution
245
+
246
+ ```swift
247
+ // Fetch user first (required for next step)
248
+ let user = try await fetchUser(id: 1)
249
+
250
+ // Then fetch related data in parallel
251
+ async let posts = fetchPosts(userId: user.id)
252
+ async let followers = fetchFollowers(userId: user.id)
253
+ async let following = fetchFollowing(userId: user.id)
254
+
255
+ let profile = Profile(
256
+ user: user,
257
+ posts: try await posts,
258
+ followers: try await followers,
259
+ following: try await following
260
+ )
261
+ ```
262
+
263
+ ## Further Learning
264
+
265
+ For in-depth coverage of async/await patterns, error handling strategies, and real-world migration scenarios, see [Swift Concurrency Course](https://www.swiftconcurrencycourse.com).
266
+