SwiftData fatal error "Never access a full future backing data"

My app started crashing a ton with Xcode 16 beta 1 / iOS 18 because of "Thread 1: Fatal error: Never access a full future backing data". I was hoping this would be resolved with beta 2, but unfortunately this is not the case. I'm having a tough time reproducing this bug in a small sample project – I'd appreciate any hints as to what might be causing this.

Full error:

Thread 1: Fatal error: Never access a full future backing data - PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://10A5A93C-DC7F-40F3-92DB-F4125E1C7A73/MyType/p2), implementation: SwiftData.PersistentIdentifierImplementation) with Optional(3BF44A2D-256B-4C40-AF40-9B7518FD9FE6)

I see this when updating relationships after upserting a model object in a context. If the model object already exists and the upsert is an update the relationship updates fail with the error. If the model object does not already exist and the upsert is an insert then the relationships update fine. This looks like a bug and I cannot see any way around it.

Also getting this quite often when deleting a model

Have logged FB14083137 for the error that I am seeing. Same code that fails in iOS18 works fine on iOS17.

I'm having the same problem, specifically when attempting to delete a model instance.

It seems to be an instance that existed prior to a change to the model properties. Instances created after the change to model properties are deleted ok, but this one has become "sticky".

I am having the same problem. For me, it occurs when I attempt to delete a SwiftData model with a one-to-many relationship with other SwiftData models. The same code that throws the error in MacOS 15 works fine in MacOS 14, so I am inclined to believe it is a bug.

I have the same issue... any way to resolve this?

Is this something they will fix or we have to find workaround?

Had similar issue when trying to delete a model Instance which has a one-to-many relationship (Deleting a Collection that holds multiple Items).

What I did is the following:

  1. Initialize the ModuleContainer as below.
struct MyApp: App {
    
    private var sharedModelContainer: ModelContainer = {
        let schema = Schema([
            Collection.self, Item.self
        ])
        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)

        do {
            let container = try ModelContainer(for: schema, configurations: [modelConfiguration])
            container.mainContext.autosaveEnabled = false
            return container
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }
    }()
    
    // PROPERTIES
    @State private var container: ModelContainer
    
    // INITIALIZATION
    init() {
        self.container = sharedModelContainer
    }
    
//MARK: - VIEW
    var body: some Scene {
        WindowGroup {
            RootView(modelContext: container.mainContext)
        }
        .modelContainer(container)
    }
}
  1. Make sure the child Model has the inverse relationship & the parent is Optional
@Model
class Item {
    @Attribute(.unique) var id: UUID
    var creationDate: Date
    var name: String
    var quantity: Int
    var frequency: String
    var intervalDays: Int
    var packed: Bool
    
    // Parent
    @Relationship var collection: Collection?
    

And it worked for me. Let me know if this hint helped. Thank you!

SwiftData fatal error "Never access a full future backing data"
 
 
Q