Has anyone gotten SwiftData to work with SwiftUI's DocumentGroup? Even the (unmodified) Xcode Multiplatform document app template using SwiftData crashes when working with a saved document. I suspect that the DocumentGroup extension for SwiftData is not creating the context on the main thread, but only when re-opening saved documents. On macOS it crashes with the above mentioned error, but I have also seen this manifest as threading deadlocks (on the iPad and macOS).
With the all the work that was apparently put into SwiftData I'm incredulous that this would just flat out not work. I am hoping I am missing something, but (based on the unpopularity of UIManagedDocument) I fear that most people are simply not working with SwiftData in document-based apps or not using it with DocumentGroup (e.g. using it alongside Core Data).
I am hoping there is a work-around, as I have already invested a lot of time converting from Core Data.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: