CorvidLabs/swift-weather
⛅ Ask the sky, get JSON back
Features
- Multiple Providers - NWS (US) and Open-Meteo (international)
- Automatic Selection - Uses best provider based on location
- Swift 6 Concurrency - Full async/await support
- Cross-Platform - iOS, macOS, tvOS, watchOS, visionOS
Installation
Add SwiftWeather as a dependency in your Package.swift:
dependencies: [
.package(url: "https://github.com/CorvidLabs/swift-weather.git", from: "0.1.0")
]Then add the target dependency:
.target(
name: "YourTarget",
dependencies: [
.product(name: "Weather", package: "swift-weather")
]
)Quick Start
import Weather
let config = WeatherConfiguration(
userAgent: "(MyApp, contact@example.com)"
)
let weather = Weather(configuration: config)
let current = try await weather.current(
latitude: 47.6062,
longitude: -122.3321
)
print("Temperature: \(current.temperature.fahrenheit)°F")
print("Condition: \(current.conditionDescription)")Configuration
// US locations (uses NWS with Open-Meteo fallback)
let usConfig = WeatherConfiguration.us(userAgent: "(MyApp, email@example.com)")
// International locations (uses Open-Meteo only)
let intlConfig = WeatherConfiguration.international(userAgent: "(MyApp, email@example.com)")
// Custom configuration
let config = WeatherConfiguration(
userAgent: "(MyApp, email@example.com)",
temperatureUnit: .celsius,
providerStrategy: .automatic
)Weather Conditions
The library supports these weather conditions:
clear- Clear skiespartlyCloudy- Partly cloudycloudy- Overcastfog- Foggy conditionsdrizzle- Light rainrain- RainfreezingRain- Freezing rainsnow- Snowsleet- Sleet/ice pelletsthunderstorm- Thunderstormsunknown- Unknown condition
License
MIT License - see LICENSE for details.
Package Metadata
Repository: CorvidLabs/swift-weather
Stars: 1
Forks: 1
Open issues: 1
Default branch: main
Primary language: swift
License: MIT
Topics: swift, swift-package, weather, weather-api
README: README.md