Hi
Am having problems creating an EKEventStore to access the calendars.
To simplify the problem I created an OS X project in swift 4 with one button on the view. In the View controller I have imported EventKit. There is an @IBAction, as shown below, linked to the button. The sandbox is on with access to calendar checked.
@IBAction func testEK(_ sender: Any) {
let eventStore = EKEventStore.init()
}
When the button is clicked the following appears in the debug console area
2018-11-13 19:19:56.985235+0000 EKTest[6916:407014] CoreData: XPC: Unable to load metadata: Error Domain=NSCocoaErrorDomain Code=134070 "An error occurred in the persistent store." UserInfo={Problem=request failed, insufficient permission}
2018-11-13 19:19:56.985845+0000 EKTest[6916:407014] [error] error: -addPersistentStoreWithType:NSXPCStore configuration:(null) URL:file:///Users/jimgraham/Library/Calendars/Calendar%20Cache options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentHistoryTrackingKey = {
NSPersistentHistoryTrackingEntitiesToExclude = (
ChangeRequest
);
};
agentOrDaemon = 1;
serviceName = "com.apple.CalendarAgent.database";
} ... returned error Error Domain=NSCocoaErrorDomain Code=134070 "An error occurred in the persistent store." UserInfo={Problem=request failed, insufficient permission} with userInfo dictionary {
Problem = "request failed, insufficient permission";
}
CoreData: error: -addPersistentStoreWithType:NSXPCStore configuration:(null) URL:file:///Users/jimgraham/Library/Calendars/Calendar%20Cache options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentHistoryTrackingKey = {
NSPersistentHistoryTrackingEntitiesToExclude = (
ChangeRequest
);
};
agentOrDaemon = 1;
serviceName = "com.apple.CalendarAgent.database";
} ... returned error Error Domain=NSCocoaErrorDomain Code=134070 "An error occurred in the persistent store." UserInfo={Problem=request failed, insufficient permission} with userInfo dictionary {
Problem = "request failed, insufficient permission";
}
What is wrong and what do I need to do to create event store constant?