Search code examples
swiftmacoseventkitekreminder

Add Reminder List programmatically


I'm building an application that interacts with the macOS Reminder App. I'm trying to create a new Reminder list into which I later can import reminders.

This is what I have so far:

func setCalendar(_ type: EKEntityType) {

    let eventStore = EKEventStore()

    let newCalendar = EKCalendar(for: type, eventStore: eventStore)
    newCalendar.title="newcal"
    print("Cal: " + newCalendar.title)

    try? eventStore.saveCalendar(newCalendar, commit: true)

}

However, there is no reminder list being created.


Solution

  • The problem is that you have omitted to specify the new calendar's .source. You cannot create a calendar of any kind (event or reminder) without doing that.