Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformable properties issue #165

Open
siideffect opened this issue Jan 3, 2020 · 9 comments · May be fixed by #168
Open

transformable properties issue #165

siideffect opened this issue Jan 3, 2020 · 9 comments · May be fixed by #168

Comments

@siideffect
Copy link

Hi, im using the latest stable version on graph im my project (i also tried development branch but the issue is there too).
Since i updated to iOS 13, i am experiencing what looks like a bad error, which i will post here:

[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-03 18:39:45.842073+0100 APPNAME[50600:5957542] [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.

Now some specific error: these errors are related to specific graph classes.

CoreData: warning: Property 'object' on Entity 'ManagedRelationshipProperty' is using nil or an insecure NSValueTransformer. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.

CoreData: warning: Property 'object' on Entity 'ManagedEntityProperty' is using nil or an insecure NSValueTransformer. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.

CoreData: warning: Property 'object' on Entity 'ManagedActionProperty' is using nil or an insecure NSValueTransformer. Please switch to using "NSSecureUnarchiveFromData" or a subclass of NSSecureUnarchiveFromDataTransformer instead.

I have no idea on how to solve this, and where to start, but it looked like a "Hey, you need to fix me asap or i can break your app and make it unasable".
Hope you can address this in the development branch you currently are, waiting for a response from you and keep up the good work, graph is awesome.

@bbruno84
Copy link

Any update?

@siideffect
Copy link
Author

I dont have any. Still waiting for a response from the owner, you got the same issue?

@bbruno84
Copy link

bbruno84 commented Mar 30, 2020 via email

@siideffect
Copy link
Author

I hope to get some news from the owner too, since everything looks abandoned: quite time has passed since opening this thread, and any communication about the state of the repo would be greatly appreciated.

@OrkhanAlikhanov
Copy link
Contributor

I've deleted my xcode months ago, can't help exactly but give a try to following.

Graph/Sources/Model.swift

Lines 163 to 165 in 9472031

let propertyValue = NSAttributeDescription()
propertyValue.name = "object"
propertyValue.attributeType = .transformableAttributeType

Try adding following after above lines and see if it works:

if #available(iOS 12, *) {
  propertyValue.valueTransformerName = "NSSecureUnarchiveFromDataTransformer"
}

if it does not work define following class:

@objc(DefaultTransformer)
class DefaultTransformer: ValueTransformer {
    override class func transformedValueClass() -> AnyClass {
        return NSData.self
    }

    override open func reverseTransformedValue(_ value: Any?) -> Any? {
        guard let value = value as? Data else {
            return nil
        }
        return NSKeyedUnarchiver.unarchiveObject(with: value)
    }

    override class func allowsReverseTransformation() -> Bool {
        return true
    }

    override func transformedValue(_ value: Any?) -> Any? {
        guard let value = value else {
            return nil
        }
        return NSKeyedArchiver.archivedData(withRootObject: value)
    }
}

taken from SO

And do:

if #available(iOS 12, *) {
  propertyValue.valueTransformerName = "DefaultTransformer" // or NSStringFromClass(DefaultTransformer.self), or String(describing: DefaultTransformer.self)
}

@daniel-jonathan
Copy link
Member

@OrkhanAlikhanov Thank you for your response. I as well don’t have the latest Xcode, at least for 6 months now.

To answer the question, whether the frameworks have died, I would say no, but it is up to the community to support it. We have been working on something new, and all our resources are aimed towards that project. We haven’t shared this publicly yet, as we did try to come up with ways for the maintenance to last on our end, but it is unfortunately not possible.

@bbruno84
Copy link

I've deleted my xcode months ago, can't help exactly but give a try to following.

Graph/Sources/Model.swift

Lines 163 to 165 in 9472031

let propertyValue = NSAttributeDescription()
propertyValue.name = "object"
propertyValue.attributeType = .transformableAttributeType

Try adding following after above lines and see if it works:

if #available(iOS 12, *) {
  propertyValue.valueTransformerName = "NSSecureUnarchiveFromDataTransformer"
}

if it does not work define following class:

@objc(DefaultTransformer)
class DefaultTransformer: ValueTransformer {
    override class func transformedValueClass() -> AnyClass {
        return NSData.self
    }

    override open func reverseTransformedValue(_ value: Any?) -> Any? {
        guard let value = value as? Data else {
            return nil
        }
        return NSKeyedUnarchiver.unarchiveObject(with: value)
    }

    override class func allowsReverseTransformation() -> Bool {
        return true
    }

    override func transformedValue(_ value: Any?) -> Any? {
        guard let value = value else {
            return nil
        }
        return NSKeyedArchiver.archivedData(withRootObject: value)
    }
}

taken from SO

And do:

if #available(iOS 12, *) {
  propertyValue.valueTransformerName = "DefaultTransformer" // or NSStringFromClass(DefaultTransformer.self), or String(describing: DefaultTransformer.self)
}

Thank you for the answer, it worked!! I used the class way, because the first try crashes into an UIImage object. Thanks a lot.

@bbruno84
Copy link

@DanielDahan Thanks for clarifying about the project state, I really appreciate the work you've done. Good luck for your next project, and yes, I've already subscribed to early access!

@daniel-jonathan
Copy link
Member

@bbruno84 thank you! We look forward to feedback and the benefit this project can have. All the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants