Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Error - Never access a full future backing data

Hi, I am building an iOS app with SwiftUI and SwiftData for the first time and I am experiencing a lot of difficulty with this error:

Thread 44: Fatal error: Never access a full future backing data - PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(backing: SwiftData.PersistentIdentifier.PersistentIdentifierBacking.managedObjectID(<ID> <x-coredata://<UUID>/MySwiftDataModel/p1>)), backing: SwiftData.PersistentIdentifier.PersistentIdentifierBacking.managedObjectID(<ID> <x-coredata://<UUID>/MySwiftDataModel/p1>)) with Optional(<UUID>)

I have been trying to figure out what the problem is, but unfortunately I cannot find any information in the documentation or on other sources online. My only theory about this error is that it is somehow related to fetching an entity that has been created in-memory, but not yet saved to the modelContext in SwiftData. However, when I am trying to debug this, it's not clear this is the case. Sometimes the error happens, sometimes it doesn't. Saving manually does not always solve the error.

Therefore, it would be extremely helpful if someone could explain what this error means and whether there are any best practices to do with SwiftData, or some pitfalls to avoid (such as wrapping my model context into a repository class).

To be clear, this problem is NOT related to one area of my code, it happens throughout my app, at unpredictable places and time. Given that there is very little information related to this error, I am at a loss at how to make sure that this never happens.

This question has been asked on the forum here as well as on StackOverflow, Reddit (can't link that here), but none of the answers worked for me.

For reference, my models generally look like this:

import Foundation
import SwiftData

@Model
final class MySwiftDataModel {
    // Stable cross-device identity
    @Attribute(.unique)
    var uuid: UUID

    var someNumber: Int

    var someString: String

    @Relationship(deleteRule: .nullify, inverse: \AnotherSwiftDataModel.parentModel)
    var childModels: [AnotherSwiftDataModel]

    init(uuid: UUID = UUID(), someNumber: Int = 1, someString: String = "Some", childModels: [AnotherSwiftDataModel] = []) {
        self.uuid = uuid
        self.someNumber = someNumber
        self.someString = someString
        self.childModels = childModels
    }

    func addChildModel(model: AnotherSwiftDataModel) {
        self.childModels.append(model)
    }

    func removeChildModel(by id: PersistentIdentifier) {
        self.childModels = self.childModels.filter { $0.id != id }
    }
}

and the child model:

import Foundation
import SwiftData

@Model
final class AnotherSwiftDataModel {
    // Stable cross-device identity
    @Attribute(.unique)
    var uuid: UUID

    var someNumber: Int

    var someString: String

    var parentModel: MySwiftDataModel?

    init(uuid: UUID = UUID(), someNumber: Int = 1, someString: String = "Some") {
        self.uuid = uuid
        self.someNumber = someNumber
        self.someString = someString
    }
}

For now, you can assume I am not using CloudKit - i know for a fact the error is unrelated to CloudKit, because it happens when I am not using CloudKit (so I do not need to follow CloudKit's requirements for model design, such as nullable values etc).

As I said, the error surfaces at different times - sometimes during assignments, a lot of times during deletions of related models, etc.

Could you please explain what I am doing wrong and how I can make sure that this error does not happen? What are the architectural patterns that work best for SwiftData in this case? Do you have any examples of things I should avoid?

Thanks

I have encountered this error before, but not with my new setup, but it’s possible that your new related models have not been saved to the store yet and SwiftData is enforcing constraints back to the ModelContext when it doesn’t exist in the store.

Error - Never access a full future backing data
 
 
Q