When I have a UIManagedDocument (which is inside an ubiquitous container) open on device A, while making changes to that document on device B, the changes are not imported into the CoreData stack on device A.
I see that changes arrive on device A because the method presentedSubitemDidChangeAtURL() is called on the document.
If I close and re-open the document, I see those changes.
But I expect that UIManagedDocument automatically merges those changes into the managed object context, while the document is open. Is this not the case? The documentation doesn't say that I have to do that by myself.
I create my document with
let document = UIManagedDocument(fileURL:...)
document.persistentStoreOptions = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]
and move it to iCloud with
let fileManager = NSFileManager()
fileManager.setUbiquitous(true, itemAtURL: documentURL, destinationURL: url)
After getting help from Apple Developer Technical Support, it turns out that you have to include the
NSPersistentStoreUbiquitousContentNameKeywhen setting up the persistent store.