Releases: CorvidLabs/swift-weather
Releases · CorvidLabs/swift-weather
0.1.0
SwiftWeather
Pre-1.0 Notice: This library is under active development. The API may change between minor versions until 1.0.
A Swift library for fetching weather data from multiple providers.
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, [email protected])"
)
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 protected])")
// International locations (uses Open-Meteo only)
let intlConfig = WeatherConfiguration.international(userAgent: "(MyApp, [email protected])")
// Custom configuration
let config = WeatherConfiguration(
userAgent: "(MyApp, [email protected])",
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