Skip to content

Commit

Permalink
Use @unchecked instead of nonisolated
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Jan 16, 2025
1 parent fe3ede7 commit 8de16a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
8 changes: 1 addition & 7 deletions SimpleKeychain/Accessibility.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Security

/// Represents the accessibility types of Keychain items. It's a mirror of `kSecAttrAccessible` values.
public enum Accessibility: RawRepresentable {
public enum Accessibility: RawRepresentable, @unchecked Sendable {

/// The data in the Keychain item can be accessed only while the device is unlocked by the user.
/// See [kSecAttrAccessibleWhenUnlocked](https://developer.apple.com/documentation/security/ksecattraccessiblewhenunlocked).
Expand Down Expand Up @@ -50,9 +50,3 @@ public enum Accessibility: RawRepresentable {
}
}
}

// MARK: - Sendable conformance

#if canImport(_Concurrency)
extension Accessibility: Sendable {}
#endif
21 changes: 2 additions & 19 deletions SimpleKeychain/SimpleKeychain.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import Foundation
import Security
#if canImport(LocalAuthentication)
#if canImport(_Concurrency)
@preconcurrency import LocalAuthentication
#else
// swiftlint:disable:next duplicate_imports
import LocalAuthentication
#endif
#endif

typealias RetrieveFunction = (_ query: CFDictionary, _ result: UnsafeMutablePointer<CFTypeRef?>?) -> OSStatus
Expand All @@ -15,22 +10,16 @@ typealias RemoveFunction = (_ query: CFDictionary) -> OSStatus
/// A simple Keychain wrapper for iOS, macOS, tvOS, and watchOS.
/// Supports sharing credentials with an **access group** or through **iCloud**, and integrating
/// **Touch ID / Face ID**.
public struct SimpleKeychain {
public struct SimpleKeychain: @unchecked Sendable {
let service: String
let accessGroup: String?
let accessibility: Accessibility
let accessControlFlags: SecAccessControlCreateFlags?
let isSynchronizable: Bool

#if canImport(_Concurrency)
nonisolated(unsafe) let attributes: [String: Any]
nonisolated(unsafe) var retrieve: RetrieveFunction = SecItemCopyMatching
nonisolated(unsafe) var remove: RemoveFunction = SecItemDelete
#else
let attributes: [String: Any]

var retrieve: RetrieveFunction = SecItemCopyMatching
var remove: RemoveFunction = SecItemDelete
#endif

#if canImport(LocalAuthentication) && !os(tvOS)
let context: LAContext?
Expand Down Expand Up @@ -332,9 +321,3 @@ extension SimpleKeychain {
return query
}
}

// MARK: - Sendable conformance

#if canImport(_Concurrency)
extension SimpleKeychain: Sendable {}
#endif

0 comments on commit 8de16a8

Please sign in to comment.