Expand description
§eventkit
Safe Rust bindings for Apple’s EventKit framework on macOS.
See COVERAGE.md for the API matrix, the adapted representations and the intentionally skipped APIs.
§Requirements
- macOS 13 or later; the Swift bridge’s deployment target is macOS 13.
- The full-access and write-only access requests need macOS 14. On macOS 13 they fall back to
requestAccessToEntityType:completion:.
Build an x86_64 macOS binary with a deployment target of macOS 13.0 or later. Rust builds
x86_64 macOS binaries for macOS 10.12 by default. With that target, the binary loads the Swift runtime
through @rpath and stops at launch with an error such as
Library not loaded: @rpath/libswiftCore.dylib. Set MACOSX_DEPLOYMENT_TARGET=13.0 in the
environment, or set it for the project in .cargo/config.toml:
[env]
MACOSX_DEPLOYMENT_TARGET = "13.0"Cargo does not link the binary again when only this variable changes, so run cargo clean
after you set it.
§Installation
[dependencies]
eventkit = "0.4"§Quick start
use eventkit::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = EKEventStore::new()?;
println!("store id: {}", store.event_store_identifier()?);
println!("event access: {:?}", EKEventStore::authorization_status(EKEntityType::Event));
let sources = store.sources()?;
let calendars = store.calendars_for_entity_type(EKEntityType::Event)?;
println!("sources: {}", sources.len());
println!("event calendars: {}", calendars.len());
Ok(())
}§Highlights
EKEventStorewrappers for authorization, source-scoped stores, source/calendar lookup, event/reminder predicates, save/remove flows, commit/reset, and source refresh.- Live
EKObjectwrappers forhas_changes,is_new,reset,rollback, andrefresh, plusas_object_inhelpers onEKEvent,EKReminder, andEKCalendarDraft. - Rich
EKEvent+EKRemindersnapshots with alarms, recurrence rules, participants, organizers, structured locations, date components, andEKParticipantScheduleStatus. EKCalendar+EKSourcesnapshots, plus unsavedEKCalendarDraftround-trips for safe headless testing.EKRecurrenceRule,EKAlarm,EKStructuredLocation, and virtual conference descriptor round-trips.- One example and one integration test per logical area.
§Async API
Enable the async Cargo feature for Future-based wrappers around EventKit’s
completion-handler APIs:
[dependencies]
eventkit = { version = "0.4", features = ["async"] }use eventkit::async_api::AsyncEventStore;
use eventkit::event_store::{EKEventStore, EKReminderPredicate};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let store = AsyncEventStore::new(EKEventStore::new()?);
let granted = store.request_full_access_to_reminders().await?;
if granted {
let reminders = store.fetch_reminders(&EKReminderPredicate::new())?.await?;
println!("found {} reminder(s)", reminders.len());
}
Ok(())
}The async API is executor-agnostic — it works with tokio, async-std, smol,
pollster, or any other runtime. See async_api in the crate docs and
examples/12_async_access.rs for a runnable example.
Tier-2 note:
EKEventStorechange notifications (multi-fire stream) are not yet wrapped; they will appear in a futureStream-based Tier-2 release.
COVERAGE.md was written against the macOS 26.2 EventKit.framework headers, re-checked against the 26.5 and 27.0 SDKs, and calls out the intentionally skipped APIs:
- deprecated legacy initializers / AddressBook integrations,
- cross-framework convenience APIs that would force a
MapKitdependency, - extension-only
EKVirtualConferenceProvidersubclass hooks.
§Authorization
EventKit.framework access is gated by macOS privacy settings (TCC).
- Add usage strings to the app’s
Info.plist:NSCalendarsFullAccessUsageDescriptionandNSRemindersFullAccessUsageDescriptionfor full access,NSCalendarsWriteOnlyAccessUsageDescriptionfor write-only event access, and on macOS 13NSCalendarsUsageDescriptionandNSRemindersUsageDescription. Without them the request is denied. - Sandboxed and hardened-runtime apps need the
com.apple.security.personal-information.calendarsentitlement. - Command-line tools get the permission of their responsible process, such as the terminal app.
- The synchronous
request_*_access_*methods wait up to 30 seconds for an answer and then returnEventKitError::TimedOutwhile the prompt may still be showing.AsyncEventStorewaits for the answer without a timeout.
§Behavior notes
- For a recurring event,
save_eventandremove_eventact on the occurrence named by the snapshot’soccurrence_date, with theEKSpanyou pass, and return an error when that occurrence can’t be found.event_with_identifierreturns the first occurrence, as EventKit does. - Saving an event or reminder writes only the fields that differ from the stored item. Unchanged alarms and recurrence rules are left as they are.
- Recurrence rules are checked before they reach EventKit: the interval and occurrence count must be positive, week numbers must be between -53 and 53 (0 for weekly rules), and the other values must be in their documented ranges. An invalid rule returns
EventKitError::InvalidArgumentinstead of raising an Objective-C exception. events_matchinghandles ranges longer than EventKit’s four-year limit by querying them in chunks. Unknown calendar identifiers returnEventKitError::InvalidArgument, and an empty calendar list matches nothing.enumerate_events_matchingfetches all matching events before it calls the closure.- The snapshot types’
Debugoutput redacts personal data such as titles, notes, locations, names and email addresses. Serialize them with serde when you need the values.
§Tests
The examples and tests use the real EventKit and tolerate zero visible calendars and sources. When calendar access is granted they read your calendars and reminders, but they never save or remove items. The access-request tests skip when the authorization status is not determined, so they never show a prompt.
§Examples
Run the store smoke example with:
cargo run --example 01_event_store_smokeRun the full example suite with:
for ex in examples/*.rs; do cargo run --example "$(basename "$ex" .rs)"; done§License
Licensed under either of Apache-2.0 or MIT at your option.
Re-exports§
pub use alarm::EKAlarm;pub use alarm::EKAlarmProximity;pub use alarm::EKAlarmType;pub use calendar::EKCalendar;pub use calendar::EKCalendarDraft;pub use calendar::EKCalendarEventAvailability;pub use calendar::EKCalendarType;pub use error::EKAuthorizationStatus;pub use error::EventKitError;pub use error::NSErrorInfo;pub use event::EKEvent;pub use event::EKEventAvailability;pub use event::EKEventStatus;pub use event_store::EKCalendarItem;pub use event_store::EKCalendarItemKind;pub use event_store::EKEntityType;pub use event_store::EKEventPredicate;pub use event_store::EKEventStore;pub use event_store::EKReminderPredicate;pub use event_store::EKReminderPredicateKind;pub use event_store::EKSpan;pub use event_store::EK_EVENT_STORE_CHANGED_NOTIFICATION;pub use object::EKObject;pub use participant::EKParticipant;pub use participant::EKParticipantRole;pub use participant::EKParticipantScheduleStatus;pub use participant::EKParticipantStatus;pub use participant::EKParticipantType;pub use recurrence_rule::EKRecurrenceDayOfWeek;pub use recurrence_rule::EKRecurrenceEnd;pub use recurrence_rule::EKRecurrenceFrequency;pub use recurrence_rule::EKRecurrenceRule;pub use recurrence_rule::EKWeekday;pub use reminder::EKReminder;pub use reminder::EKReminderPriority;pub use reminder::NSDateComponents;pub use source::EKSource;pub use source::EKSourceType;pub use structured_location::EKGeoLocation;pub use structured_location::EKStructuredLocation;pub use virtual_conference_provider::EKVirtualConferenceDescriptor;pub use virtual_conference_provider::EKVirtualConferenceRoomTypeDescriptor;pub use virtual_conference_provider::EKVirtualConferenceURLDescriptor;pub use virtual_conference_provider::EK_VIRTUAL_CONFERENCE_PROVIDER_IS_EXTENSION_ONLY;
Modules§
- alarm
- EventKit alarm types and helpers.
- async_
api async - Async API for EventKit (
feature = "async") - calendar
- EventKit calendar snapshots and draft helpers.
- error
- EventKit error and authorization types.
- event
- EventKit event snapshots and helpers.
- event_
store - EventKit store access, predicates, and save helpers.
- object
- EventKit live-object wrappers.
- participant
- EventKit participant snapshots.
- prelude
- Common imports.
- recurrence_
rule - EventKit recurrence rule types and helpers.
- reminder
- EventKit reminder snapshots and date components.
- source
- EventKit source snapshots and queries.
- store
- Re-exports EventKit store types.
- structured_
location - EventKit structured-location types and helpers.
- types
- Re-exports common EventKit data types.
- virtual_
conference_ provider - EventKit virtual conference provider descriptors.