Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__SwiftValue encodeWithCoder:]: unrecognized selector sent to instance 0x600002592800'
terminating with uncaught exception of type NSException
[x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
[x] I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
The reason of the crash is the following function:
private func setSecret (_ value: Any?, forKey defaultName: String) { if let value = value { let data = NSKeyedArchiver.archivedData (withRootObject: value) super.set (try? encrypter?.encrypt (data), forKey: defaultName) return } super.set (nil, forKey: defaultName) }
Only NSCoding conforming objects can be stored in NSKeyedArchive as far as I know.
Reproducible in:
SecureDefaults version: 1.0.7
iOS version: 15.5
Steps to reproduce:
set value with type that is not available for obj-c
Description
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__SwiftValue encodeWithCoder:]: unrecognized selector sent to instance 0x600002592800' terminating with uncaught exception of type NSException
Requirements (place an
x
in each of the[ ]
)Bug Report
The reason of the crash is the following function:
private func setSecret (_ value: Any?, forKey defaultName: String) { if let value = value { let data = NSKeyedArchiver.archivedData (withRootObject: value) super.set (try? encrypter?.encrypt (data), forKey: defaultName) return } super.set (nil, forKey: defaultName) }
Only NSCoding conforming objects can be stored in NSKeyedArchive as far as I know.
Reproducible in:
SecureDefaults version: 1.0.7
iOS version: 15.5
Steps to reproduce:
Expected result:
It should save the value
Actual result:
crash