Post

Replies

Boosts

Views

Activity

How to sync data between iOS and OSX apps with CloudKit?
We have an iOS App developed in SwiftUI that saves data to CloudKit using NSPersistentCloudKitContainer. If I modify any of this data, the changes are synchronized on other iOS devices without problem. We also have an OSX App with StoryBoard using NSPersistentCloudKitContainer to share the same data with iOS devices. Changes made on OSX are updated immediately on iOS devices. But if any data is modified in iOS, it is not updated in the OSX application. Simply by doing Command-Tab twice the OSX app displays the new data. It appears that CloudKit Push Notifications are not causing the OSX application to detect that there are changes to the data and that it needs to be updated. In both cases an NSFetchedResultsController is created and a delegate is placed. The iOS one is called but the OSX one is not. The only difference in the code is that in the iOS app with SwiftUI it is done: var body: some Scene { WindowGroup { InitialTab() .environment(\.managedObjectContext, DataManager.shared.viewContext) } } but this is not done in OSK since NSView does not have the .environmet method. Could this be the problem? What should I do to update data without switching applications on OSX? Any help would be appreciated, Thank you so much.
0
0
302
Jan ’24