I updated today at Xcode 16 beta 6, and my app using SwiftData on iOS 18 (beta 6) is getting now this new error when saving the model in the modelContext.
I don't understand if it is a regression introduced in the beta 6 or if it is enforced something that previously wasn't.
It seems to be always referred to the ID property, for example:
SwiftData/ModelCoders.swift:1762: Fatal error: Passed nil for a non-optional keypath \MyModel.id
In this case (and in most of the cases in my models) the ID is defined as following
@Attribute(.unique)
public var id: UUID
I also tried to add the initialization inline, but didn't help
@Attribute(.unique)
public var id: UUID = .init()
I also tried to remove the @Attribute(.unique)
, didn't help as well.
Does any of you have the same issue?