Core Data error switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead
Asked Answered
O

2

10

I am getting this CoreData error. I have no idea why I'm getting this error. I'm not using any Transformable types. I see nothing in my code indicating that I'm using transformable properties. I let Xcode set up CoreData by selecting the Use Core Data option when I created my project. The other similar questions do not help because the answers have to do with code that look like anything that I can find that Xcode created when the project was created. The project does not crash when this error appears in the debug window. I am using Xcode 11.3 and Google Maps SDK for iOS for iOS 12, and it's running on an iPhone 8 device with iOS 13.3.

CoreData: annotation:  Failed to load optimized model at path '/var/containers/Bundle/Application/A2B8A56C-E0D5-467A-9300-8EDFB20574BE/Routes.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
2020-01-13 12:42:00.771883-0600 Routes[4631:1067373] [error] 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: 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.
2020-01-13 12:42:00.771972-0600 Routes[4631:1067373] [error] CoreData: 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 'value' on Entity 'GMSCacheProperty' is using nil or an insecure NSValueTransformer.  Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.
CoreData: annotation:  Failed to load optimized model at path '/var/containers/Bundle/Application/A2B8A56C-E0D5-467A-9300-8EDFB20574BE/Routes.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
CoreData: warning: Property 'value' on Entity 'GMSCacheProperty' is using nil or an insecure NSValueTransformer.  Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.
CoreData: annotation:  Failed to load optimized model at path '/var/containers/Bundle/Application/A2B8A56C-E0D5-467A-9300-8EDFB20574BE/Routes.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
CoreData: warning: Property 'value' on Entity 'GMSCacheProperty' is using nil or an insecure NSValueTransformer.  Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.

This is the code that triggers the error:

do {

    storeAddresses = try managedObjectContext.fetch(Address.fetchRequest())

} catch {

    print(error)

}

I am using the following core data objects:

Address entity

position attribute

type Integer 16

text attribute type String

timestamp attribute type Date

route relationship destination Route inverse addresses

Route entity

timestamp attribute type Date

title attribute type String

addresses relationship destination Address inverse route

I have the following code for managed object classes:

public class Address: NSManagedObject {

}

extension Address {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Address> {
        return NSFetchRequest<Address>(entityName: "Address")
    }

    @NSManaged public var text: String?
    @NSManaged public var timestamp: NSDate
    @NSManaged public var position: Int16
    @NSManaged public var route: Route?

}

public class Route: NSManagedObject {

}

extension Route {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Route> {
        return NSFetchRequest<Route>(entityName: "Route")
    }

    @NSManaged public var timestamp: NSDate
    @NSManaged public var title: String?
    @NSManaged public var addresses: NSSet?

}

// MARK: Generated accessors for addresses
extension Route {

    @objc(addAddressesObject:)
    @NSManaged public func addToAddresses(_ value: Address)

    @objc(removeAddressesObject:)
    @NSManaged public func removeFromAddresses(_ value: Address)

    @objc(addAddresses:)
    @NSManaged public func addToAddresses(_ values: NSSet)

    @objc(removeAddresses:)
    @NSManaged public func removeFromAddresses(_ values: NSSet)

}
Oehsen answered 13/1, 2020 at 19:12 Comment(0)
O
0

I found I did something wrong when I used my own code instead of removeFromAddresses(_ value: Address) to remove an address from Route.addresses. When I fixed my code by using removeFromAddresses(_ value: Address) instead of my own code, the error messages in question went away.

Oehsen answered 20/1, 2020 at 16:45 Comment(0)
H
0

I think you might have overlooked one of your entities called "GMSCacheProperty".

As stated in the error message:

CoreData: warning: Property 'value' on Entity 'GMSCacheProperty' is using nil or an insecure NSValueTransformer.

This entity has a property "value" that is using nil or an insecure NSValueTransformer.

Haematogenesis answered 20/1, 2020 at 13:28 Comment(0)
O
0

I found I did something wrong when I used my own code instead of removeFromAddresses(_ value: Address) to remove an address from Route.addresses. When I fixed my code by using removeFromAddresses(_ value: Address) instead of my own code, the error messages in question went away.

Oehsen answered 20/1, 2020 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.