I'm seeing this error reported by a lot of my users. I have a pretty simple EventKit integration where a user can add an event to their calendar. I offer this functionality by pre-populating an EKEvent with some data, and then present it to the user via an EKEventEditViewController. This mostly works just fine, but every so often a user runs up against a "Cannot save Event - No Calendar has been set" alert presented when trying to save from the EKEventEditViewController.
It's surprising that this error would be seen at all, since the EKEventEditViewController documentation states at the top "If the new event has no calendar, the default calendar is used." Regardless of that, when I create the EKEvent object, I assign the calendar manually by querying EKEventStore's defaultCalendarForNewEvents property.
It's very difficult to reproduce the alert myself. The only thing I've been able to do is erase all content and settings from a phone, do some combination of logging into and out of a Google account, and then if I set a breakpoint and call defaultCalendarForNewEvents, it might return nil. In the cases where it does return nil, I will see the "Cannot save Event" error.
So question is - why would the defaultCalendarForNewEvents ever return nil? And, if there is a valid case where it returns nil, is there a potential recovery path for me to take?