Hi everyone
My goal is to create a document based app (iOS and macOS) with a complex data model stored in CoreData. The model consists of various entities and relations.
The "basic" requirement I have: The user can choose a document from anywhere he likes (eg "Files" app on iOS; hard disk or cloud location on macOS) and starts working on the document. When the document is modified on another device, it must be ensured that the app detects this and automatically merge the changes (or shows possible conflicts).
Based on this requirements, I remembered that Apple used to have UIDocument
and UIManagedDocument
in UIKit land to help managing documents and ensuring they can update automatically based on changes in iCloud. UIDocument
is used for simple data models which are fully kept in memory and which can be "snapshotted", put into file(s) and then restored again by loading from the file(s). This is very similar to to how ReferenceFileDocument
works: the system calls snapshot(contentType:)
to capture the document state and then asks for the "file representation" when it calls fileWrapper(snapshot:, configuration:)
...
But looking at ReferenceFileDocument
or FileDocument
I don't see any discussion on how merging or conflict resolution is handled.
Also there is still the issue of the missing CoreData functionality. I cannot keep my data model fully in memory.
So now I'm wondering is the time of UIDocument
and UIManagedDocument
something of the past? And if not, how would one make them fit with the SwiftUI-way of document based apps?
In the end I only wonder: how can I get a CoreData document based SwiftUI app? Should I try to make UIManagedDocument
become ReferenceFileDocument
compatible? (which I'm currently trying but I'm struggling)
Or can I use NSPersistenContainer
in some way?
Kind regards
Philipp