I have been fighting this one for the last 4 months!
Has anyone seen this error (MacOS - 10.15.3) and knows how to get around it. I just want to programatically create and delete iCloud calendars from my Mac, using an app I am developing. Works fine on iOS.
Error Domain=EKErrorDomain Code=72 "Can't delete a calendar if doing so would leave the account with no calendars which are eligible to be the default scheduling calendar."
To reproduce, in xcode, targeting MacOS:
- create an EKEventStore
- run through the sources to select the "iCloud" source
- create an EKCalendar instance, set the src and title
- Save it: saveCalendar
You can see the calendar appear in the Calendar app. All good.
- get a list of all the existing calendars
- select the one just created by its title
- try .removeCalendar
You get the error above.
Info.plist privacy settings are correct as well as entitlements, as we can create the calendar.
If I run this same code on an iOS device - works perfectly., however I want to be able to delete a calendar via my app on the Mac.