Skip to content

Commit 8a1ea3e

Browse files
committed
Enable compilation with Swift 6 for most targets
1 parent 67e90ef commit 8a1ea3e

File tree

295 files changed

+1118
-851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+1118
-851
lines changed

ios/MullvadLogging/LogFileOutputStream.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MullvadTypes
1313
/// the first place, or when writing to it.
1414
private let reopenFileLogInterval: Duration = .seconds(5)
1515

16-
class LogFileOutputStream: TextOutputStream {
16+
class LogFileOutputStream: TextOutputStream, @unchecked Sendable {
1717
private let queue = DispatchQueue(label: "LogFileOutputStreamQueue", qos: .utility)
1818

1919
private let baseFileURL: URL

ios/MullvadLogging/OSLogHandler.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct OSLogHandler: LogHandler {
2222
let category: String
2323
}
2424

25-
private static var osLogRegistry: [RegistryKey: OSLog] = [:]
25+
nonisolated(unsafe) private static var osLogRegistry: [RegistryKey: OSLog] = [:]
2626
private static let registryLock = NSLock()
2727

2828
private static func getOSLog(subsystem: String, category: String) -> OSLog {

ios/MullvadMockData/MullvadREST/AccessMethodRepository+Stub.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Combine
1010
import MullvadSettings
1111

12-
public struct AccessMethodRepositoryStub: AccessMethodRepositoryDataSource {
12+
public struct AccessMethodRepositoryStub: AccessMethodRepositoryDataSource, @unchecked Sendable {
1313
public var directAccess: PersistentAccessMethod
1414

1515
public var accessMethodsPublisher: AnyPublisher<[PersistentAccessMethod], Never> {

ios/MullvadMockData/MullvadREST/RESTRequestExecutor+Stubs.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
import MullvadREST
1111
import MullvadTypes
1212

13-
struct RESTRequestExecutorStub<Success>: RESTRequestExecutor {
13+
struct RESTRequestExecutorStub<Success: Sendable>: RESTRequestExecutor {
1414
var success: (() -> Success)?
1515

1616
func execute(completionHandler: @escaping (Result<Success, Error>) -> Void) -> Cancellable {

ios/MullvadREST/ApiHandlers/APIAvailabilityTestRequest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
import MullvadTypes
1111

1212
extension REST {
13-
public struct APIAvailabilityTestRequest {
13+
public struct APIAvailabilityTestRequest: Sendable {
1414
let transport: RESTTransport
1515

1616
public init(transport: RESTTransport) {
@@ -21,7 +21,7 @@ extension REST {
2121
///
2222
/// - Parameter completion: Completes with `nil` if the request was successful, and `Error` otherwise.
2323
/// - Returns: A cancellable token to cancel the request inflight.
24-
public func makeRequest(completion: @escaping (Swift.Error?) -> Void) -> Cancellable {
24+
public func makeRequest(completion: @escaping @Sendable (Swift.Error?) -> Void) -> Cancellable {
2525
do {
2626
let factory = RequestFactory(
2727
hostname: defaultAPIHostname,

ios/MullvadREST/ApiHandlers/AddressCache.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import MullvadLogging
1111
import MullvadTypes
1212

1313
extension REST {
14-
public final class AddressCache {
14+
public final class AddressCache: @unchecked Sendable {
1515
/// Logger.
1616
private let logger = Logger(label: "AddressCache")
1717

ios/MullvadREST/ApiHandlers/RESTAPIProxy.swift

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import Foundation
1010
import MullvadTypes
1111
import WireGuardKitTypes
1212

13-
public protocol APIQuerying {
13+
public protocol APIQuerying: Sendable {
1414
func getAddressList(
1515
retryStrategy: REST.RetryStrategy,
16-
completionHandler: @escaping ProxyCompletionHandler<[AnyIPEndpoint]>
16+
completionHandler: @escaping @Sendable ProxyCompletionHandler<[AnyIPEndpoint]>
1717
) -> Cancellable
1818

1919
func getRelays(
2020
etag: String?,
2121
retryStrategy: REST.RetryStrategy,
22-
completionHandler: @escaping ProxyCompletionHandler<REST.ServerRelaysCacheResponse>
22+
completionHandler: @escaping @Sendable ProxyCompletionHandler<REST.ServerRelaysCacheResponse>
2323
) -> Cancellable
2424

2525
func createApplePayment(
@@ -30,19 +30,19 @@ public protocol APIQuerying {
3030
func sendProblemReport(
3131
_ body: REST.ProblemReportRequest,
3232
retryStrategy: REST.RetryStrategy,
33-
completionHandler: @escaping ProxyCompletionHandler<Void>
33+
completionHandler: @escaping @Sendable ProxyCompletionHandler<Void>
3434
) -> Cancellable
3535

3636
func submitVoucher(
3737
voucherCode: String,
3838
accountNumber: String,
3939
retryStrategy: REST.RetryStrategy,
40-
completionHandler: @escaping ProxyCompletionHandler<REST.SubmitVoucherResponse>
40+
completionHandler: @escaping @Sendable ProxyCompletionHandler<REST.SubmitVoucherResponse>
4141
) -> Cancellable
4242
}
4343

4444
extension REST {
45-
public final class APIProxy: Proxy<AuthProxyConfiguration>, APIQuerying {
45+
public final class APIProxy: Proxy<AuthProxyConfiguration>, APIQuerying, @unchecked Sendable {
4646
public init(configuration: AuthProxyConfiguration) {
4747
super.init(
4848
name: "APIProxy",
@@ -57,7 +57,7 @@ extension REST {
5757

5858
public func getAddressList(
5959
retryStrategy: REST.RetryStrategy,
60-
completionHandler: @escaping ProxyCompletionHandler<[AnyIPEndpoint]>
60+
completionHandler: @escaping @Sendable ProxyCompletionHandler<[AnyIPEndpoint]>
6161
) -> Cancellable {
6262
let requestHandler = AnyRequestHandler { endpoint in
6363
try self.requestFactory.createRequest(
@@ -84,7 +84,7 @@ extension REST {
8484
public func getRelays(
8585
etag: String?,
8686
retryStrategy: REST.RetryStrategy,
87-
completionHandler: @escaping ProxyCompletionHandler<ServerRelaysCacheResponse>
87+
completionHandler: @escaping @Sendable ProxyCompletionHandler<ServerRelaysCacheResponse>
8888
) -> Cancellable {
8989
let requestHandler = AnyRequestHandler { endpoint in
9090
var requestBuilder = try self.requestFactory.createRequestBuilder(
@@ -240,7 +240,7 @@ extension REST {
240240
voucherCode: String,
241241
accountNumber: String,
242242
retryStrategy: REST.RetryStrategy,
243-
completionHandler: @escaping ProxyCompletionHandler<SubmitVoucherResponse>
243+
completionHandler: @escaping @Sendable ProxyCompletionHandler<SubmitVoucherResponse>
244244
) -> Cancellable {
245245
let requestHandler = AnyRequestHandler(
246246
createURLRequest: { endpoint, authorization in
@@ -283,16 +283,16 @@ extension REST {
283283

284284
// MARK: - Response types
285285

286-
public enum ServerRelaysCacheResponse {
286+
public enum ServerRelaysCacheResponse: Sendable {
287287
case notModified
288288
case newContent(_ etag: String?, _ rawData: Data)
289289
}
290290

291-
private struct CreateApplePaymentRequest: Encodable {
291+
private struct CreateApplePaymentRequest: Encodable, Sendable {
292292
let receiptString: Data
293293
}
294294

295-
public enum CreateApplePaymentResponse {
295+
public enum CreateApplePaymentResponse: Sendable {
296296
case noTimeAdded(_ expiry: Date)
297297
case timeAdded(_ timeAdded: Int, _ newExpiry: Date)
298298

@@ -322,12 +322,12 @@ extension REST {
322322
}
323323
}
324324

325-
private struct CreateApplePaymentRawResponse: Decodable {
325+
private struct CreateApplePaymentRawResponse: Decodable, Sendable {
326326
let timeAdded: Int
327327
let newExpiry: Date
328328
}
329329

330-
public struct ProblemReportRequest: Encodable {
330+
public struct ProblemReportRequest: Encodable, Sendable {
331331
public let address: String
332332
public let message: String
333333
public let log: String
@@ -341,11 +341,11 @@ extension REST {
341341
}
342342
}
343343

344-
private struct SubmitVoucherRequest: Encodable {
344+
private struct SubmitVoucherRequest: Encodable, Sendable {
345345
let voucherCode: String
346346
}
347347

348-
public struct SubmitVoucherResponse: Decodable {
348+
public struct SubmitVoucherResponse: Decodable, Sendable {
349349
public let timeAdded: Int
350350
public let newExpiry: Date
351351

ios/MullvadREST/ApiHandlers/RESTAccessTokenManager.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import MullvadLogging
1111
import MullvadTypes
1212
import Operations
1313

14-
public protocol RESTAccessTokenManagement {
14+
public protocol RESTAccessTokenManagement: Sendable {
1515
func getAccessToken(
1616
accountNumber: String,
17-
completionHandler: @escaping ProxyCompletionHandler<REST.AccessTokenData>
17+
completionHandler: @escaping @Sendable ProxyCompletionHandler<REST.AccessTokenData>
1818
) -> Cancellable
1919

2020
func invalidateAllTokens()
2121
}
2222

2323
extension REST {
24-
public final class AccessTokenManager: RESTAccessTokenManagement {
24+
public final class AccessTokenManager: RESTAccessTokenManagement, @unchecked Sendable {
2525
private let logger = Logger(label: "REST.AccessTokenManager")
2626
private let operationQueue = AsyncOperationQueue.makeSerial()
2727
private let dispatchQueue = DispatchQueue(label: "REST.AccessTokenManager.dispatchQueue")
@@ -34,7 +34,7 @@ extension REST {
3434

3535
public func getAccessToken(
3636
accountNumber: String,
37-
completionHandler: @escaping ProxyCompletionHandler<REST.AccessTokenData>
37+
completionHandler: @escaping @Sendable ProxyCompletionHandler<REST.AccessTokenData>
3838
) -> Cancellable {
3939
let operation =
4040
ResultBlockOperation<REST.AccessTokenData>(dispatchQueue: dispatchQueue) { finish -> Cancellable in

ios/MullvadREST/ApiHandlers/RESTAccountsProxy.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import Foundation
1010
import MullvadTypes
1111

12-
public protocol RESTAccountHandling {
12+
public protocol RESTAccountHandling: Sendable {
1313
func createAccount(
1414
retryStrategy: REST.RetryStrategy,
15-
completion: @escaping ProxyCompletionHandler<REST.NewAccountData>
15+
completion: @escaping @Sendable ProxyCompletionHandler<REST.NewAccountData>
1616
) -> Cancellable
1717

1818
func getAccountData(accountNumber: String) -> any RESTRequestExecutor<Account>
@@ -25,7 +25,7 @@ public protocol RESTAccountHandling {
2525
}
2626

2727
extension REST {
28-
public final class AccountsProxy: Proxy<AuthProxyConfiguration>, RESTAccountHandling {
28+
public final class AccountsProxy: Proxy<AuthProxyConfiguration>, RESTAccountHandling, @unchecked Sendable {
2929
public init(configuration: AuthProxyConfiguration) {
3030
super.init(
3131
name: "AccountsProxy",
@@ -135,7 +135,7 @@ extension REST {
135135
}
136136
}
137137

138-
public struct NewAccountData: Decodable {
138+
public struct NewAccountData: Decodable, Sendable {
139139
public let id: String
140140
public let expiry: Date
141141
public let maxPorts: Int

ios/MullvadREST/ApiHandlers/RESTAuthenticationProxy.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
import MullvadTypes
1111

1212
extension REST {
13-
public final class AuthenticationProxy: Proxy<ProxyConfiguration> {
13+
public final class AuthenticationProxy: Proxy<ProxyConfiguration>, @unchecked Sendable {
1414
public init(configuration: ProxyConfiguration) {
1515
super.init(
1616
name: "AuthenticationProxy",
@@ -57,12 +57,12 @@ extension REST {
5757
}
5858
}
5959

60-
public struct AccessTokenData: Decodable {
60+
public struct AccessTokenData: Decodable, Sendable {
6161
let accessToken: String
6262
let expiry: Date
6363
}
6464

65-
private struct AccessTokenRequest: Encodable {
65+
private struct AccessTokenRequest: Encodable, Sendable {
6666
let accountNumber: String
6767
}
6868
}

ios/MullvadREST/ApiHandlers/RESTAuthorization.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import MullvadTypes
1111
import Operations
1212

1313
protocol RESTAuthorizationProvider {
14-
func getAuthorization(completion: @escaping (Result<REST.Authorization, Swift.Error>) -> Void)
14+
func getAuthorization(completion: @escaping @Sendable (Result<REST.Authorization, Swift.Error>) -> Void)
1515
-> Cancellable
1616
}
1717

@@ -28,7 +28,7 @@ extension REST {
2828
}
2929

3030
func getAuthorization(
31-
completion: @escaping (Result<REST.Authorization, Swift.Error>)
31+
completion: @escaping @Sendable (Result<REST.Authorization, Swift.Error>)
3232
-> Void
3333
) -> Cancellable {
3434
accessTokenManager.getAccessToken(accountNumber: accountNumber) { result in

ios/MullvadREST/ApiHandlers/RESTDefaults.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MullvadTypes
1313
extension REST {
1414
/// The API hostname and endpoint are defined in the Info.plist of the MullvadREST framework bundle
1515
/// This is due to not being able to target `Bundle.main` from a Unit Test environment as it gets its own bundle that would not contain the above variables.
16-
private static let infoDictionary = Bundle(for: AddressCache.self).infoDictionary!
16+
nonisolated(unsafe) private static let infoDictionary = Bundle(for: AddressCache.self).infoDictionary!
1717

1818
/// Default API hostname.
1919
public static let defaultAPIHostname = infoDictionary["ApiHostName"] as! String

ios/MullvadREST/ApiHandlers/RESTDevicesProxy.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,47 @@
88

99
import Foundation
1010
import MullvadTypes
11-
import WireGuardKitTypes
11+
@preconcurrency import WireGuardKitTypes
1212

13-
public protocol DeviceHandling {
13+
public protocol DeviceHandling: Sendable {
1414
func getDevice(
1515
accountNumber: String,
1616
identifier: String,
1717
retryStrategy: REST.RetryStrategy,
18-
completion: @escaping ProxyCompletionHandler<Device>
18+
completion: @escaping @Sendable ProxyCompletionHandler<Device>
1919
) -> Cancellable
2020

2121
func getDevices(
2222
accountNumber: String,
2323
retryStrategy: REST.RetryStrategy,
24-
completion: @escaping ProxyCompletionHandler<[Device]>
24+
completion: @escaping @Sendable ProxyCompletionHandler<[Device]>
2525
) -> Cancellable
2626

2727
func createDevice(
2828
accountNumber: String,
2929
request: REST.CreateDeviceRequest,
3030
retryStrategy: REST.RetryStrategy,
31-
completion: @escaping ProxyCompletionHandler<Device>
31+
completion: @escaping @Sendable ProxyCompletionHandler<Device>
3232
) -> Cancellable
3333

3434
func deleteDevice(
3535
accountNumber: String,
3636
identifier: String,
3737
retryStrategy: REST.RetryStrategy,
38-
completion: @escaping ProxyCompletionHandler<Bool>
38+
completion: @escaping @Sendable ProxyCompletionHandler<Bool>
3939
) -> Cancellable
4040

4141
func rotateDeviceKey(
4242
accountNumber: String,
4343
identifier: String,
4444
publicKey: PublicKey,
4545
retryStrategy: REST.RetryStrategy,
46-
completion: @escaping ProxyCompletionHandler<Device>
46+
completion: @escaping @Sendable ProxyCompletionHandler<Device>
4747
) -> Cancellable
4848
}
4949

5050
extension REST {
51-
public final class DevicesProxy: Proxy<AuthProxyConfiguration>, DeviceHandling {
51+
public final class DevicesProxy: Proxy<AuthProxyConfiguration>, DeviceHandling, @unchecked Sendable {
5252
public init(configuration: AuthProxyConfiguration) {
5353
super.init(
5454
name: "DevicesProxy",
@@ -161,7 +161,7 @@ extension REST {
161161
accountNumber: String,
162162
request: CreateDeviceRequest,
163163
retryStrategy: REST.RetryStrategy,
164-
completion: @escaping ProxyCompletionHandler<Device>
164+
completion: @escaping @Sendable ProxyCompletionHandler<Device>
165165
) -> Cancellable {
166166
let requestHandler = AnyRequestHandler(
167167
createURLRequest: { endpoint, authorization in
@@ -262,7 +262,7 @@ extension REST {
262262
identifier: String,
263263
publicKey: PublicKey,
264264
retryStrategy: REST.RetryStrategy,
265-
completion: @escaping ProxyCompletionHandler<Device>
265+
completion: @escaping @Sendable ProxyCompletionHandler<Device>
266266
) -> Cancellable {
267267
let requestHandler = AnyRequestHandler(
268268
createURLRequest: { endpoint, authorization in
@@ -310,7 +310,7 @@ extension REST {
310310
}
311311
}
312312

313-
public struct CreateDeviceRequest: Encodable {
313+
public struct CreateDeviceRequest: Encodable, Sendable {
314314
let publicKey: PublicKey
315315
let hijackDNS: Bool
316316

@@ -332,7 +332,7 @@ extension REST {
332332
}
333333
}
334334

335-
private struct RotateDeviceKeyRequest: Encodable {
335+
private struct RotateDeviceKeyRequest: Encodable, Sendable {
336336
let publicKey: PublicKey
337337

338338
private enum CodingKeys: String, CodingKey {

0 commit comments

Comments
 (0)