NSUnknownKeyException: not key value coding-compliant for the key "(null)"

In Xcode 15 beta 3 and iOS 17 beta 3, my app with SwiftData keeps generating error:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSManagedObject 0x2811cb390> setValue:forUndefinedKey:]: the entity dataSets is not key value coding-compliant for the key "(null)".'

I have a model:

@Model final class Station: Sendable {
    ...
    var dataSets: [String]
}

The error seems to occur when saving entities of the model in SwiftData. There is no entity named "dataSets". Only a property in the above model. What's the null key in the error?

I'm running into the same issue. Did you find the cause?

I think it has something to do with arrays and SwiftData. When I add @Transient the error goes away but now the data set isn't saved which is the opposite of intended 🙃

@Model
final class Foo {
  @Transient
  var bar: [String]? = nil
} 

Xcode 15 beta 6 reports a new error for the array property:

CoreData: fault: One or more models in this application are using transformable properties with transformer names that are either unset, or set to NSKeyedUnarchiveFromDataTransformerName. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead. At some point, Core Data will default to using "NSSecureUnarchiveFromData" when nil is specified, and transformable properties containing classes that do not support NSSecureCoding will become unreadable.

CoreData: warning: Property 'dataSets' on Entity 'Station' is using nil or an insecure NSValueTransformer. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.

NSUnknownKeyException: not key value coding-compliant for the key "(null)"
 
 
Q