Expand description
§weatherkit-rs
Safe Rust bindings for Apple’s WeatherKit framework on macOS 13+.
The published package is weatherkit-doomfish; the Rust library crate is imported as weatherkit.
Status: v0.2.0 covers WeatherService, CurrentWeather, daily/hourly/minute forecasts, weather alerts, availability metadata, WeatherAttribution, SunEvents, MoonEvents, WeatherCondition descriptors, and Pressure helpers.
§Quick start
use weatherkit::prelude::*;
fn main() -> Result<(), WeatherKitError> {
let service = WeatherService::shared();
let location = CLLocation::new(37.3349, -122.0090);
let current = service.current_weather(&location)?;
println!(
"current temperature: {:.1}°C ({:?})",
current.temperature,
current.condition
);
Ok(())
}§Highlights
WeatherService::weather,current_weather,daily_forecast,hourly_forecast,minute_forecast,weather_alerts,availability, andattributionDailyForecast/HourlyForecastcontainers with WeatherKit metadata plusDayForecast/HourForecastentriesCurrentWeatherwith precipitation intensity, metadata, and cloud-cover-by-altitude when available on macOS 15+DayForecastwithSunEvents,MoonEvents,UVIndex, wind, day-part forecasts, and precipitation-by-type details when availableWeatherAttribution,WeatherSeverity,AvailabilityKind,WeatherCondition,PressureTrend, andMoonPhasedescriptor catalogs- Async Swift APIs bridged to synchronous Rust via
DispatchSemaphore + Task, with opaque handle ownership released on the Rust side
§Entitlements / caveats
WeatherKit usually requires an entitled bundle ID backed by a paid Apple Developer membership. Unsigned CLI binaries often fail with permission or bundle-configuration errors; every example in examples/ treats that as a caveat instead of a hard failure.
§Examples
Each logical area has a dedicated example:
cargo run --example 01_weather_service_smoke
cargo run --example 02_current_weather_snapshot
cargo run --example 03_daily_forecast_snapshot
cargo run --example 04_hourly_forecast_snapshot
cargo run --example 05_weather_alerts_snapshot
cargo run --example 06_minute_forecast_snapshot
cargo run --example 07_availability_kind_catalog
cargo run --example 08_weather_attribution_snapshot
cargo run --example 09_sun_events_snapshot
cargo run --example 10_moon_events_snapshot
cargo run --example 11_weather_condition_catalog
cargo run --example 12_pressure_catalog§License
Licensed under either Apache-2.0 or MIT at your option.
Re-exports§
pub use availability_kind::AvailabilityKind;pub use availability_kind::AvailabilityKindDescriptor;pub use availability_kind::WeatherAvailability;pub use current_weather::CloudCoverByAltitude;pub use current_weather::CurrentWeather;pub use current_weather::UVIndex;pub use current_weather::Wind;pub use daily_forecast::DailyForecast;pub use daily_forecast::DayForecast;pub use daily_forecast::DayPartForecast;pub use daily_forecast::PrecipitationAmountByType;pub use daily_forecast::SnowfallAmount;pub use error::WeatherKitError;pub use error::WEATHERKIT_BRIDGE_ERROR_DOMAIN;pub use hourly_forecast::HourForecast;pub use hourly_forecast::HourlyForecast;pub use minute_forecast::MinuteForecast;pub use minute_forecast::MinuteForecastCollection;pub use moon_events::MoonEvents;pub use moon_events::MoonPhase;pub use moon_events::MoonPhaseDescriptor;pub use pressure::Pressure;pub use pressure::PressureTrend;pub use pressure::PressureTrendDescriptor;pub use service::CLLocation;pub use service::DateInterval;pub use service::Weather;pub use service::WeatherMetadata;pub use service::WeatherService;pub use sun_events::SunEvents;pub use weather_alert::WeatherAlert;pub use weather_alert::WeatherSeverity;pub use weather_alert::WeatherSeverityDescriptor;pub use weather_attribution::WeatherAttribution;pub use weather_condition::Precipitation;pub use weather_condition::WeatherCondition;pub use weather_condition::WeatherConditionDescriptor;