vpeschenkov / SecureDefaults

Elevate the security of your UserDefaults with this lightweight wrapper that adds a layer of AES-256 encryption
MIT License
227 stars 17 forks source link

NSKeyedArichiver error #10

Open thegalkin opened 2 years ago

thegalkin commented 2 years ago

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:

  1. set value with type that is not available for obj-c
  2. get crash

Expected result:

It should save the value

Actual result:

crash