@devo-bmad-custom/agent-orchestration 1.0.4 → 1.0.6
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.
- package/package.json +1 -1
- package/src/.agents/skills/tmux-commands/SKILL.md +353 -0
- package/src/bmm/data/project-context-template.md +26 -26
- package/src/bmm/teams/default-party.csv +20 -20
- package/src/bmm/workflows/2-plan-workflows/create-prd/data/domain-complexity.csv +14 -14
- package/src/bmm/workflows/2-plan-workflows/create-prd/data/prd-purpose.md +197 -197
- package/src/bmm/workflows/2-plan-workflows/create-prd/data/project-types.csv +10 -10
- package/src/bmm/workflows/2-plan-workflows/create-prd/templates/prd-template.md +10 -10
- package/src/bmm/workflows/3-solutioning/create-architecture/data/domain-complexity.csv +12 -12
- package/src/bmm/workflows/4-implementation/code-review/instructions.xml +226 -226
- package/src/bmm/workflows/4-implementation/correct-course/checklist.md +288 -288
- package/src/bmm/workflows/4-implementation/correct-course/instructions.md +207 -207
- package/src/bmm/workflows/4-implementation/retrospective/instructions.md +1444 -1444
- package/src/bmm/workflows/4-implementation/sprint-planning/sprint-status-template.yaml +55 -55
- package/src/bmm/workflows/4-implementation/sprint-status/instructions.md +230 -230
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/tech-spec-template.md +74 -74
- package/src/bmm/workflows/document-project/instructions.md +130 -130
- package/src/bmm/workflows/document-project/templates/project-scan-report-schema.json +160 -160
- package/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +298 -298
- package/src/bmm/workflows/document-project/workflows/deep-dive.yaml +31 -31
- package/src/bmm/workflows/document-project/workflows/full-scan-instructions.md +1106 -1106
- package/src/bmm/workflows/document-project/workflows/full-scan.yaml +31 -31
- package/src/bmm/workflows/qa-generate-e2e-tests/checklist.md +33 -33
- package/src/bmm/workflows/qa-generate-e2e-tests/instructions.md +110 -110
- package/src/core/agents/bmad-master.md +56 -56
- package/src/core/workflows/party-mode/steps/step-02-discussion-orchestration.md +187 -187
- package/src/core/workflows/party-mode/steps/step-03-graceful-exit.md +168 -168
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/SKILL.md +0 -475
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/references/vision-requests.md +0 -736
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/references/visionkit-scanner.md +0 -738
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/weatherkit/SKILL.md +0 -410
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/weatherkit/references/weatherkit-patterns.md +0 -567
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/widgetkit/SKILL.md +0 -497
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/widgetkit/references/widgetkit-advanced.md +0 -871
- package/src/.agents/skills/ui-ux-pro-custom/data/typography.csv +0 -58
- package/src/.agents/skills/ui-ux-pro-custom/data/ui-reasoning.csv +0 -101
- package/src/.agents/skills/ui-ux-pro-custom/data/ux-guidelines.csv +0 -100
- package/src/.agents/skills/ui-ux-pro-custom/data/web-interface.csv +0 -31
- package/src/.agents/skills/ui-ux-pro-custom/scripts/core.py +0 -253
- package/src/.agents/skills/ui-ux-pro-custom/scripts/design_system.py +0 -1067
- package/src/.agents/skills/ui-ux-pro-custom/scripts/search.py +0 -114
- package/src/.agents/skills/ux-audit/SKILL.md +0 -151
- package/src/.agents/skills/websocket-engineer/SKILL.md +0 -168
- package/src/.agents/skills/websocket-engineer/references/alternatives.md +0 -391
- package/src/.agents/skills/websocket-engineer/references/patterns.md +0 -400
- package/src/.agents/skills/websocket-engineer/references/protocol.md +0 -195
- package/src/.agents/skills/websocket-engineer/references/scaling.md +0 -333
- package/src/.agents/skills/websocket-engineer/references/security.md +0 -474
- package/src/.agents/skills/writing-skills/SKILL.md +0 -655
- package/src/.agents/skills/writing-skills/anthropic-best-practices.md +0 -1150
- package/src/.agents/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
- package/src/.agents/skills/writing-skills/graphviz-conventions.dot +0 -172
- package/src/.agents/skills/writing-skills/persuasion-principles.md +0 -187
- package/src/.agents/skills/writing-skills/render-graphs.js +0 -168
- package/src/.agents/skills/writing-skills/testing-skills-with-subagents.md +0 -384
- package/src/.claude/commands/bmad-track-compact.md +0 -19
- package/src/.claude/commands/bmad-track-extended.md +0 -19
- package/src/.claude/commands/bmad-track-large.md +0 -19
- package/src/.claude/commands/bmad-track-medium.md +0 -19
- package/src/.claude/commands/bmad-track-nano.md +0 -19
- package/src/.claude/commands/bmad-track-rv.md +0 -18
- package/src/.claude/commands/bmad-track-small.md +0 -19
- package/src/.claude/commands/master-orchestrator.md +0 -15
- package/src/_memory/master-orchestrator-sidecar/docs-index.md +0 -3
- package/src/_memory/master-orchestrator-sidecar/instructions.md +0 -2616
- package/src/_memory/master-orchestrator-sidecar/memories.md +0 -8
- package/src/_memory/master-orchestrator-sidecar/session-state.md +0 -15
- package/src/_memory/master-orchestrator-sidecar/triage-history.md +0 -3
- package/src/_memory/master-orchestrator-sidecar/workflows-overview.html +0 -1230
- package/src/core/agents/master-orchestrator.md +0 -54
- package/src/docs/dev/tmux/actions_popup.py +0 -291
- package/src/docs/dev/tmux/actions_popup.sh +0 -110
- package/src/docs/dev/tmux/claude_usage.sh +0 -15
- package/src/docs/dev/tmux/colors.conf +0 -26
- package/src/docs/dev/tmux/cpu_usage.sh +0 -7
- package/src/docs/dev/tmux/dispatch.sh +0 -10
- package/src/docs/dev/tmux/float_init.sh +0 -13
- package/src/docs/dev/tmux/float_term.sh +0 -23
- package/src/docs/dev/tmux/open_clip.sh +0 -14
- package/src/docs/dev/tmux/paste_clipboard.sh +0 -13
- package/src/docs/dev/tmux/paste_image_wrapper.sh +0 -94
- package/src/docs/dev/tmux/ram_usage.sh +0 -3
- package/src/docs/dev/tmux/title_sync.sh +0 -54
- package/src/docs/dev/tmux/tmux-setup.md +0 -867
- package/src/docs/dev/tmux/tmux.conf +0 -127
- package/src/docs/dev/tmux/xclip +0 -18
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: weatherkit
|
|
3
|
-
description: "Fetch current, hourly, and daily weather forecasts and display required attribution using WeatherKit. Use when integrating weather data, showing forecasts, handling weather alerts, displaying Apple Weather attribution, or querying historical weather statistics in iOS apps."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# WeatherKit
|
|
7
|
-
|
|
8
|
-
Fetch current conditions, hourly and daily forecasts, weather alerts, and
|
|
9
|
-
historical statistics using `WeatherService`. Display required Apple Weather
|
|
10
|
-
attribution. Targets Swift 6.2 / iOS 26+.
|
|
11
|
-
|
|
12
|
-
## Contents
|
|
13
|
-
|
|
14
|
-
- [Setup](#setup)
|
|
15
|
-
- [Fetching Current Weather](#fetching-current-weather)
|
|
16
|
-
- [Forecasts](#forecasts)
|
|
17
|
-
- [Weather Alerts](#weather-alerts)
|
|
18
|
-
- [Selective Queries](#selective-queries)
|
|
19
|
-
- [Attribution](#attribution)
|
|
20
|
-
- [Availability](#availability)
|
|
21
|
-
- [Common Mistakes](#common-mistakes)
|
|
22
|
-
- [Review Checklist](#review-checklist)
|
|
23
|
-
- [References](#references)
|
|
24
|
-
|
|
25
|
-
## Setup
|
|
26
|
-
|
|
27
|
-
### Project Configuration
|
|
28
|
-
|
|
29
|
-
1. Enable the **WeatherKit** capability in Xcode (adds the entitlement)
|
|
30
|
-
2. Enable WeatherKit for your App ID in the Apple Developer portal
|
|
31
|
-
3. Add `NSLocationWhenInUseUsageDescription` to Info.plist if using device location
|
|
32
|
-
4. WeatherKit requires an active Apple Developer Program membership
|
|
33
|
-
|
|
34
|
-
### Import
|
|
35
|
-
|
|
36
|
-
```swift
|
|
37
|
-
import WeatherKit
|
|
38
|
-
import CoreLocation
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Creating the Service
|
|
42
|
-
|
|
43
|
-
Use the shared singleton or create an instance. The service is `Sendable` and
|
|
44
|
-
thread-safe.
|
|
45
|
-
|
|
46
|
-
```swift
|
|
47
|
-
let weatherService = WeatherService.shared
|
|
48
|
-
// or
|
|
49
|
-
let weatherService = WeatherService()
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Fetching Current Weather
|
|
53
|
-
|
|
54
|
-
Fetch current conditions for a location. Returns a `Weather` object with all
|
|
55
|
-
available datasets.
|
|
56
|
-
|
|
57
|
-
```swift
|
|
58
|
-
func fetchCurrentWeather(for location: CLLocation) async throws -> CurrentWeather {
|
|
59
|
-
let weather = try await weatherService.weather(for: location)
|
|
60
|
-
return weather.currentWeather
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Using the result
|
|
64
|
-
func displayCurrent(_ current: CurrentWeather) {
|
|
65
|
-
let temp = current.temperature // Measurement<UnitTemperature>
|
|
66
|
-
let condition = current.condition // WeatherCondition enum
|
|
67
|
-
let symbol = current.symbolName // SF Symbol name
|
|
68
|
-
let humidity = current.humidity // Double (0-1)
|
|
69
|
-
let wind = current.wind // Wind (speed, direction, gust)
|
|
70
|
-
let uvIndex = current.uvIndex // UVIndex
|
|
71
|
-
|
|
72
|
-
print("\(condition): \(temp.formatted())")
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Forecasts
|
|
77
|
-
|
|
78
|
-
### Hourly Forecast
|
|
79
|
-
|
|
80
|
-
Returns 25 contiguous hours starting from the current hour by default.
|
|
81
|
-
|
|
82
|
-
```swift
|
|
83
|
-
func fetchHourlyForecast(for location: CLLocation) async throws -> Forecast<HourWeather> {
|
|
84
|
-
let weather = try await weatherService.weather(for: location)
|
|
85
|
-
return weather.hourlyForecast
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Iterate hours
|
|
89
|
-
for hour in hourlyForecast {
|
|
90
|
-
print("\(hour.date): \(hour.temperature.formatted()), \(hour.condition)")
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Daily Forecast
|
|
95
|
-
|
|
96
|
-
Returns 10 contiguous days starting from the current day by default.
|
|
97
|
-
|
|
98
|
-
```swift
|
|
99
|
-
func fetchDailyForecast(for location: CLLocation) async throws -> Forecast<DayWeather> {
|
|
100
|
-
let weather = try await weatherService.weather(for: location)
|
|
101
|
-
return weather.dailyForecast
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Iterate days
|
|
105
|
-
for day in dailyForecast {
|
|
106
|
-
print("\(day.date): \(day.lowTemperature.formatted()) - \(day.highTemperature.formatted())")
|
|
107
|
-
print(" Condition: \(day.condition), Precipitation: \(day.precipitationChance)")
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Custom Date Range
|
|
112
|
-
|
|
113
|
-
Request forecasts for specific date ranges using `WeatherQuery`.
|
|
114
|
-
|
|
115
|
-
```swift
|
|
116
|
-
func fetchExtendedForecast(for location: CLLocation) async throws -> Forecast<DayWeather> {
|
|
117
|
-
let startDate = Date.now
|
|
118
|
-
let endDate = Calendar.current.date(byAdding: .day, value: 10, to: startDate)!
|
|
119
|
-
|
|
120
|
-
let forecast = try await weatherService.weather(
|
|
121
|
-
for: location,
|
|
122
|
-
including: .daily(startDate: startDate, endDate: endDate)
|
|
123
|
-
)
|
|
124
|
-
return forecast
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Weather Alerts
|
|
129
|
-
|
|
130
|
-
Fetch active weather alerts for a location. Alerts include severity, summary,
|
|
131
|
-
and affected regions.
|
|
132
|
-
|
|
133
|
-
```swift
|
|
134
|
-
func fetchAlerts(for location: CLLocation) async throws -> [WeatherAlert]? {
|
|
135
|
-
let weather = try await weatherService.weather(for: location)
|
|
136
|
-
return weather.weatherAlerts
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Process alerts
|
|
140
|
-
if let alerts = weatherAlerts {
|
|
141
|
-
for alert in alerts {
|
|
142
|
-
print("Alert: \(alert.summary)")
|
|
143
|
-
print("Severity: \(alert.severity)")
|
|
144
|
-
print("Region: \(alert.region)")
|
|
145
|
-
if let detailsURL = alert.detailsURL {
|
|
146
|
-
// Link to full alert details
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Selective Queries
|
|
153
|
-
|
|
154
|
-
Fetch only the datasets you need to minimize API usage and response size. Each
|
|
155
|
-
`WeatherQuery` type maps to one dataset.
|
|
156
|
-
|
|
157
|
-
### Single Dataset
|
|
158
|
-
|
|
159
|
-
```swift
|
|
160
|
-
let current = try await weatherService.weather(
|
|
161
|
-
for: location,
|
|
162
|
-
including: .current
|
|
163
|
-
)
|
|
164
|
-
// current is CurrentWeather
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Multiple Datasets
|
|
168
|
-
|
|
169
|
-
```swift
|
|
170
|
-
let (current, hourly, daily) = try await weatherService.weather(
|
|
171
|
-
for: location,
|
|
172
|
-
including: .current, .hourly, .daily
|
|
173
|
-
)
|
|
174
|
-
// current: CurrentWeather, hourly: Forecast<HourWeather>, daily: Forecast<DayWeather>
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Minute Forecast
|
|
178
|
-
|
|
179
|
-
Available in limited regions. Returns precipitation forecasts at minute
|
|
180
|
-
granularity for the next hour.
|
|
181
|
-
|
|
182
|
-
```swift
|
|
183
|
-
let minuteForecast = try await weatherService.weather(
|
|
184
|
-
for: location,
|
|
185
|
-
including: .minute
|
|
186
|
-
)
|
|
187
|
-
// minuteForecast: Forecast<MinuteWeather>? (nil if unavailable)
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Available Query Types
|
|
191
|
-
|
|
192
|
-
| Query | Return Type | Description |
|
|
193
|
-
|---|---|---|
|
|
194
|
-
| `.current` | `CurrentWeather` | Current observed conditions |
|
|
195
|
-
| `.hourly` | `Forecast<HourWeather>` | 25 hours from current hour |
|
|
196
|
-
| `.daily` | `Forecast<DayWeather>` | 10 days from today |
|
|
197
|
-
| `.minute` | `Forecast<MinuteWeather>?` | Next-hour precipitation (limited regions) |
|
|
198
|
-
| `.alerts` | `[WeatherAlert]?` | Active weather alerts |
|
|
199
|
-
| `.availability` | `WeatherAvailability` | Dataset availability for location |
|
|
200
|
-
|
|
201
|
-
## Attribution
|
|
202
|
-
|
|
203
|
-
Apple requires apps using WeatherKit to display attribution. This is a
|
|
204
|
-
legal requirement.
|
|
205
|
-
|
|
206
|
-
### Fetching Attribution
|
|
207
|
-
|
|
208
|
-
```swift
|
|
209
|
-
func fetchAttribution() async throws -> WeatherAttribution {
|
|
210
|
-
return try await weatherService.attribution
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Displaying Attribution in SwiftUI
|
|
215
|
-
|
|
216
|
-
```swift
|
|
217
|
-
import SwiftUI
|
|
218
|
-
import WeatherKit
|
|
219
|
-
|
|
220
|
-
struct WeatherAttributionView: View {
|
|
221
|
-
let attribution: WeatherAttribution
|
|
222
|
-
@Environment(\.colorScheme) private var colorScheme
|
|
223
|
-
|
|
224
|
-
var body: some View {
|
|
225
|
-
VStack(spacing: 8) {
|
|
226
|
-
// Display the Apple Weather mark
|
|
227
|
-
AsyncImage(url: markURL) { image in
|
|
228
|
-
image
|
|
229
|
-
.resizable()
|
|
230
|
-
.scaledToFit()
|
|
231
|
-
.frame(height: 20)
|
|
232
|
-
} placeholder: {
|
|
233
|
-
EmptyView()
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Link to the legal attribution page
|
|
237
|
-
Link("Weather data sources", destination: attribution.legalPageURL)
|
|
238
|
-
.font(.caption2)
|
|
239
|
-
.foregroundStyle(.secondary)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
private var markURL: URL {
|
|
244
|
-
colorScheme == .dark
|
|
245
|
-
? attribution.combinedMarkDarkURL
|
|
246
|
-
: attribution.combinedMarkLightURL
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
### Attribution Properties
|
|
252
|
-
|
|
253
|
-
| Property | Use |
|
|
254
|
-
|---|---|
|
|
255
|
-
| `combinedMarkLightURL` | Apple Weather mark for light backgrounds |
|
|
256
|
-
| `combinedMarkDarkURL` | Apple Weather mark for dark backgrounds |
|
|
257
|
-
| `squareMarkURL` | Square Apple Weather logo |
|
|
258
|
-
| `legalPageURL` | URL to the legal attribution web page |
|
|
259
|
-
| `legalAttributionText` | Text alternative when a web view is not feasible |
|
|
260
|
-
| `serviceName` | Weather data provider name |
|
|
261
|
-
|
|
262
|
-
## Availability
|
|
263
|
-
|
|
264
|
-
Check which weather datasets are available for a given location. Not all datasets
|
|
265
|
-
are available in all countries.
|
|
266
|
-
|
|
267
|
-
```swift
|
|
268
|
-
func checkAvailability(for location: CLLocation) async throws {
|
|
269
|
-
let availability = try await weatherService.weather(
|
|
270
|
-
for: location,
|
|
271
|
-
including: .availability
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
// Check specific dataset availability
|
|
275
|
-
if availability.alertAvailability == .available {
|
|
276
|
-
// Safe to fetch alerts
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if availability.minuteAvailability == .available {
|
|
280
|
-
// Minute forecast available for this region
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Common Mistakes
|
|
286
|
-
|
|
287
|
-
### DON'T: Ship without Apple Weather attribution
|
|
288
|
-
|
|
289
|
-
Omitting attribution violates the WeatherKit terms of service and risks App Review
|
|
290
|
-
rejection.
|
|
291
|
-
|
|
292
|
-
```swift
|
|
293
|
-
// WRONG: Show weather data without attribution
|
|
294
|
-
VStack {
|
|
295
|
-
Text("72F, Sunny")
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// CORRECT: Always include attribution
|
|
299
|
-
VStack {
|
|
300
|
-
Text("72F, Sunny")
|
|
301
|
-
WeatherAttributionView(attribution: attribution)
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### DON'T: Fetch all datasets when you only need current conditions
|
|
306
|
-
|
|
307
|
-
Each dataset query counts against your API quota. Fetch only what you display.
|
|
308
|
-
|
|
309
|
-
```swift
|
|
310
|
-
// WRONG: Fetches everything
|
|
311
|
-
let weather = try await weatherService.weather(for: location)
|
|
312
|
-
let temp = weather.currentWeather.temperature
|
|
313
|
-
|
|
314
|
-
// CORRECT: Fetch only current conditions
|
|
315
|
-
let current = try await weatherService.weather(
|
|
316
|
-
for: location,
|
|
317
|
-
including: .current
|
|
318
|
-
)
|
|
319
|
-
let temp = current.temperature
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### DON'T: Ignore minute forecast unavailability
|
|
323
|
-
|
|
324
|
-
Minute forecasts return `nil` in unsupported regions. Force-unwrapping crashes.
|
|
325
|
-
|
|
326
|
-
```swift
|
|
327
|
-
// WRONG: Force-unwrap minute forecast
|
|
328
|
-
let minutes = try await weatherService.weather(for: location, including: .minute)
|
|
329
|
-
for m in minutes! { ... } // Crash in unsupported regions
|
|
330
|
-
|
|
331
|
-
// CORRECT: Handle nil
|
|
332
|
-
if let minutes = try await weatherService.weather(for: location, including: .minute) {
|
|
333
|
-
for m in minutes { ... }
|
|
334
|
-
} else {
|
|
335
|
-
// Minute forecast not available for this region
|
|
336
|
-
}
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### DON'T: Forget the WeatherKit entitlement
|
|
340
|
-
|
|
341
|
-
Without the capability enabled, `WeatherService` calls throw at runtime.
|
|
342
|
-
|
|
343
|
-
```swift
|
|
344
|
-
// WRONG: No WeatherKit capability configured
|
|
345
|
-
let weather = try await weatherService.weather(for: location) // Throws
|
|
346
|
-
|
|
347
|
-
// CORRECT: Enable WeatherKit in Xcode Signing & Capabilities
|
|
348
|
-
// and in the Apple Developer portal for your App ID
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
### DON'T: Make repeated requests without caching
|
|
352
|
-
|
|
353
|
-
Weather data updates every few minutes, not every second. Cache responses
|
|
354
|
-
to stay within API quotas and improve performance.
|
|
355
|
-
|
|
356
|
-
```swift
|
|
357
|
-
// WRONG: Fetch on every view appearance
|
|
358
|
-
.task {
|
|
359
|
-
let weather = try? await fetchWeather()
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// CORRECT: Cache with a staleness interval
|
|
363
|
-
actor WeatherCache {
|
|
364
|
-
private var cached: CurrentWeather?
|
|
365
|
-
private var lastFetch: Date?
|
|
366
|
-
|
|
367
|
-
func current(for location: CLLocation) async throws -> CurrentWeather {
|
|
368
|
-
if let cached, let lastFetch,
|
|
369
|
-
Date.now.timeIntervalSince(lastFetch) < 600 {
|
|
370
|
-
return cached
|
|
371
|
-
}
|
|
372
|
-
let fresh = try await WeatherService.shared.weather(
|
|
373
|
-
for: location, including: .current
|
|
374
|
-
)
|
|
375
|
-
cached = fresh
|
|
376
|
-
lastFetch = .now
|
|
377
|
-
return fresh
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
## Review Checklist
|
|
383
|
-
|
|
384
|
-
- [ ] WeatherKit capability enabled in Xcode and Apple Developer portal
|
|
385
|
-
- [ ] Active Apple Developer Program membership (required for WeatherKit)
|
|
386
|
-
- [ ] Apple Weather attribution displayed wherever weather data appears
|
|
387
|
-
- [ ] Attribution mark uses correct color scheme variant (light/dark)
|
|
388
|
-
- [ ] Legal attribution page linked or `legalAttributionText` displayed
|
|
389
|
-
- [ ] Only needed `WeatherQuery` datasets fetched (not full `weather(for:)` when unnecessary)
|
|
390
|
-
- [ ] Minute forecast handled as optional (nil in unsupported regions)
|
|
391
|
-
- [ ] Weather alerts checked for nil before iteration
|
|
392
|
-
- [ ] Responses cached with a reasonable staleness interval (5-15 minutes)
|
|
393
|
-
- [ ] `WeatherAvailability` checked before fetching region-limited datasets
|
|
394
|
-
- [ ] Location permission requested before passing `CLLocation` to service
|
|
395
|
-
- [ ] Temperature and measurements formatted with `Measurement.formatted()` for locale
|
|
396
|
-
|
|
397
|
-
## References
|
|
398
|
-
|
|
399
|
-
- Extended patterns (SwiftUI dashboard, charts integration, historical statistics): `references/weatherkit-patterns.md`
|
|
400
|
-
- [WeatherKit framework](https://sosumi.ai/documentation/weatherkit)
|
|
401
|
-
- [WeatherService](https://sosumi.ai/documentation/weatherkit/weatherservice)
|
|
402
|
-
- [WeatherAttribution](https://sosumi.ai/documentation/weatherkit/weatherattribution)
|
|
403
|
-
- [WeatherQuery](https://sosumi.ai/documentation/weatherkit/weatherquery)
|
|
404
|
-
- [CurrentWeather](https://sosumi.ai/documentation/weatherkit/currentweather)
|
|
405
|
-
- [Forecast](https://sosumi.ai/documentation/weatherkit/forecast)
|
|
406
|
-
- [HourWeather](https://sosumi.ai/documentation/weatherkit/hourweather)
|
|
407
|
-
- [DayWeather](https://sosumi.ai/documentation/weatherkit/dayweather)
|
|
408
|
-
- [WeatherAlert](https://sosumi.ai/documentation/weatherkit/weatheralert)
|
|
409
|
-
- [WeatherAvailability](https://sosumi.ai/documentation/weatherkit/weatheravailability)
|
|
410
|
-
- [Fetching weather forecasts with WeatherKit](https://sosumi.ai/documentation/weatherkit/fetching_weather_forecasts_with_weatherkit)
|