I have an app using iCloud and Core Data through NSPersistentCloudKitContainer
. The container and related code are in a shared framework and most things are running fine. In addition to the app itself, I have a share extension and an intents extension.
The thing I'm having trouble with is if one of the extensions writes to the database while the app is active. NSPersistentCloudKitContainer
seems to do some magic in both processes, and when it finds the magic already done, it fails to update certain data. For example, I have one-to-one relationships between two managed objects (which need to have inverses with cloudkit backed models). One side of the relationship becomes valid while the other one is nil.
I get errors in the console saying that CloudKit+CoreData could not merge differences between the database and the cache of the container. I'm pretty sure this is a oversight in NSPersistentCloudKitContainer
where this particular scenario (shared framework, multiple open processes) wasn't taken into consideration.
Has anyone had any luck using NSPersistentCloudKitContainer
and saving data with relationships from extensions?