Skip to content

Commit

Permalink
Switch from deprecated NSSecureCoding API
Browse files Browse the repository at this point in the history
Fixes #131
  • Loading branch information
sindresorhus committed Apr 6, 2023
1 parent 06dc954 commit 332d9ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.7
import PackageDescription

let package = Package(
Expand Down
6 changes: 3 additions & 3 deletions Sources/Defaults/Defaults+Bridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension Defaults {
This exists to avoid compiler ambiguity.
*/
extension Defaults {
public struct CodableNSSecureCodingBridge<Value: Codable & NSSecureCoding>: CodableBridge {}
public struct CodableNSSecureCodingBridge<Value: Codable & NSSecureCoding & NSObject>: CodableBridge {}
}

extension Defaults {
Expand Down Expand Up @@ -79,7 +79,7 @@ extension Defaults {
}

extension Defaults {
public struct NSSecureCodingBridge<Value: NSSecureCoding>: Bridge {
public struct NSSecureCodingBridge<Value: NSSecureCoding & NSObject>: Bridge {
public typealias Value = Value
public typealias Serializable = Data

Expand All @@ -97,7 +97,7 @@ extension Defaults {
}

do {
return try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(object) as? Value
return try NSKeyedUnarchiver.unarchivedObject(ofClass: Value.self, from: object)
} catch {
print(error)
return nil
Expand Down
6 changes: 3 additions & 3 deletions Sources/Defaults/Defaults+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ extension Defaults.Serializable where Self: Codable {
public static var bridge: Defaults.TopLevelCodableBridge<Self> { Defaults.TopLevelCodableBridge() }
}

extension Defaults.Serializable where Self: Codable & NSSecureCoding {
extension Defaults.Serializable where Self: Codable & NSSecureCoding & NSObject {
public static var bridge: Defaults.CodableNSSecureCodingBridge<Self> { Defaults.CodableNSSecureCodingBridge() }
}

extension Defaults.Serializable where Self: Codable & NSSecureCoding & Defaults.PreferNSSecureCoding {
extension Defaults.Serializable where Self: Codable & NSSecureCoding & NSObject & Defaults.PreferNSSecureCoding {
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
}

Expand All @@ -104,7 +104,7 @@ extension Defaults.Serializable where Self: Codable & RawRepresentable & Default
extension Defaults.Serializable where Self: RawRepresentable {
public static var bridge: Defaults.RawRepresentableBridge<Self> { Defaults.RawRepresentableBridge() }
}
extension Defaults.Serializable where Self: NSSecureCoding {
extension Defaults.Serializable where Self: NSSecureCoding & NSObject {
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Defaults/Defaults+Protocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public protocol _DefaultsSetAlgebraSerializable: SetAlgebra, Defaults.Serializab
public protocol _DefaultsCodableBridge: Defaults.Bridge where Serializable == String, Value: Codable {}

public protocol _DefaultsPreferRawRepresentable: RawRepresentable {}
public protocol _DefaultsPreferNSSecureCoding: NSSecureCoding {}
public protocol _DefaultsPreferNSSecureCoding: NSSecureCoding & NSObject {}

Check warning on line 44 in Sources/Defaults/Defaults+Protocol.swift

View workflow job for this annotation

GitHub Actions / lint

Comma Inheritance Rule Violation: Use commas to separate types in inheritance lists (comma_inheritance)

Check warning on line 44 in Sources/Defaults/Defaults+Protocol.swift

View workflow job for this annotation

GitHub Actions / lint

Comma Inheritance Rule Violation: Use commas to separate types in inheritance lists (comma_inheritance)

// Essential properties for serializing and deserializing `ClosedRange` and `Range`.
public protocol _DefaultsRange {
Expand Down

0 comments on commit 332d9ed

Please sign in to comment.