Skip to content

Commit 0842f0a

Browse files
authored
[Infra] Sessions Xcode 26 beta warnings (#15100)
1 parent af36805 commit 0842f0a

File tree

4 files changed

+37
-22
lines changed

4 files changed

+37
-22
lines changed

FirebaseSessions/Sources/EventGDTLogger.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import Foundation
1818
internal import GoogleDataTransport
1919

2020
protocol EventGDTLoggerProtocol: Sendable {
21-
func logEvent(event: SessionStartEvent, completion: @escaping (Result<Void, Error>) -> Void)
21+
func logEvent(event: SessionStartEvent,
22+
completion: @escaping @Sendable (Result<Void, Error>) -> Void)
2223
}
2324

2425
///
@@ -38,7 +39,8 @@ final class EventGDTLogger: EventGDTLoggerProtocol {
3839

3940
/// Logs the event to FireLog, taking into account debugging cases such as running
4041
/// in simulator.
41-
func logEvent(event: SessionStartEvent, completion: @escaping (Result<Void, Error>) -> Void) {
42+
func logEvent(event: SessionStartEvent,
43+
completion: @escaping @Sendable (Result<Void, Error>) -> Void) {
4244
let gdtEvent = googleDataTransport.eventForTransport()
4345
gdtEvent.dataObject = event
4446
gdtEvent.qosTier = GDTCOREventQoS.qosDefault

FirebaseSessions/Sources/GoogleDataTransport+GoogleDataTransportProtocol.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ enum GoogleDataTransportProtocolErrors: Error {
2222
}
2323

2424
protocol GoogleDataTransportProtocol: Sendable {
25-
func logGDTEvent(event: GDTCOREvent, completion: @escaping (Result<Void, Error>) -> Void)
25+
func logGDTEvent(event: GDTCOREvent,
26+
completion: @escaping @Sendable (Result<Void, Error>) -> Void)
2627
func eventForTransport() -> GDTCOREvent
2728
}
2829

@@ -38,7 +39,8 @@ final class GoogleDataTransporter: GoogleDataTransportProtocol {
3839
transporter = GDTCORTransport(mappingID: mappingID, transformers: transformers, target: target)!
3940
}
4041

41-
func logGDTEvent(event: GDTCOREvent, completion: @escaping (Result<Void, any Error>) -> Void) {
42+
func logGDTEvent(event: GDTCOREvent,
43+
completion: @escaping @Sendable (Result<Void, any Error>) -> Void) {
4244
transporter.sendDataEvent(event) { wasWritten, error in
4345
if let error {
4446
completion(.failure(error))

FirebaseSessions/Sources/SessionCoordinator.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import Foundation
1616

1717
protocol SessionCoordinatorProtocol: Sendable {
1818
func attemptLoggingSessionStart(event: SessionStartEvent,
19-
callback: @escaping (Result<Void, FirebaseSessionsError>) -> Void)
19+
callback: @escaping @Sendable (Result<Void,
20+
FirebaseSessionsError>) -> Void)
2021
}
2122

2223
///
@@ -37,7 +38,10 @@ final class SessionCoordinator: SessionCoordinatorProtocol {
3738
/// Begins the process of logging a SessionStartEvent to FireLog after
3839
/// it has been approved for sending
3940
func attemptLoggingSessionStart(event: SessionStartEvent,
40-
callback: @escaping (Result<Void, FirebaseSessionsError>)
41+
callback: @escaping @Sendable (Result<
42+
Void,
43+
FirebaseSessionsError
44+
>)
4145
-> Void) {
4246
/// Order of execution
4347
/// 1. Fetch the installations Id. Regardless of success, move to step 2

FirebaseSessions/Tests/Unit/SessionCoordinatorTests.swift

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ import XCTest
1717

1818
@testable import FirebaseSessions
1919

20+
private class SendableBox<Value>: @unchecked Sendable {
21+
var value: Value
22+
init(value: Value) {
23+
self.value = value
24+
}
25+
}
26+
2027
class SessionCoordinatorTests: XCTestCase {
2128
var installations = MockInstallationsProtocol()
2229
var time = MockTimeProvider()
@@ -50,13 +57,13 @@ class SessionCoordinatorTests: XCTestCase {
5057

5158
func test_attemptLoggingSessionStart_logsToGDT() throws {
5259
let event = SessionStartEvent(sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
53-
var resultSuccess = false
60+
let resultSuccess = SendableBox(value: false)
5461
coordinator.attemptLoggingSessionStart(event: event) { result in
5562
switch result {
5663
case .success(()):
57-
resultSuccess = true
64+
resultSuccess.value = true
5865
case .failure:
59-
resultSuccess = false
66+
resultSuccess.value = false
6067
}
6168
}
6269
// Make sure we've set the Installation ID
@@ -71,7 +78,7 @@ class SessionCoordinatorTests: XCTestCase {
7178

7279
// We should have logged successfully
7380
XCTAssertEqual(fireLogger.loggedEvent, event)
74-
XCTAssert(resultSuccess)
81+
XCTAssert(resultSuccess.value)
7582
}
7683

7784
func test_attemptLoggingSessionStart_handlesGDTError() throws {
@@ -80,13 +87,13 @@ class SessionCoordinatorTests: XCTestCase {
8087
let event = SessionStartEvent(sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
8188

8289
// Start success so it must be set to false
83-
var resultSuccess = true
90+
let resultSuccess = SendableBox(value: true)
8491
coordinator.attemptLoggingSessionStart(event: event) { result in
8592
switch result {
8693
case .success(()):
87-
resultSuccess = true
94+
resultSuccess.value = true
8895
case .failure:
89-
resultSuccess = false
96+
resultSuccess.value = false
9097
}
9198
}
9299

@@ -102,7 +109,7 @@ class SessionCoordinatorTests: XCTestCase {
102109

103110
// We should have logged the event, but with a failed result
104111
XCTAssertEqual(fireLogger.loggedEvent, event)
105-
XCTAssertFalse(resultSuccess)
112+
XCTAssertFalse(resultSuccess.value)
106113
}
107114

108115
func test_attemptLoggingSessionStart_handlesInstallationsError() throws {
@@ -111,21 +118,21 @@ class SessionCoordinatorTests: XCTestCase {
111118
let event = SessionStartEvent(sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
112119

113120
// Start success so it must be set to false
114-
var resultSuccess = true
121+
let resultSuccess = SendableBox(value: true)
115122
coordinator.attemptLoggingSessionStart(event: event) { result in
116123
switch result {
117124
case .success(()):
118-
resultSuccess = true
125+
resultSuccess.value = true
119126
case .failure:
120-
resultSuccess = false
127+
resultSuccess.value = false
121128
}
122129
}
123130

124131
XCTAssertTrue(installations.authTokenFinished)
125132
XCTAssertTrue(installations.installationIdFinished)
126133
// We should have logged the event, but with a failed result
127134
XCTAssertNotNil(fireLogger.loggedEvent)
128-
XCTAssertFalse(resultSuccess)
135+
XCTAssertFalse(resultSuccess.value)
129136
}
130137

131138
func test_attemptLoggingSessionStart_handlesGDTAndInstallationsError() throws {
@@ -138,13 +145,13 @@ class SessionCoordinatorTests: XCTestCase {
138145
let event = SessionStartEvent(sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
139146

140147
// Start success so it must be set to false
141-
var resultSuccess = true
148+
let resultSuccess = SendableBox(value: true)
142149
coordinator.attemptLoggingSessionStart(event: event) { result in
143150
switch result {
144151
case .success(()):
145-
resultSuccess = true
152+
resultSuccess.value = true
146153
case let .failure(err):
147-
resultSuccess = false
154+
resultSuccess.value = false
148155
// Result should use the FireLog error if there's an error in both
149156
// Installations and FireLog
150157
XCTAssertEqual(err, FirebaseSessionsError.DataTransportError(fireLogError))
@@ -164,6 +171,6 @@ class SessionCoordinatorTests: XCTestCase {
164171

165172
// We should have logged the event, but with a failed result
166173
XCTAssertEqual(fireLogger.loggedEvent, event)
167-
XCTAssertFalse(resultSuccess)
174+
XCTAssertFalse(resultSuccess.value)
168175
}
169176
}

0 commit comments

Comments
 (0)