From f4f8461e100def9593d81c6ef2c7a746f4b51953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Fri, 16 Feb 2024 14:41:11 +0100 Subject: [PATCH] Support named transformers, set attrType Named transformers should just work too? Also setting the `attributeType` to `.transformableAttributeType`. --- .../SchemaCompatibility/NSAttributeDescription+Data.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift b/Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift index 1e8c399..162efbd 100644 --- a/Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift +++ b/Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift @@ -206,9 +206,10 @@ private extension NSAttributeDescription { case .ephemeral: isTransient = true case .transformableByName(let name): - fatalError("Not supported") - case .transformableByType(let type): assert(valueTransformerName == nil) + attributeType = .transformableAttributeType + valueTransformerName = name + case .transformableByType(let type): let name = NSStringFromClass(type) if !ValueTransformer.valueTransformerNames().contains(.init(name)) { // no access to valueTransformerForName? @@ -217,6 +218,7 @@ private extension NSAttributeDescription { .setValueTransformer(transformer, forName: .init(name)) } valueTransformerName = name + attributeType = .transformableAttributeType case .allowsCloudEncryption: // FIXME: restrict availability if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) {