核心数据错误切换到使用 "NSSecureUnarchiveFromData" 或 NSSecureUnarchiveFromDataTransformer 的子类

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

我收到这个 CoreData 错误。我不知道为什么会收到此错误。我没有使用任何 Transformable 类型。我在我的代码中看不到任何表明我正在使用可转换属性的信息。我让 Xcode 通过在创建项目时选择“使用核心数据”选项来设置 CoreData。其他类似的问题没有帮助,因为答案与代码有关,这些代码看起来像创建项目时创建的 Xcode 的任何代码。调试 window 中出现此错误时项目不会崩溃。我正在为 iOS 12 使用 Xcode 11.3 和 Google Maps SDK for iOS,它在 iPhone 8 设备上使用 运行 iOS13.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.

这是触发错误的代码:

do {

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

} catch {

    print(error)

}

我正在使用以下核心数据对象:

地址实体

位置属性

输入整数 16

文本属性类型String

时间戳属性类型日期

路由关系目的地路由逆向地址

路由实体

时间戳属性类型日期

title 属性类型 String

addresses relationship destination Address inverse route

我有以下托管对象代码 类:

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)

}

我认为您可能忽略了一个名为 "GMSCacheProperty" 的实体。

如错误信息中所述:

CoreData:警告:实体 'GMSCacheProperty' 上的 属性 'value' 正在使用 nil 或不安全的 NSValueTransformer。

此实体有一个 属性 "value" 使用 nil 或不安全的 NSValueTransformer。

当我使用自己的代码而不是 removeFromAddresses(_ value: Address) 从 Route.addresses 中删除一个地址时,我发现我做错了什么。当我使用 removeFromAddresses(_ value: Address) 而不是我自己的代码修复我的代码时,相关错误消息消失了。