Skip to content
Development
Skill

/weatherkit

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

From plugin
swift-ios-skills
98186 skills1 MCP
Install
$ npx -y skills add dpearson2699/swift-ios-skills --skill weatherkit --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/weatherkit

Context preview

The summary Claude sees to decide when to auto-load this skill.

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

SKILL.md

weatherkit.SKILL.md
name: weatherkit
description: "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."

WeatherKit

Fetch current conditions, hourly and daily forecasts, weather alerts, and historical statistics using `WeatherService`. Display required Apple Weather attribution.

Contents

  • [Setup](#setup)
  • [Fetching Current Weather](#fetching-current-weather)
  • [Forecasts](#forecasts)
  • [Weather Alerts](#weather-alerts)
  • [Selective Queries](#selective-queries)
  • [Context Queries](#context-queries)
  • [Attribution](#attribution)
  • [Availability](#availability)
  • [Common Mistakes](#common-mistakes)
  • [Review Checklist](#review-checklist)
  • [References](#references)

Setup

Project Configuration

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 membership

Import

import WeatherKit
import CoreLocation

Creating the Service

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()

Fetching Current Weather

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())")
}

Forecasts

Hourly Forecast

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)")
}

Daily Forecast

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)")
}

Custom Date Range

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)
    )
}

Weather Alerts

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.

Selective Queries

Fetch only the datasets you need to minimize API usage and response size. Each `WeatherQuery` type maps to one dataset.

Single Dataset

let current = try await weatherService.weather(
    for: loc
Read more
Ships withswift-ios-skills

86 agent skills optimized for iOS 26+ development with Swift 6.3 and modern Apple frameworks.

Get the whole plugin
Stats
981
Stars
50
Forks
Active
Maintenance
Python
Language
9d ago
Last commit
5mo ago
Created

Repo: dpearson2699/swift-ios-skills

Other skills on swift-ios-skills.