Posts

Post not yet marked as solved
2 Replies
944 Views
Hi, I have a Swift 5 project which accesses the user Calendar on a Mac Mojave via EKEventstore. I use the following code to initializes the access to the calendar:var eventStore = EKEventstore() func requestAccessToCalendar() { eventStore.requestAccess(to: .event, completion: { granted, error in }) } func loadCalendars() { calendars = eventStore.calendars(for: .event) } let ekstatus = EKEventStore.authorizationStatus(for: EKEntityType.event) switch (ekstatus) { case EKAuthorizationStatus.notDetermined: // This happens on first-run requestAccessToCalendar() case EKAuthorizationStatus.authorized: // Things are in line with being able to fetch all client events in the next period upfront loadCalendars() getFutureVisits() case EKAuthorizationStatus.restricted, EKAuthorizationStatus.denied: // We need to help them give us permission dialogOK("access denied") @unknown default: dialogOK("general access problem") }On the first run, the app logs permission problems in the XCode console, then asks the user to grant permission, which is granted but no calendar entries found. Any subsequent runs work fine as expected. The errors are reported directly when the eventStore instance is initialized. II've tried several options with lazy vars or constants, but all resulted in the same problem. The Apple developper documents unfortunatly show outdated ways to init the EKEventstore and I found nowhere a solution which works with Swift 5 and OS 10.14 Did anyone succeed to have the instance initiated the first time without errors? I would appreciate a code sample.
Posted
by tantares.
Last updated
.
Post not yet marked as solved
4 Replies
2.0k Views
Hello,My goal is to extract names from OSX Contacts. Following the hints, I try to use the CNContactStore. I'm working with Xcode 10.1 and Swift. Unfortunatley I found no way of exploring code in a Xcode Playlist, since there is no info.plist created and hence I can't enter the required privilege key, which is required for accessing the ContactStore. Does anyone know how to get privilege access in Playlist codes?When I try the code in a "Command Line Tool", I face the same problem. However when I create a running exec, it does work. Trying the same code in a Cocoa App using the priv key in info.plist, results in the following error:2019-05-13 23:54:10.586962+0200 Show Clients[2324:83437] [default] Unable to load Info.plist exceptions (eGPUOverrides) CNAuthorizationStatus2019-05-13 23:54:30.347100+0200 Show Clients[2324:83437] Could not get real path for Address Book lock folder: open() for F_GETPATH failed.2019-05-13 23:54:30.347101+0200 Show Clients[2324:83437] Unable to open file lock: {recursion count = 0, name = nil}, fileDescriptor=-1> Error Domain=NSPOSIXErrorDomain Code=14 "Bad address" UserInfo={ABFileDescriptor=-1}So I'm really stuck and would appreciate any helpTony
Posted
by tantares.
Last updated
.