Skip to content

NSKeyedArichiver error #10

@thegalkin

Description

@thegalkin

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 [ ])

  • I've read and agree to the Code of Conduct.
  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • 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:

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions