Skip to content

Commit 0c9f32c

Browse files
authored
feat: add Sendable conformances and fix warnings (#260)
* feat: add Sendable conformances and fix warnings * chore: add existential any * chore: remove swift 5.10 from CI * chore: add any on non-Darwin code * fix library evolution
1 parent 08eefdc commit 0c9f32c

38 files changed

+260
-197
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
pull_request:
88
branches:
9-
- '*'
9+
- "*"
1010
workflow_dispatch:
1111

1212
concurrency:
@@ -37,41 +37,33 @@ jobs:
3737
library-linux:
3838
runs-on: ubuntu-latest
3939
name: Test Library (Linux)
40+
strategy:
41+
matrix:
42+
swift-version: ["5.8", "5.9"]
4043
steps:
4144
- uses: swift-actions/setup-swift@v1
4245
with:
43-
swift-version: "5.9"
46+
swift-version: "${{ matrix.swift-version }}"
4447
- uses: actions/checkout@v3
4548
- name: Run Tests
4649
run: swift test
4750

48-
library-compatibility:
49-
runs-on: ubuntu-latest
50-
name: Test Library (Swift 5.8)
51+
library-windows:
52+
runs-on: windows-latest
53+
name: Test Library (Windows)
5154
steps:
52-
- uses: swift-actions/setup-swift@v1
55+
# We use BCNY's repo since they have newer builds of Swift
56+
# which have fixed libcurl in Foundation.
57+
- uses: compnerd/gha-setup-swift@main
5358
with:
54-
swift-version: "5.8"
59+
release-tag-name: "20231203.0"
60+
github-repo: "thebrowsercompany/swift-build"
61+
release-asset-name: installer-amd64.exe
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
5563
- uses: actions/checkout@v3
5664
- name: Run Tests
5765
run: swift test
5866

59-
library-windows:
60-
runs-on: windows-latest
61-
name: Test Library (Windows)
62-
steps:
63-
# We use BCNY's repo since they have newer builds of Swift
64-
# which have fixed libcurl in Foundation.
65-
- uses: compnerd/gha-setup-swift@main
66-
with:
67-
release-tag-name: "20231203.0"
68-
github-repo: "thebrowsercompany/swift-build"
69-
release-asset-name: installer-amd64.exe
70-
github-token: ${{ secrets.GITHUB_TOKEN }}
71-
- uses: actions/checkout@v3
72-
- name: Run Tests
73-
run: swift test
74-
7567
examples:
7668
runs-on: macos-14
7769
name: Build Examples

Examples/Examples/Auth/GoogleSignInSDKFlow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// Created by Guilherme Souza on 05/03/24.
66
//
77

8-
import SwiftUI
98
@preconcurrency import GoogleSignIn
109
import GoogleSignInSwift
1110
import Supabase
11+
import SwiftUI
1212

1313
@MainActor
1414
struct GoogleSignInSDKFlow: View {

Examples/Examples/ExamplesApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// Created by Guilherme Souza on 22/12/22.
66
//
77

8+
import GoogleSignIn
89
import Supabase
910
import SwiftUI
10-
import GoogleSignIn
1111

1212
@main
1313
struct ExamplesApp: App {

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ let package = Package(
137137

138138
for target in package.targets where !target.isTest {
139139
target.swiftSettings = [
140-
.enableUpcomingFeature("StrictConcurrency=complete"),
140+
.enableUpcomingFeature("ExistentialAny"),
141+
.enableExperimentalFeature("StrictConcurrency"),
141142
]
142143
}

Sources/Auth/AuthClient.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public actor AuthClient {
1616
public let url: URL
1717
public var headers: [String: String]
1818
public let flowType: AuthFlowType
19-
public let localStorage: AuthLocalStorage
20-
public let logger: SupabaseLogger?
19+
public let localStorage: any AuthLocalStorage
20+
public let logger: (any SupabaseLogger)?
2121
public let encoder: JSONEncoder
2222
public let decoder: JSONDecoder
2323
public let fetch: FetchHandler
@@ -37,8 +37,8 @@ public actor AuthClient {
3737
url: URL,
3838
headers: [String: String] = [:],
3939
flowType: AuthFlowType = Configuration.defaultFlowType,
40-
localStorage: AuthLocalStorage,
41-
logger: SupabaseLogger? = nil,
40+
localStorage: any AuthLocalStorage,
41+
logger: (any SupabaseLogger)? = nil,
4242
encoder: JSONEncoder = AuthClient.Configuration.jsonEncoder,
4343
decoder: JSONDecoder = AuthClient.Configuration.jsonDecoder,
4444
fetch: @escaping FetchHandler = { try await URLSession.shared.data(for: $0) }
@@ -64,23 +64,23 @@ public actor AuthClient {
6464
Dependencies.current.value!.api
6565
}
6666

67-
private var sessionManager: SessionManager {
67+
private var sessionManager: any SessionManager {
6868
Dependencies.current.value!.sessionManager
6969
}
7070

7171
private var codeVerifierStorage: CodeVerifierStorage {
7272
Dependencies.current.value!.codeVerifierStorage
7373
}
7474

75-
private var eventEmitter: EventEmitter {
75+
private var eventEmitter: any EventEmitter {
7676
Dependencies.current.value!.eventEmitter
7777
}
7878

7979
private var currentDate: @Sendable () -> Date {
8080
Dependencies.current.value!.currentDate
8181
}
8282

83-
private var logger: SupabaseLogger? {
83+
private var logger: (any SupabaseLogger)? {
8484
Dependencies.current.value!.logger
8585
}
8686

@@ -116,8 +116,8 @@ public actor AuthClient {
116116
url: URL,
117117
headers: [String: String] = [:],
118118
flowType: AuthFlowType = AuthClient.Configuration.defaultFlowType,
119-
localStorage: AuthLocalStorage,
120-
logger: SupabaseLogger? = nil,
119+
localStorage: any AuthLocalStorage,
120+
logger: (any SupabaseLogger)? = nil,
121121
encoder: JSONEncoder = AuthClient.Configuration.jsonEncoder,
122122
decoder: JSONDecoder = AuthClient.Configuration.jsonDecoder,
123123
fetch: @escaping FetchHandler = { try await URLSession.shared.data(for: $0) }
@@ -160,12 +160,12 @@ public actor AuthClient {
160160
/// This internal initializer is here only for easy injecting mock instances when testing.
161161
init(
162162
configuration: Configuration,
163-
sessionManager: SessionManager,
163+
sessionManager: any SessionManager,
164164
codeVerifierStorage: CodeVerifierStorage,
165165
api: APIClient,
166-
eventEmitter: EventEmitter,
166+
eventEmitter: any EventEmitter,
167167
sessionStorage: SessionStorage,
168-
logger: SupabaseLogger?
168+
logger: (any SupabaseLogger)?
169169
) {
170170
mfa = AuthMFA()
171171
admin = AuthAdmin()
@@ -198,7 +198,7 @@ public actor AuthClient {
198198
@discardableResult
199199
public func onAuthStateChange(
200200
_ listener: @escaping AuthStateChangeListener
201-
) async -> AuthStateChangeListenerRegistration {
201+
) async -> some AuthStateChangeListenerRegistration {
202202
let handle = eventEmitter.attachListener(listener)
203203
await emitInitialSession(forHandle: handle)
204204
return handle

Sources/Auth/AuthMFA.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ public actor AuthMFA {
77
Dependencies.current.value!.api
88
}
99

10-
private var sessionManager: SessionManager {
10+
private var sessionManager: any SessionManager {
1111
Dependencies.current.value!.sessionManager
1212
}
1313

1414
private var configuration: AuthClient.Configuration {
1515
Dependencies.current.value!.configuration
1616
}
1717

18-
private var eventEmitter: EventEmitter {
18+
private var eventEmitter: any EventEmitter {
1919
Dependencies.current.value!.eventEmitter
2020
}
2121

Sources/Auth/Deprecated.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension AuthClient.Configuration {
7171
url: URL,
7272
headers: [String: String] = [:],
7373
flowType: AuthFlowType = Self.defaultFlowType,
74-
localStorage: AuthLocalStorage,
74+
localStorage: any AuthLocalStorage,
7575
encoder: JSONEncoder = AuthClient.Configuration.jsonEncoder,
7676
decoder: JSONDecoder = AuthClient.Configuration.jsonDecoder,
7777
fetch: @escaping AuthClient.FetchHandler = { try await URLSession.shared.data(for: $0) }
@@ -109,7 +109,7 @@ extension AuthClient {
109109
url: URL,
110110
headers: [String: String] = [:],
111111
flowType: AuthFlowType = Configuration.defaultFlowType,
112-
localStorage: AuthLocalStorage,
112+
localStorage: any AuthLocalStorage,
113113
encoder: JSONEncoder = AuthClient.Configuration.jsonEncoder,
114114
decoder: JSONDecoder = AuthClient.Configuration.jsonDecoder,
115115
fetch: @escaping AuthClient.FetchHandler = { try await URLSession.shared.data(for: $0) }

Sources/Auth/Internal/CodeVerifierStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct CodeVerifierStorage: Sendable {
99

1010
extension CodeVerifierStorage {
1111
static var live: Self = {
12-
var localStorage: AuthLocalStorage {
12+
var localStorage: any AuthLocalStorage {
1313
Dependencies.current.value!.configuration.localStorage
1414
}
1515

Sources/Auth/Internal/Dependencies.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ struct Dependencies: Sendable {
66
static let current = LockIsolated(Dependencies?.none)
77

88
var configuration: AuthClient.Configuration
9-
var sessionManager: SessionManager
9+
var sessionManager: any SessionManager
1010
var api: APIClient
11-
var eventEmitter: EventEmitter
11+
var eventEmitter: any EventEmitter
1212
var sessionStorage: SessionStorage
1313
var sessionRefresher: SessionRefresher
1414
var codeVerifierStorage: CodeVerifierStorage
1515
var currentDate: @Sendable () -> Date = { Date() }
16-
var logger: SupabaseLogger?
16+
var logger: (any SupabaseLogger)?
1717
}

Sources/Auth/Internal/SessionManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ actor DefaultSessionManager: SessionManager {
2222

2323
private init() {}
2424

25-
private var task: Task<Session, Error>?
25+
private var task: Task<Session, any Error>?
2626

2727
private var storage: SessionStorage {
2828
Dependencies.current.value!.sessionStorage

0 commit comments

Comments
 (0)