UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Can I make this warning go away

Forums > SwiftUI

2020-11-30 09:18:49.812229-0500 Hermes[51410:3197707] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release

It is being caused by my using an Attribute in CoreData of Transmutable - which I am using to store NSAttributedString(s). Then in the Attribute inspector I am specifying the "Custom Class" to be NSAtributedString. This works, and is the most straightforward way I have found to save my Attributed Strings in CoreData.

Since I am not actually using a custom class, I am simply using Apples NSAtrributedString class, I would think I don't have to worry about NSKeyedUnarchiveFromData being depreciated. I would expect Apple would deal with changing it to NSSecureKeyedUnarchiveFromData which is to "soon" to be used replacement to make decoding more secure.

That is all fine, and it is "ONLY" a warning, but it spams my console out while I am debugging. So, I would like it to shut up. Is there a setting someplace in XCode that I can change to get it to NOT warn me 2,346 times every time I run my app?

EDITED: OOPS! The all knowing and all powerful OZ... er... Google knew the answer. If anyone else needs this it is in the Project Build settings - look at Apple Clang - Warnings - All Languages.

2      

In your data model in your field set the Transformer attribute to NSSecureUnarchiveFromData and the error will go away.

2      

"In your data model in your field set the Transformer attribute to NSSecureUnarchiveFromData and the error will go away."

I tried that and it still shows the warning in the console log. I also tried what I posted in my edited comment and it still came back, so, now I am just living with it.

I don't know why it won't go away. After putting "NSSecureUnarchiveFromData" into the Transformer field, I also deleted the apps container in my Library, deleted all the XCode derived data, - well, pretty much everything I could find associated with my project and rebuilt from scratch, and the warning still shows in the console log. I tis NOT showing in as a "Warning (!)" in the compile status line.

2      

Turns out somehow, "NSSecureUnarchiveFromDataTransformer" worked. It took a few tries and clearing out all the folders associated with the project and finally the warnings are gone from the console.

2      

Finally, this works consistently:

Create this as a minimum:

@objc(NSAttributedStringTransformer)
class NSAttributedStringTransformer: NSSecureUnarchiveFromDataTransformer {
    override class var allowedTopLevelClasses: [AnyClass] {
        return super.allowedTopLevelClasses + [NSAttributedString.self]
    }
}

Then set the attribute to be of type "Transformable" and in the inspector set Custom Class to "NSAttributedString" and the Transformer to "NSAttributedStringTransformer" - from above.

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.