Skip to content

Commit 3df8eaa

Browse files
authored
Make core types Sendable and @unchecked Sendable (#308)
* Make core types Sendable and @unchecked Sendable * Update Swift version and minimum Xcode version
1 parent c095ce0 commit 3df8eaa

18 files changed

+27
-37
lines changed

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
- name: Select Xcode Version
9393
run: sudo xcode-select --switch /Applications/Xcode_14.3.app/Contents/Developer
9494
- name: Lint Podspec
95-
run: bundle exec pod lib lint --verbose --fail-fast --swift-version=5.0
95+
run: bundle exec pod lib lint --verbose --fail-fast --swift-version=5.4
9696
carthage:
9797
name: Carthage
9898
runs-on: macOS-13
@@ -118,7 +118,6 @@ jobs:
118118
'iOS_14,tvOS_14,watchOS_7',
119119
'iOS_13,tvOS_13,watchOS_6',
120120
'macOS_11',
121-
'macOS_10_15',
122121
]
123122
fail-fast: false
124123
steps:
@@ -135,9 +134,6 @@ jobs:
135134
- name: Select Xcode Version
136135
run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer
137136
if: ${{ matrix.platforms == 'macOS_11' }}
138-
- name: Select Xcode Version
139-
run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer
140-
if: ${{ matrix.platforms == 'macOS_10_15' }}
141137
- name: Prepare Simulator Runtimes
142138
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
143139
- name: Build Framework

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.4
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Valet guarantees that reading and writing operations will succeed as long as wri
239239
240240
## Requirements
241241
242-
* Xcode 11.0 or later. Xcode 10 and Xcode 9 require [Valet version 3.2.8](https://github.com/square/Valet/releases/tag/3.2.8). Earlier versions of Xcode require [Valet version 2.4.2](https://github.com/square/Valet/releases/tag/2.4.2).
242+
* Xcode 12.5 or later.
243243
* iOS 9 or later.
244244
* tvOS 9 or later.
245245
* watchOS 2 or later.

Scripts/build.swift

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ enum Platform: String, CustomStringConvertible {
3131
case tvOS_15
3232
case tvOS_16
3333
case tvOS_17
34-
case macOS_10_15
3534
case macOS_11
3635
case macOS_12
3736
case macOS_13
@@ -66,8 +65,7 @@ enum Platform: String, CustomStringConvertible {
6665
case .tvOS_17:
6766
return "platform=tvOS Simulator,OS=17.0,name=Apple TV"
6867

69-
case .macOS_10_15,
70-
.macOS_11,
68+
case .macOS_11,
7169
.macOS_12,
7270
.macOS_13,
7371
.macOS_14:
@@ -102,8 +100,6 @@ enum Platform: String, CustomStringConvertible {
102100
.tvOS_17:
103101
return "appletvsimulator"
104102

105-
case .macOS_10_15:
106-
return "macosx10.15"
107103
case .macOS_11:
108104
return "macosx11.1"
109105
case .macOS_12:
@@ -134,7 +130,6 @@ enum Platform: String, CustomStringConvertible {
134130
.tvOS_15,
135131
.tvOS_16,
136132
.tvOS_17,
137-
.macOS_10_15,
138133
.macOS_11,
139134
.macOS_12,
140135
.macOS_13,
@@ -182,8 +177,7 @@ enum Platform: String, CustomStringConvertible {
182177
.tvOS_17:
183178
return "Valet tvOS"
184179

185-
case .macOS_10_15,
186-
.macOS_11,
180+
case .macOS_11,
187181
.macOS_12,
188182
.macOS_13,
189183
.macOS_14:

Sources/Valet/Accessibility.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919

2020
@objc(VALAccessibility)
21-
public enum Accessibility: Int, CaseIterable, CustomStringConvertible, Equatable {
21+
public enum Accessibility: Int, CaseIterable, CustomStringConvertible, Equatable, Sendable {
2222
/// Valet data can only be accessed while the device is unlocked. This attribute is recommended for data that only needs to be accessible while the application is in the foreground. Valet data with this attribute will migrate to a new device when using encrypted backups.
2323
case whenUnlocked = 1
2424
/// Valet data cannot be accessed after a restart until the device has been unlocked once; data is accessible until the device is next rebooted. This attribute is recommended for data that needs to be accessible by background applications. Valet data with this attribute will migrate to a new device when using encrypted backups.

Sources/Valet/CloudAccessibility.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919

2020
@objc(VALCloudAccessibility)
21-
public enum CloudAccessibility: Int, CaseIterable, CustomStringConvertible, Equatable {
21+
public enum CloudAccessibility: Int, CaseIterable, CustomStringConvertible, Equatable, Sendable {
2222
/// Valet data can only be accessed while the device is unlocked. This attribute is recommended for data that only needs to be accessible while the application is in the foreground. Valet data with this attribute will migrate to a new device when using encrypted backups.
2323
case whenUnlocked = 1
2424
/// Valet data cannot be accessed after a restart until the device has been unlocked once; data is accessible until the device is next rebooted. This attribute is recommended for data that needs to be accessible by background applications. Valet data with this attribute will migrate to a new device when using encrypted backups.

Sources/Valet/Identifier.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919

20-
public struct Identifier: CustomStringConvertible {
20+
public struct Identifier: CustomStringConvertible, Sendable {
2121

2222
// MARK: Initialization
2323

Sources/Valet/Internal/Configuration.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919

20-
internal enum Configuration: CustomStringConvertible {
20+
internal enum Configuration: CustomStringConvertible, Sendable {
2121
case valet(Accessibility)
2222
case iCloud(CloudAccessibility)
2323
case secureEnclave(SecureEnclaveAccessControl)

Sources/Valet/Internal/Service.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919

20-
internal enum Service: CustomStringConvertible, Equatable {
20+
internal enum Service: CustomStringConvertible, Equatable, Sendable {
2121
case standard(Identifier, Configuration)
2222
case sharedGroup(SharedGroupIdentifier, Identifier?, Configuration)
2323

Sources/Valet/KeychainError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919

2020
@objc(VALKeychainError)
21-
public enum KeychainError: Int, CaseIterable, CustomStringConvertible, Error, Equatable {
21+
public enum KeychainError: Int, CaseIterable, CustomStringConvertible, Error, Equatable, Sendable {
2222
/// The keychain could not be accessed.
2323
case couldNotAccessKeychain
2424
/// User dismissed the user-presence prompt.

Sources/Valet/MigrationError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919

2020
@objc(VALMigrationResult)
21-
public enum MigrationError: Int, CaseIterable, CustomStringConvertible, Error, Equatable {
21+
public enum MigrationError: Int, CaseIterable, CustomStringConvertible, Error, Equatable, Sendable {
2222
/// Migration failed because the keychain query was not valid.
2323
case invalidQuery
2424
/// Migration failed because a key staged for migration was invalid.

Sources/Valet/SecureEnclave.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919

20-
public final class SecureEnclave {
20+
public final class SecureEnclave: Sendable {
2121

2222
// MARK: Internal Methods
2323

Sources/Valet/SecureEnclaveAccessControl.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919

2020
@objc(VALSecureEnclaveAccessControl)
21-
public enum SecureEnclaveAccessControl: Int, CustomStringConvertible, Equatable {
21+
public enum SecureEnclaveAccessControl: Int, CustomStringConvertible, Equatable, Sendable {
2222
/// Access to keychain elements requires user presence verification via Touch ID, Face ID, or device Passcode. On macOS 10.15 and later, this element may also be accessed via a prompt on a paired watch. Keychain elements are still accessible by Touch ID even if fingers are added or removed. Touch ID does not have to be available or enrolled.
2323
case userPresence = 1
2424

Sources/Valet/SecureEnclaveValet.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919

2020
/// Reads and writes keychain elements that are stored on the Secure Enclave using Accessibility attribute `.whenPasscodeSetThisDeviceOnly`. Accessing these keychain elements will require the user to confirm their presence via Touch ID, Face ID, or passcode entry. If no passcode is set on the device, accessing the keychain via a `SecureEnclaveValet` will fail. Data is removed from the Secure Enclave when the user removes a passcode from the device.
2121
@objc(VALSecureEnclaveValet)
22-
public final class SecureEnclaveValet: NSObject {
22+
public final class SecureEnclaveValet: NSObject, Sendable {
2323

2424
// MARK: Public Class Methods
2525

@@ -92,7 +92,6 @@ public final class SecureEnclaveValet: NSObject {
9292
self.identifier = identifier
9393
self.service = service
9494
self.accessControl = accessControl
95-
baseKeychainQuery = service.generateBaseQuery()
9695
}
9796

9897
// MARK: Hashable
@@ -232,7 +231,9 @@ public final class SecureEnclaveValet: NSObject {
232231
// MARK: Private Properties
233232

234233
private let lock = NSLock()
235-
private let baseKeychainQuery: [String : AnyHashable]
234+
private var baseKeychainQuery: [String : AnyHashable] {
235+
return service.generateBaseQuery()
236+
}
236237

237238
}
238239

Sources/Valet/SharedGroupIdentifier.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919

20-
public struct SharedGroupIdentifier: CustomStringConvertible {
20+
public struct SharedGroupIdentifier: CustomStringConvertible, Sendable {
2121

2222
// MARK: Initialization
2323

Sources/Valet/SinglePromptSecureEnclaveValet.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import Foundation
2525
/// Reads and writes keychain elements that are stored on the Secure Enclave using Accessibility attribute `.whenPasscodeSetThisDeviceOnly`. The first access of these keychain elements will require the user to confirm their presence via Touch ID, Face ID, or passcode entry. If no passcode is set on the device, accessing the keychain via a `SinglePromptSecureEnclaveValet` will fail. Data is removed from the Secure Enclave when the user removes a passcode from the device.
2626
@objc(VALSinglePromptSecureEnclaveValet)
2727
@available(watchOS 3, *)
28-
public final class SinglePromptSecureEnclaveValet: NSObject {
29-
28+
public final class SinglePromptSecureEnclaveValet: NSObject, @unchecked Sendable {
29+
3030
// MARK: Public Class Methods
3131

3232
/// - Parameters:

Sources/Valet/Valet.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919

2020
/// Reads and writes keychain elements.
2121
@objc(VALValet)
22-
public final class Valet: NSObject {
22+
public final class Valet: NSObject, Sendable {
2323

2424
// MARK: Public Class Methods
2525

@@ -198,7 +198,6 @@ public final class Valet: NSObject {
198198
self.configuration = configuration
199199
self.service = service
200200
accessibility = configuration.accessibility
201-
baseKeychainQuery = service.generateBaseQuery()
202201
}
203202

204203
#if os(macOS)
@@ -207,15 +206,13 @@ public final class Valet: NSObject {
207206
self.configuration = configuration
208207
service = .standardOverride(service: identifier, configuration)
209208
accessibility = configuration.accessibility
210-
baseKeychainQuery = service.generateBaseQuery()
211209
}
212210

213211
private init(overrideSharedAccess identifier: SharedGroupIdentifier, configuration: Configuration) {
214212
self.identifier = identifier.asIdentifier
215213
self.configuration = configuration
216214
service = .sharedGroupOverride(service: identifier, configuration)
217215
accessibility = configuration.accessibility
218-
baseKeychainQuery = service.generateBaseQuery()
219216
}
220217
#endif
221218

@@ -483,7 +480,9 @@ public final class Valet: NSObject {
483480

484481
internal let configuration: Configuration
485482
internal let service: Service
486-
internal let baseKeychainQuery: [String : AnyHashable]
483+
internal var baseKeychainQuery: [String : AnyHashable] {
484+
return service.generateBaseQuery()
485+
}
487486

488487
// MARK: Private Properties
489488

Valet.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22
s.name = 'Valet'
3-
s.version = '4.2.0'
3+
s.version = '4.3.0'
44
s.license = 'Apache License, Version 2.0'
55
s.summary = 'Securely store data on iOS, tvOS, watchOS, or macOS without knowing a thing about how the Keychain works. It\'s easy. We promise.'
66
s.homepage = 'https://github.com/square/Valet'
77
s.authors = 'Square'
88
s.source = { :git => 'https://github.com/square/Valet.git', :tag => s.version }
9-
s.swift_version = '5.0'
9+
s.swift_version = '5.4'
1010
s.source_files = 'Sources/Valet/**/*.{swift,h}'
1111
s.public_header_files = 'Sources/Valet/*.h'
1212
s.frameworks = 'Security'

0 commit comments

Comments
 (0)