11import Foundation
22import Security
33#if canImport(LocalAuthentication)
4+ #if canImport(_Concurrency)
45@preconcurrency import LocalAuthentication
6+ #else
7+ // swiftlint:disable:next duplicate_imports
8+ import LocalAuthentication
9+ #endif
510#endif
611
712typealias RetrieveFunction = (_ query: CFDictionary, _ result: UnsafeMutablePointer<CFTypeRef?>?) -> OSStatus
@@ -10,16 +15,22 @@ typealias RemoveFunction = (_ query: CFDictionary) -> OSStatus
1015/// A simple Keychain wrapper for iOS, macOS, tvOS, and watchOS.
1116/// Supports sharing credentials with an **access group** or through **iCloud**, and integrating
1217/// **Touch ID / Face ID**.
13- public struct SimpleKeychain: Sendable {
18+ public struct SimpleKeychain {
1419 let service: String
1520 let accessGroup: String?
1621 let accessibility: Accessibility
1722 let accessControlFlags: SecAccessControlCreateFlags?
1823 let isSynchronizable: Bool
19- nonisolated(unsafe) let attributes: [String: Any]
2024
25+ #if canImport(_Concurrency)
26+ nonisolated(unsafe) let attributes: [String: Any]
2127 nonisolated(unsafe) var retrieve: RetrieveFunction = SecItemCopyMatching
2228 nonisolated(unsafe) var remove: RemoveFunction = SecItemDelete
29+ #else
30+ let attributes: [String: Any]
31+ var retrieve: RetrieveFunction = SecItemCopyMatching
32+ var remove: RemoveFunction = SecItemDelete
33+ #endif
2334
2435 #if canImport(LocalAuthentication) && !os(tvOS)
2536 let context: LAContext?
@@ -321,3 +332,9 @@ extension SimpleKeychain {
321332 return query
322333 }
323334}
335+
336+ // MARK: - Sendable conformance
337+
338+ #if canImport(_Concurrency)
339+ extension SimpleKeychain: Sendable {}
340+ #endif
0 commit comments