Post

Replies

Boosts

Views

Activity

Reply to error: the replacement path doesn't exist:
I think I have made some progress with this by introducing manual saves when working on the model, so for example, instead of: selectedItem = item I have replaced with: do { try modelContext.transaction { selectedItem = item } catch { print("unable to save change due to error \(error)") } Items are now successfully persisting, and the error: SwiftData/ModelContext.swift:3253: Fatal error: Failed to identify a store that can hold instances of SwiftData. Seems to have gone away. It seems like the error was something to do with the way that changes are stashed and saved in the background by SwiftData, I am not an expert but my best guess is that it is related to the recent changes in concurrency architecture. I have also found SwiftData to be much more reliable if you work directly on elements derived from @Query in the view, rather than trying to save on @Bindable from a parent. I pass the UUID around the views and then filter the arrray from @Query for the id.
Sep ’24
Reply to error: the replacement path doesn't exist:
I have a SwiftData document-based app with iCloud documents enabled, and lots of one-to-many @model relationships. I have the same issue as reported, and I am getting the error: Publishing changes from background threads is not allowed; make sure to publish values from the main thread I also get a crash shortly after with the breakpoint message: SwiftData/ModelContext.swift:3253: Fatal error: Failed to identify a store that can hold instances of SwiftData. I wonder if the two errors are related. I have not tested on the simulator, but have tested on iPad Pro M1 and iPhone 12 Both errors have only appeared in ios18, and the app has been running great for many months in ios17 with no crashes. Suddenly ios18 is released and the entire app is broken. Grrrrr.
Sep ’24
Reply to Document-based SwiftData apps fail to identify a store on iPad?
I have the same issue, it has completely broken my project. I have upgraded to Swift 6, but that didnt help. I have tried manually creating a container, but the container is not unique to the document. I have a large data model with many relationships, it stores simple data and image data. It has been working great for a year, and then completely crashes on IOS18! I am at a loss, please help!
Sep ’24
Reply to Xcode 15 beta 5 missing cascade property option in @Relationship(.cascade) error.
It seems that you can make all of the variables optional where they are declared in the @Model class (eg var variable: String?), and then use nil coalescing to unwrap when the properties are called (?? ""), but then you get a compile time error when you call the parameter from @Bindable in the View using a binding. The below will not compile, even with the ?? "". struct egView: View { @Bindable var VM: ViewModel var body: some View { ButtonStruct(Variable: $VM.variable ?? "" ) } Performing nil coalescing in the ButtonStruct doesnt seem to work either, so I am stumped.
Aug ’23
Reply to SwiftData Fatal error: failed to find a currently active container
I had the same issue after the XCode beta 5 update. My issue has three models in an array, so a slightly different solution: import SwiftData import SwiftUI @main struct SurvAIApp: App { let modelContainer: ModelContainer init() { do { modelContainer = try ModelContainer(for: [ViewModel1.self,ViewModel2.self, ViewModel3.self]) } catch { fatalError("Could not initialize ModelContainer") } } var body: some Scene { WindowGroup { NavigationStack { ContentView() } .modelContainer(modelContainer ) } }
Jul ’23