Hi,
I have a mac os app that I am developing. It is backed by a SwiftData database. I'm trying to set up cloudkit so that the app's data can be shared across the user's devices. However, I'm finding that every tutorial i find online makes it sound super easy, but only discusses it from the perspective of ios.
The instructions typically say:
-
Add the iCloud capability.
-
Select CloudKit from its options.
-
Press + to add a new CloudKit container, or select one of your existing ones.
-
Add the Background Modes capability.
-
Check the box "Remote Notifications" checkbox from its options.
I'm having issue with the following: I don't see background modes showing up or remote notifications checkbox since i'm making a mac os app.
If i do the first 3 steps only, when i launch my app i get an app crash while trying to load the persistent store. Here is the exact error message:
Add the iCloud capability.
Select CloudKit from its options.
Press + to add a new CloudKit container, or select one of your existing ones.
Add the Background Modes capability.
Check the box "Remote Notifications" checkbox from its options.
Any help would be greatly appreciated.
var sharedModelContainer: ModelContainer = {
let schema = Schema([One.self, Two.self])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
The fatal error in the catch block happens when i run the app.
The error message doesn't contain any useful information, and so I don't have more to comment.
We don't have a documentation specific for macOS, because the configuration process is pretty much the same, except that, as you have noticed, the Background Mode
is not available on macOS.
You can probably start with the following:
Best,
——
Ziqiao Chen
Worldwide Developer Relations.