How to Prevent Eventstore Access Error on First Run

Problems accessing Calendar using EKEventStore on OSX Sierra with Swift 3

You need to add a usage description to your info.plist. This is a small description of why you need access to the services that is presented to the user.

<key>NSCalendarsUsageDescription</key>
<string>Description of why you need access to the Calendar</string>

eventStore.saveCalendar returns an error json error: An unexpected error occurred.

Two possible reasons

  1. From the documentation of EKEventStore

    To access the user’s Calendar data, all sandboxed macOS apps must include the com.apple.security.personal-information.calendars entitlement. To learn more about entitlements related to App Sandbox, see Enabling App Sandbox.

  2. Check the authorizationStatus of the store and call requestAccess if necessary.


Your error message is misleading, the error has nothing to do with JSON.

iOS: EKEventStore sources / defaultCalendarForNewEvents / calendarsForEntityType all return nothing AFTER authorization

OK, it turns out there was a small line of code in a viewDidLoad that was before the [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error code and that tried to access the eventStore. It was superfluous and did not need to be happening and I had not noticed it. Once I removed this code the stuff now works, so it does go back to needing to authorize, as even after authorization, the eventStore was already "bad" due to this previous access.



Related Topics



Leave a reply



Submit