Just moved to Xcode 11 and getting the following crash at launch:
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 'color' on Entity 'Group' is using nil or an insecure NSValueTransformer. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.
I'm creating an NSPersistentContainer
at launch using the code below:
private let container: NSPersistentContainer = { let container = NSPersistentContainer(name: "MyApp", managedObjectModel: MyAppModelVersion.current.managedObjectModel()) let storeDescription = NSPersistentStoreDescription(url: getStoreURLWithUserName()) storeDescription.shouldMigrateStoreAutomatically = true storeDescription.shouldInferMappingModelAutomatically = true container.persistentStoreDescriptions = [storeDescription] return container }()
Error occurs right after this line is executed:
let container = NSPersistentContainer(name: "MyApp", managedObjectModel: MyAppModelVersion.current.managedObjectModel())
I also have a property called 'Colorin a
Group` entity that's transformable:
@NSManaged public var color: UIColor? @NSManaged public var hexColorValue: String?
Below is how set the property:
public var hexColor: String? { get { return self.hexColorValue } set { self.hexColorValue = newValue if let str = newValue { self.color = UIColor(hex: str) } } }
This is what the property looks like in Core Data:
I am not sure how to recover from this crash. This was working fine with Xcode 10
Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence.
Core Data is not a database. Core Data is a framework for managing an object graph. An object graph is nothing more than a collection of interconnected objects. The framework excels at managing complex object graphs.
Getting Started Core Data (CRUD) with Swift. Core Data is a graphical and persistence framework, which is used in Apple devices with operating systems macOS and iOS. Core Data was first introduced in Mac OS X 10.4 Tiger and iOS with iPhone SDK 3.0.
Setting Transformer property to NSSecureUnarchiveFromDataTransformer solved the warning in my case. For this select the attribute & set its transformer type to NSSecureUnarchiveFromDataTransformer & run again by pressing commond+R.
Thanks, Ratneshwar
Swift 5.4.2
This worked for me.
EDIT Link to the article is here.
Your warnings/errors should go away. If not, try cleaning your build folder and rebuild.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With