Post

Replies

Boosts

Views

Activity

CoreData with CloudKit in WidgetKit not working
In my app, I have an NSPersistentCloudKitContainer set up in the following way:     let container: NSPersistentCloudKitContainer     init() {         self.container = NSPersistentCloudKitContainer(name: "Model")         self.container.persistentStoreDescriptions[0].setOption(             true as NSNumber,             forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey         }         self.container.loadPersistentStores { (_, error) in             guard error == nil else {                 print("error loading store: \(error.debugDescription)")                 return             }         }                  self.container.viewContext.automaticallyMergesChangesFromParent = true     } When I invoke a fetch request on the context of the container in my iOS target, it works as expected. However, when I perform the same fetch request in my Widget target, it returns an empty array result. In my iOS target, I have Background Modes / Remote Notifications and iCloud / CloudKit capabilities. In my Widget target, I have the iCloud / CloudKit capability. Not sure why it isn't working, so any help would be much appreciated, thanks!
3
0
945
Sep ’20