Best for
- Use when integrating weather data, showing forecasts or alerts, caching WeatherKit responses, displaying attribution, or reviewing WeatherKit query limits in iOS apps.
dpearson2699/swift-ios-skills/skills/weatherkit/SKILL.md
Fetch WeatherKit current, minute, hourly, and daily forecasts; weather alerts; iOS 18+ changes, historical comparisons, summaries, and statistics; and required Apple Weather attribution. Use when integrating weather data, showing forecasts or alerts, caching WeatherKit responses, displaying attribution, or reviewing WeatherKit query limits in iOS apps.
Decision brief
Fetch current conditions, hourly and daily forecasts, weather alerts, and historical statistics using WeatherService. Display required Apple Weather attribution.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill "skills/weatherkit"Inspect the Agent Skill "weatherkit" from https://github.com/dpearson2699/swift-ios-skills/blob/90c9573272531337962fbb3505036d61ed23389a/skills/weatherkit/SKILL.md at commit 90c9573272531337962fbb3505036d61ed23389a. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
1. Enable the WeatherKit capability in Xcode (adds the entitlement) 2. Enable WeatherKit for your App ID in the Apple Developer portal 3. Add NSLocationWhenInUseUsageDescription to Info.plist if using device location 4. WeatherKit requires an active Apple Developer Program membe…
[ ] WeatherKit capability enabled in Xcode and Apple Developer portal
1. Enable the WeatherKit capability in Xcode (adds the entitlement) 2. Enable WeatherKit for your App ID in the Apple Developer portal 3. Add NSLocationWhenInUseUsageDescription to Info.plist if using device location 4. WeatherKit requires an active Apple Developer Program membe…
Review the “Import” section in the pinned source before continuing.
Use the shared singleton or create an instance. WeatherService conforms to Sendable; keep app cache and UI state isolated separately.
Permission review
The documentation includes network, browsing, or remote request actions.
Each dataset query counts against your API quota. Use the selective query shownEvidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 83/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 933 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Fetch current conditions, hourly and daily forecasts, weather alerts, and
historical statistics using WeatherService. Display required Apple Weather attribution.
NSLocationWhenInUseUsageDescription to Info.plist if using device locationimport WeatherKit
import CoreLocation
Use the shared singleton or create an instance. WeatherService conforms to
Sendable; keep app cache and UI state isolated separately.
let weatherService = WeatherService.shared
// or
let weatherService = WeatherService()
Fetch current conditions for a location. Returns a Weather object with all
available datasets.
WeatherKit temperatures are Measurement<UnitTemperature> values; display them
with .formatted() so units and number formatting follow the user's locale.
func fetchCurrentWeather(for location: CLLocation) async throws -> CurrentWeather {
let weather = try await weatherService.weather(for: location)
return weather.currentWeather
}
// Using the result
func displayCurrent(_ current: CurrentWeather) {
let temp = current.temperature // Measurement<UnitTemperature>
let condition = current.condition // WeatherCondition enum
let symbol = current.symbolName // SF Symbol name
let humidity = current.humidity // Double (0-1)
let wind = current.wind // Wind (speed, direction, gust)
let uvIndex = current.uvIndex // UVIndex
print("\(condition): \(temp.formatted())")
}
Returns 25 contiguous hours starting from the current hour by default.
func fetchHourlyForecast(for location: CLLocation) async throws -> Forecast<HourWeather> {
let weather = try await weatherService.weather(for: location)
return weather.hourlyForecast
}
// Iterate hours
for hour in hourlyForecast {
print("\(hour.date): \(hour.temperature.formatted()), \(hour.condition)")
}
Returns 10 contiguous days starting from the current day by default.
func fetchDailyForecast(for location: CLLocation) async throws -> Forecast<DayWeather> {
let weather = try await weatherService.weather(for: location)
return weather.dailyForecast
}
// Iterate days
for day in dailyForecast {
print("\(day.date): \(day.lowTemperature.formatted()) - \(day.highTemperature.formatted())")
print(" Condition: \(day.condition), Precipitation: \(day.precipitationChance)")
}
Request forecasts for specific date ranges using WeatherQuery.
Daily and hourly date-range queries use an inclusive startDate and exclusive
endDate. They can include historical data from August 1, 2021. Forecasts are
available up to 10 days in the future; each request returns at most 10 daily
forecast days or about 240 hourly forecast hours.
func fetchExtendedForecast(for location: CLLocation) async throws -> Forecast<DayWeather> {
let startDate = Date.now
let endDate = Calendar.current.date(byAdding: .day, value: 10, to: startDate)!
let forecast = try await weatherService.weather(
for: location,
including: .daily(startDate: startDate, endDate: endDate)
)
return forecast
}
For tomorrow-specific guidance, request the local tomorrow day interval rather than using minute forecasts:
func fetchTomorrowForecast(for location: CLLocation) async throws -> Forecast<DayWeather> {
let calendar = Calendar.current
let tomorrow = calendar.startOfDay(
for: calendar.date(byAdding: .day, value: 1, to: .now)!
)
let dayAfterTomorrow = calendar.date(byAdding: .day, value: 1, to: tomorrow)!
return try await weatherService.weather(
for: location,
including: .daily(startDate: tomorrow, endDate: dayAfterTomorrow)
)
}
Fetch active weather alerts for a location. Alerts include severity, summary, and affected regions.
func fetchAlerts(for location: CLLocation) async throws -> [WeatherAlert]? {
let weather = try await weatherService.weather(for: location)
return weather.weatherAlerts
}
// Process alerts
if let alerts = weatherAlerts {
for alert in alerts {
print("Alert: \(alert.summary)")
print("Severity: \(alert.severity)")
print("Region: \(alert.region ?? "Unknown region")")
print("Details: \(alert.detailsURL)") // Non-optional and required for attribution
}
}
For alert dashboards, name WeatherAvailability explicitly when discussing
support checks: it exposes alertAvailability and minuteAvailability only,
not a broad availability matrix for current, hourly, or daily weather.
Fetch only the datasets you need to minimize API usage and response size. Each
WeatherQuery type maps to one dataset.
let current = try await weatherService.weather(
for: location,
including: .current
)
// current is CurrentWeather
let (current, hourly, daily) = try await weatherService.weather(
for: location,
including: .current, .hourly, .daily
)
// current: CurrentWeather, hourly: Forecast<HourWeather>, daily: Forecast<DayWeather>
Available in limited regions. Returns precipitation forecasts at minute granularity for the next hour.
let minuteForecast = try await weatherService.weather(
for: location,
including: .minute
)
// minuteForecast: Forecast<MinuteWeather>? (nil if unavailable)
| Query | Return Type | Description |
|---|---|---|
.current | CurrentWeather | Current observed conditions |
.hourly | Forecast<HourWeather> | 25 hours from current hour |
.daily | Forecast<DayWeather> | 10 days from today |
.minute | Forecast<MinuteWeather>? | Next-hour precipitation (limited regions) |
.alerts | [WeatherAlert]? | Active weather alerts |
.availability | WeatherAvailability | Alert and minute forecast availability only |
.changes | WeatherChanges? | Significant upcoming weather changes (iOS 18+) |
.historicalComparisons | HistoricalComparisons? | Current weather compared to historical averages (iOS 18+) |
For "unusual tomorrow" or "what is changing?" features on iOS 18+, request the
optional .changes and .historicalComparisons results together: the first
reports significant upcoming changes and the second provides historical context.
let (changes, comparisons) = try await weatherService.weather(
for: location,
including: .changes, .historicalComparisons
)
Historical summaries and statistics use WeatherService methods rather than
WeatherQuery. Load references/weatherkit-patterns.md
for their tuple ordering, APIs, and statistics-specific properties.
Apple requires apps using WeatherKit to display attribution. This is a legal requirement.
func fetchAttribution() async throws -> WeatherAttribution {
return try await weatherService.attribution
}
Load references/weatherkit-patterns.md for the complete SwiftUI attribution view and cache integration.
| Property | Use |
|---|---|
combinedMarkLightURL | Apple Weather mark for light backgrounds |
combinedMarkDarkURL | Apple Weather mark for dark backgrounds |
squareMarkURL | Square Apple Weather logo |
legalPageURL | URL to the legal attribution web page |
legalAttributionText | Text alternative when a web view is not feasible |
serviceName | Weather data provider name |
Check whether weather alerts or minute forecast data are available for a
location. WeatherAvailability reports only alert and minute availability;
other datasets, such as current weather, are expected to be supported for
geographic locations.
func checkAvailability(for location: CLLocation) async throws {
let availability = try await weatherService.weather(
for: location,
including: .availability
)
// Check specific dataset availability
if availability.alertAvailability == .available {
// Safe to fetch alerts
}
if availability.minuteAvailability == .available {
// Minute forecast available for this region
}
}
Display the appropriate Apple Weather mark and link legalPageURL wherever WeatherKit data appears; use legalAttributionText only when the legal page cannot be shown.
Each dataset query counts against your API quota. Use the selective query shown in Selective Queries and fetch only what the UI displays.
Minute forecasts are optional in unsupported regions. Check availability and
handle the nil result instead of force-unwrapping it.
Without the capability enabled, WeatherService calls throw at runtime.
// WRONG: No WeatherKit capability configured
let weather = try await weatherService.weather(for: location) // Throws
// CORRECT: Enable WeatherKit in Xcode Signing & Capabilities
// and in the Apple Developer portal for your App ID
WeatherKit models include metadata.expirationDate. Cache responses until that
expiration instead of inventing a fixed interval or fetching on every view
appearance. Let a model or cache own loadIfNeeded; the complete actor pattern
is in references/weatherkit-patterns.md.
legalAttributionText displayedWeatherQuery datasets fetched (not full weather(for:) when unnecessary)detailsURL; optional region is nil-safemetadata.expirationDateWeatherAvailability used for alert/minute availability, not as a broad support matrixCLLocation to serviceMeasurement.formatted() for locale