3

I am using SwiftData in my project. All worked fine under Xcode 15 beta 4 in the simulator. Since I changed to Xcode 15 beta 5 I am getting the following error multiple times:

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. 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release

I understand this is an error in the underlying CoreData setup. However, how can I change the CoreData config? If you use CoreData directly you can change the config, but how do you do this, when you use SwiftData. And why does Apple not use the proper config from the start?

I am using standard code that defines my model:

@Model final class LoggerItem {
    @Attribute(.unique) let id: UUID
    var title: String
    var created: Date
    var modified: Date?
    ...
}

This already creates above error messages.

Mike
  • 51
  • 5
  • Not sure I understand, are you or aren’t you using transformable properties in your model? – Joakim Danielson Jul 29 '23 at 11:18
  • That being said, there seems to be some changes in the Model macro and/or relating to PersistentModel that can give some really strange errors when moving from beta 4 to 5. – Joakim Danielson Jul 29 '23 at 11:23
  • The model only uses UUID, Double, String and Date, and the @Attribute (.unique) is the only attribute. Since I did not get the same error in beta 4, I assume it is down to the changes you mention. What they basically say is, that I should switch to "NSSecureUnarchiveFromData", which is something I could do myself if I used Core Data. With SwiftData however, I assume this config has to be done by Apple, as SwiftData is kind of a wrapper around Core Data. – Mike Jul 29 '23 at 13:46
  • 1
    The same error occurs when using an `[Int]` type variable. We should report the bug. Let's hope that the problem will be solved in Xcode beta 6, as it's out of our hands. – parapote Jul 31 '23 at 14:57
  • Hey guys, I'm experiencing the same error in XCode Beta 7, any ideas for a workaround or a fix? – bogdan Aug 25 '23 at 11:19
  • beta 7 actually fixed it for me. – Mike Aug 25 '23 at 15:14

1 Answers1

1

Apparently this has been fixed in Xcode 15 beta 7

Mike
  • 51
  • 5