Post

Replies

Boosts

Views

Activity

Reply to Push to CloudKit from Share Extension
I shared some thoughts on this a month ago in another answer. In summary: Saving to Core Data itself is reliable from an extension The extension likely is killed before the sync to CloudKit is scheduled/complete. This is why you see the behavior of needing to launch your app for syncing to occur. There is no workaround at this point, as the syncing is done in their internal API, but I'm hoping my conversation with the Apple engineer was enough for them to consider improvements this year.
May ’21
Reply to Is it safe to use a NSPersistentCloudKitContainer on a Share Extension?
Having used this API for two of my apps, and speaking with an Apple engineer, it sounds like we can assume the following: NSPersistentCloudKitContainer can be safely used in a Share Extension for storing data locally. It will complete the save operation locally. Uploading to CloudKit requires a scheduled background operation on the part of the API. Because of this, by the time the Extension is terminated, the background operation is not completed, and thus the CloudKit sync does not occur. In my testing, this leads to predictable behavior: Data is never uploaded from an Extension, however, Data is saved locally in your persistent container. And upon launching your app, with the container alive once more, it will sync your data to CloudKit. It's a bit unwieldy having to launch your app after an operation in an Extension, but from my own usage, I think it's safe to say that you can safely use NSPersistentCloudKitContainer, even if it doesn't sync as you or I would like. I truly hope this behavior is improved soon.
Apr ’21
Reply to NSPersistentCloudKitContainer reverts NSManagedObject subclass to old value
The behavior you have is very similar to what I have observed. I will launch my app, make an update to my managed object, and then it is overwritten by data from CloudKit that is older than the update. I would assume that that NSMergeByPropertyObjectTrumpMergePolicy would mean my local, newer changes would survive any merge, but either my assumption is wrong or the merge policy doesn't apply.
Sep ’20
Reply to How to debug NSPersistentCloudKitContainer background updates?
I, too, followed the sample app and documentation and have issues with background syncing. When the app is in the foreground, I can get updates every 10-15 seconds, but when in the background, I never seem to get an update. This has caused an issue with my app where, when the user launches it and updates data, it's soon overwritten by updates from CloudKit. I will be working on filing feedback for this over the next week.
Sep ’20