skills/eventkit/SKILL.md
Create, read, and manage calendar events and reminders using EventKit and EventKitUI. Use when adding events to the user's calendar, creating reminders, setting recurrence rules, requesting calendar or reminders access, presenting event editors, choosing calendars, handling alarms, observing calendar changes, or working with EKEventStore, EKEvent, EKReminder, EKCalendar, EKRecurrenceRule, EKEventEditViewController, EKCalendarChooser, or EventKitUI views.
npx skillsauth add dpearson2699/swift-ios-skills eventkitInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Create, read, and manage calendar events and reminders. Covers authorization, event and reminder CRUD, recurrence rules, alarms, and EventKitUI editors. Targets Swift 6.3 / iOS 26+.
Add the required usage description strings based on what access level you need:
| Key | Access Level |
|---|---|
| NSCalendarsFullAccessUsageDescription | Read + write events |
| NSCalendarsWriteOnlyAccessUsageDescription | Direct write-only event creation |
| NSRemindersFullAccessUsageDescription | Read + write reminders |
On iOS 17+, an app that only presents EKEventEditViewController to let the
person create an event does not need calendar authorization or calendar usage
strings. Direct EventKit writes need write-only or full calendar access; any
event read/fetch needs full calendar access. Reminders have only full access.
For apps also running on iOS 10 through iOS 16, include the legacy
NSCalendarsUsageDescription/NSRemindersUsageDescriptionkeys. If using EventKitUI on those systems, also includeNSContactsUsageDescriptionwhen the UI may need contact display names or avatars.
Create a single EKEventStore instance and reuse it. Do not mix objects from
different event stores.
import EventKit
let eventStore = EKEventStore()
iOS 17+ introduced granular access levels. Request the narrowest access that
matches the feature. If the deployment target includes earlier OS versions,
availability-guard the iOS 17+ methods and fall back to requestAccess(to:)
only before iOS 17.
Call try await eventStore.requestFullAccessToEvents() when the app needs to
read, edit, delete, or fetch calendar events.
Use when your app only creates events (e.g., saving a booking) and does not need to read existing events.
Call try await eventStore.requestWriteOnlyAccessToEvents() before direct
EventKit writes that do not use EKEventEditViewController.
With write-only access, EventKit can create events but cannot read calendars or events, including events the app created. Calendar reads return a virtual calendar and event fetches return no events.
Use full access instead of write-only if the app must later query, verify, modify, or sync saved events.
Call try await eventStore.requestFullAccessToReminders() before reading,
creating, editing, or deleting reminders.
Use EKEventStore.authorizationStatus(for: .event) or .reminder before work.
Handle .notDetermined, .fullAccess, .writeOnly, .restricted, .denied,
and @unknown default; only .fullAccess supports event/reminder reads.
func createEvent(
title: String,
startDate: Date,
endDate: Date,
calendar: EKCalendar? = nil
) throws {
let event = EKEvent(eventStore: eventStore)
event.title = title
event.startDate = startDate
event.endDate = endDate
event.calendar = calendar ?? eventStore.defaultCalendarForNewEvents
try eventStore.save(event, span: .thisEvent)
}
// List writable calendars
let calendars = eventStore.calendars(for: .event)
.filter { $0.allowsContentModifications }
// Use the first writable calendar, or the default
let targetCalendar = calendars.first ?? eventStore.defaultCalendarForNewEvents
event.calendar = targetCalendar
import CoreLocation
let location = EKStructuredLocation(title: "Apple Park")
location.geoLocation = CLLocation(latitude: 37.3349, longitude: -122.0090)
event.structuredLocation = location
Use a date-range predicate to query events. The events(matching:) method
returns occurrences of recurring events expanded within the range. Fetching
events requires full calendar access; write-only access returns no events.
Event predicates are capped to a four-year span, and events(matching:) /
enumerateEvents(matching:using:) are synchronous and return only committed
events.
func fetchEvents(from start: Date, to end: Date) -> [EKEvent] {
let predicate = eventStore.predicateForEvents(
withStart: start,
end: end,
calendars: nil // nil = all calendars
)
return eventStore.events(matching: predicate)
.sorted { $0.startDate < $1.startDate }
}
if let event = eventStore.event(withIdentifier: savedEventID) {
print(event.title ?? "No title")
}
func createReminder(title: String, dueDate: Date) throws {
let reminder = EKReminder(eventStore: eventStore)
reminder.title = title
reminder.calendar = eventStore.defaultCalendarForNewReminders()
let dueDateComponents = Calendar.current.dateComponents(
[.year, .month, .day, .hour, .minute],
from: dueDate
)
reminder.dueDateComponents = dueDateComponents
try eventStore.save(reminder, commit: true)
}
Reminder fetches are asynchronous and return through a completion handler.
func fetchIncompleteReminders() async -> [EKReminder] {
let predicate = eventStore.predicateForIncompleteReminders(
withDueDateStarting: nil,
ending: nil,
calendars: nil
)
return await withCheckedContinuation { continuation in
eventStore.fetchReminders(matching: predicate) { reminders in
continuation.resume(returning: reminders ?? [])
}
}
}
func completeReminder(_ reminder: EKReminder) throws {
reminder.isCompleted = true
try eventStore.save(reminder, commit: true)
}
Use EKRecurrenceRule to create repeating events or reminders.
// Every week, indefinitely
let weeklyRule = EKRecurrenceRule(
recurrenceWith: .weekly,
interval: 1,
end: nil
)
event.addRecurrenceRule(weeklyRule)
// Every 2 weeks, ending after 10 occurrences
let biweeklyRule = EKRecurrenceRule(
recurrenceWith: .weekly,
interval: 2,
end: EKRecurrenceEnd(occurrenceCount: 10)
)
// Monthly, ending on a specific date
let monthlyRule = EKRecurrenceRule(
recurrenceWith: .monthly,
interval: 1,
end: EKRecurrenceEnd(end: endDate)
)
// Every Monday and Wednesday
let days = [
EKRecurrenceDayOfWeek(.monday),
EKRecurrenceDayOfWeek(.wednesday)
]
let complexRule = EKRecurrenceRule(
recurrenceWith: .weekly,
interval: 1,
daysOfTheWeek: days,
daysOfTheMonth: nil,
monthsOfTheYear: nil,
weeksOfTheYear: nil,
daysOfTheYear: nil,
setPositions: nil,
end: nil
)
event.addRecurrenceRule(complexRule)
When saving changes to a recurring event, specify the span:
// Change only this occurrence
try eventStore.save(event, span: .thisEvent)
// Change this and all future occurrences
try eventStore.save(event, span: .futureEvents)
Attach alarms to events or reminders to trigger notifications.
// 15 minutes before
let alarm = EKAlarm(relativeOffset: -15 * 60)
event.addAlarm(alarm)
// At an absolute date
let absoluteAlarm = EKAlarm(absoluteDate: alertDate)
event.addAlarm(absoluteAlarm)
For reminder geofences, put an EKStructuredLocation and .enter / .leave
proximity on an EKAlarm, then add it to the reminder. See
references/eventkit-patterns.md for the full
location-based reminder pattern.
Present the system event editor for creating or editing events.
On iOS 17+, EKEventEditViewController can let someone create an event without
the app requesting calendar access. The editor runs out of process with its own
calendar access, so do not inspect the dismissed controller to learn what was
saved; refetch only if the app separately has full access.
import EventKitUI
class EventEditorCoordinator: NSObject, EKEventEditViewDelegate {
let eventStore = EKEventStore()
func presentEditor(from viewController: UIViewController) {
let editor = EKEventEditViewController()
editor.eventStore = eventStore
editor.editViewDelegate = self
viewController.present(editor, animated: true)
}
func eventEditViewController(
_ controller: EKEventEditViewController,
didCompleteWith action: EKEventEditViewAction
) {
switch action {
case .saved:
// Event saved
break
case .canceled:
break
case .deleted:
break
@unknown default:
break
}
controller.dismiss(animated: true)
}
}
import EventKitUI
let viewer = EKEventViewController()
viewer.event = existingEvent
viewer.allowsEditing = true
navigationController?.pushViewController(viewer, animated: true)
EKCalendarChooser requires write-only or full calendar access. In write-only
apps, the chooser behaves as writable-calendars-only and only allows a single
writable calendar selection.
let chooser = EKCalendarChooser(
selectionStyle: .multiple,
displayStyle: .allCalendars,
entityType: .event,
eventStore: eventStore
)
chooser.showsDoneButton = true
chooser.showsCancelButton = true
chooser.delegate = self
present(UINavigationController(rootViewController: chooser), animated: true)
Register for EKEventStoreChanged notifications to keep your UI in sync when
events are modified outside your app (e.g., by the Calendar app or a sync).
NotificationCenter.default.addObserver(
forName: .EKEventStoreChanged,
object: eventStore,
queue: .main
) { [weak self] _ in
self?.refreshEvents()
}
Always re-fetch events after receiving this notification. Previously fetched
EKEvent, EKReminder, and EKCalendar objects may be stale. The notification
is posted on the main actor.
On iOS 26+, you can also use the typed EKEventStore.EventStoreChanged /
.changed notification message behind availability checks.
// WRONG: Deprecated in iOS 17
eventStore.requestAccess(to: .event) { granted, error in }
// CORRECT: Use the granular async methods
let granted = try await eventStore.requestFullAccessToEvents()
On iOS 17+, requestAccess(to: .event) does not prompt and throws. Keep it only
as an availability-guarded fallback for apps that still run on earlier systems.
// 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)
// 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
// 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()
// 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)
Info.plist usage description keys added for calendars and/or remindersrequestAccess(to:) only as a pre-iOS 17 fallbackEKEventStore instance reused across the appallowsContentModifications checked)EKSpan (.thisEvent vs .futureEvents)commit()EKEventStoreChanged notification observed to refresh stale data.changed notification used only behind availability checksdevelopment
Implement, review, or improve data visualizations using Swift Charts. Use when building bar, line, area, point, pie, donut, or iOS 26 3D charts; when adding chart selection, scrolling, annotations, axes, scales, legends, or foregroundStyle grouping; when plotting functions with BarPlot, LinePlot, AreaPlot, PointPlot, Chart3D, or SurfacePlot; or when creating heat maps, Gantt charts, grouped bars, sparklines, threshold lines, or spatial visualizations.
data-ai
Select, implement, or migrate between app architecture patterns for Apple platform apps. Use when choosing between MV (Model-View with @Observable), MVVM, MVI, TCA (The Composable Architecture), Clean Architecture, VIPER, or Coordinator patterns; when evaluating architecture fit for a feature's complexity; when migrating from one pattern to another; or when reviewing whether an app's current architecture is appropriate. Scoped to Apple-platform patterns using Swift 6.3, SwiftUI, and UIKit.
development
Apply Swift API Design Guidelines to name, label, and document Swift APIs. Covers argument label rules (prepositional phrase rule, grammatical phrase rule, first-label omission), mutating/nonmutating pair naming (-ed/-ing participle pattern, form- prefix, sort/sorted, formUnion/union), side-effect naming (noun for pure, verb for mutating), documentation comment structure (summary by declaration kind, O(1) complexity rule), clarity at call site, role-based naming, protocol naming (-able/-ible/-ing), default arguments over method families, casing conventions, and terminology. Use when designing new Swift APIs, reviewing naming and argument labels, writing documentation comments, or refactoring for call site clarity.
development
Implement, review, or improve in-app purchases and subscriptions using StoreKit 2. Use when building paywalls with SubscriptionStoreView or ProductView, processing transactions with Product and Transaction APIs, verifying entitlements, handling purchase flows (consumable, non-consumable, auto-renewable), implementing offer codes or promotional/win-back/introductory offers, managing subscription status and renewal state, setting up StoreKit testing with configuration files, or integrating Family Sharing, Ask to Buy, refund handling, and billing retry logic.