Use EventKit for calendar and reminder authorization, CRUD, recurrence, alarms, and system editors.
Contents
- Workflow
- Route by Task
- Core Decisions
- Common Mistakes
- Review Checklist
- References
Workflow
- Determine whether the app needs event write-only access, full event access, or reminder access and declare the matching usage descriptions.
- Retain one
EKEventStore, request the narrowest authorization, and branch on current status. - Create or fetch objects from that store, choose writable calendars, and make timezone/recurrence semantics explicit.
- Save or batch changes with the intended commit policy and surface recoverable errors.
- Observe store changes and verify denied/restricted access, recurrence edits, timezone changes, and external modifications.
Route by Task
- Read core implementation details for authorization, events, reminders, recurrence, alarms, EventKitUI, and change observation.
- Read extended EventKit patterns for SwiftUI wrappers, predicates, batch operations, and advanced recurrence workflows.
Core Decisions
- Use current full-access/write-only authorization APIs rather than legacy generic access calls.
- Never mix
EKObjectinstances from different event stores. - Check calendar mutability before save and preserve explicit timezone intent.
- Decide whether recurring edits affect one occurrence or the future span before saving.
Common Mistakes
DON'T: Use legacy requestAccess(to:) on current systems
// WRONG: Legacy request API on current systems
eventStore.requestAccess(to: .event) { granted, error in }
// CORRECT: Use the granular async methods
let granted = try await eventStore.requestFullAccessToEvents()
Keep it only in the compatibility fallback from Availability.
DON'T: Save events to a read-only calendar
// WRONG: No check -- will throw if calendar is read-only
event.calendar = someCalendar
try eventStore.save(event, span: .thisEvent)
// CORRECT: Verify the calendar allows modifications
guard someCalendar.allowsContentModifications else {
event.calendar = eventStore.defaultCalendarForNewEvents
return
}
event.calendar = someCalendar
try eventStore.save(event, span: .thisEvent)
DON'T: Ignore timezone when creating events
// WRONG: Event appears at wrong time for traveling users
event.startDate = Date()
event.endDate = Date().addingTimeInterval(3600)
// CORRECT: Set the timezone explicitly for location-specific events
event.timeZone = TimeZone(identifier: "America/New_York")
event.startDate = startDate
event.endDate = endDate
DON'T: Forget to commit batched saves
// WRONG: Changes never persisted
try eventStore.save(event1, span: .thisEvent, commit: false)
try eventStore.save(event2, span: .thisEvent, commit: false)
// Missing commit!
// CORRECT: Commit after batching
try eventStore.save(event1, span: .thisEvent, commit: false)
try eventStore.save(event2, span: .thisEvent, commit: false)
try eventStore.commit()
DON'T: Mix EKObjects from different event stores
// WRONG: Event fetched from storeA, saved to storeB
let event = storeA.event(withIdentifier: id)!
try storeB.save(event, span: .thisEvent) // Undefined behavior
// CORRECT: Use the same store throughout
let event = eventStore.event(withIdentifier: id)!
try eventStore.save(event, span: .thisEvent)
Review Checklist
- Correct
Info.plistusage description keys added for calendars and/or reminders - Authorization follows the version split in Availability
- Write-only calendar access used only for direct event creation, not event/calendar reads
- Authorization status checked before fetching or saving
- Full access required before any event or reminder fetch
- Single
EKEventStoreinstance reused across the app - Events saved to a writable calendar (
allowsContentModificationschecked) - Recurring event saves specify correct
EKSpan(.thisEventvs.futureEvents) - Batched saves validate writable calendars, stage with
commit: false, call throwingcommit(), and on failurereset()unsaved state, discard every invalidatedEKObject, then refetch or reconstruct before retry -
EKEventStoreChangednotification observed to refresh stale data - Change observation uses the classic notification or guarded typed message per Availability
- Timezone set explicitly for location-specific events
- EKObjects not shared across different event store instances
- EventKitUI delegates dismiss controllers in completion callbacks
References
- Extended patterns (SwiftUI wrappers, predicate queries, batch operations): references/eventkit-patterns.md
- EventKit framework
- EKEventStore
- EKEvent
- EKReminder
- EKRecurrenceRule
- EKCalendar
- EventKit UI
- EKEventEditViewController
- EKCalendarChooser
- Accessing the event store
- Creating a recurring event
- Core implementation details -- setup, API wiring, and focused implementation recipes moved out of the entrypoint.