Problems accessing Calendar using EKEventStore on OSX Sierra with Swift 3 : <p>This appears very simple, but I've been struggling for several days to get access to the Calendar on OSX.  I have switched on the App Sandbox capability, and I've ticked the "Calendar" box in App Data.  I have created very simple app with the following view controller class:</p>

<pre><code>import Cocoa
import EventKit

class ViewController: NSViewController {

    var eventControl = EKEventStore()
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }
}
</code></pre>

<p>As you can see, the only lines of code I've added are to import EventKit and to initialise eventControl.</p>

<p>When I run this in debug, I get an error at the eventControl initialisation line</p>

<pre><code>2016-10-28 15:02:00.056521 calendarTest[4105:847101] CoreData: XPC:     Unable to load metadata: Error Domain=NSCocoaErrorDomain Code=134070 "An error occurred in the persistent store." UserInfo={Problem=request failed, insufficient permission}
2016-10-28 15:02:00.057742 calendarTest[4105:847101] [error] error: -addPersistentStoreWithType:NSXPCStore configuration:(null) URL:file:///Users/patrickramsden/Library/Calendars/Calendar%20Cache  options:{
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
    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";
}
</code></pre>

<p>I can't work out how to get the right permissions.  </p>

<p>I am using Xcode 8.1 and macOS Sierra 10.12.1 </p>
