I just renamed my Xcode project and when I ran it I got this error:
2015-11-14 05:32:42.337 Buck Tracker[3537:1456100] * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '* -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (iBudgeter.Record) for key (NS.objects); the class may be defined in source code or a library that is not linked'
The Buck Tracker
is the new name and iBudgeter
is the original name. Record
is a custom NSObject
I created to store some data.
I tried renaming the project back to iBudgeter
but it didn't work. Reverting to a previous version in git did help but I got the same error when I renamed it again.
So any suggestions?
another way is to fix the name of the class used for NSCoding. You simply have to use:
NSKeyedArchiver.setClassName("Record", forClass: Record.self
before serializingNSKeyedUnarchiver.setClass(Record.self, forClassName: "Record")
before deserializingwherever needed.
Looks like iOS extensions prefix the class name with the extension's name.
In Case if you moved your file to another module, you would need to add additional information
NSKeyedArchiver.setClassName("OldModule.ClassName", for: ClassName.self)
NSKeyedUnarchiver.setClass(ClassName.self, forClassName: "OldModule.ClassName")
Don't change your project name. Just change the display name. It's the "Bundle display name" entry in your Info.plist. You'll probably need to add the entry.
See this answer if you want to change the display name of an OS X app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With