Skip to content

Commit d9fd34b

Browse files
authored
[Infra] Remove Swift compiler(>=6) checks (#14771)
1 parent c4f8209 commit d9fd34b

File tree

10 files changed

+50
-151
lines changed

10 files changed

+50
-151
lines changed

FirebaseAuth/Sources/Swift/Backend/IdentityToolkitRequest.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ private let kHttpProtocol = "http:"
1919

2020
private let kEmulatorHostAndPrefixFormat = "%@/%@"
2121

22-
#if compiler(>=6)
23-
/// Host for server API calls. This should be changed via
24-
/// `IdentityToolkitRequest.setHost(_ host:)` for testing purposes only.
25-
private nonisolated(unsafe) var gAPIHost = "www.googleapis.com"
26-
#else
27-
/// Host for server API calls. This should be changed via
28-
/// `IdentityToolkitRequest.setHost(_ host:)` for testing purposes only.
29-
private var gAPIHost = "www.googleapis.com"
30-
#endif // compiler(>=6)
22+
/// Host for server API calls. This should be changed via
23+
/// `IdentityToolkitRequest.setHost(_ host:)` for testing purposes only.
24+
private nonisolated(unsafe) var gAPIHost = "www.googleapis.com"
3125

3226
private let kFirebaseAuthAPIHost = "www.googleapis.com"
3327
private let kIdentityPlatformAPIHost = "identitytoolkit.googleapis.com"

FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,9 @@ private let kRefreshTokenKey = "refreshToken"
5454
/// The key for the "code" parameter in the request.
5555
private let kCodeKey = "code"
5656

57-
#if compiler(>=6)
58-
/// Host for server API calls. This should be changed via
59-
/// `SecureTokenRequest.setHost(_ host:)` for testing purposes only.
60-
private nonisolated(unsafe) var gAPIHost = "securetoken.googleapis.com"
61-
#else
62-
/// Host for server API calls. This should be changed via
63-
/// `SecureTokenRequest.setHost(_ host:)` for testing purposes only.
64-
private var gAPIHost = "securetoken.googleapis.com"
65-
#endif // compiler(>=6)
57+
/// Host for server API calls. This should be changed via
58+
/// `SecureTokenRequest.setHost(_ host:)` for testing purposes only.
59+
private nonisolated(unsafe) var gAPIHost = "securetoken.googleapis.com"
6660

6761
/// Represents the parameters for the token endpoint.
6862
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)

FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,9 @@ final class HeartbeatStorage: Sendable, HeartbeatStorageProtocol {
5252
// MARK: - Instance Management
5353

5454
/// Statically allocated cache of `HeartbeatStorage` instances keyed by string IDs.
55-
#if compiler(>=6)
56-
// In Swift 6, this property is not concurrency-safe because it is
57-
// nonisolated global shared mutable state. Because this target's
58-
// deployment version does not support Swift concurrency, it is marked as
59-
// `nonisolated(unsafe)` to disable concurrency-safety checks. The
60-
// property's access is protected by an external synchronization mechanism
61-
// (see `instancesLock` property).
62-
private nonisolated(unsafe) static var cachedInstances: AtomicBox<
63-
[String: WeakContainer<HeartbeatStorage>]
64-
> = AtomicBox([:])
65-
#else
66-
// TODO(Xcode 16): Delete this block when minimum supported Xcode is
67-
// Xcode 16.
68-
static var cachedInstances: AtomicBox<[String: WeakContainer<HeartbeatStorage>]> =
69-
AtomicBox([:])
70-
#endif // compiler(>=6)
55+
private nonisolated(unsafe) static var cachedInstances: AtomicBox<
56+
[String: WeakContainer<HeartbeatStorage>]
57+
> = AtomicBox([:])
7158

7259
/// Gets an existing `HeartbeatStorage` instance with the given `id` if one exists. Otherwise,
7360
/// makes a new instance with the given `id`.

FirebaseFunctions/Sources/Functions.swift

Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ enum FunctionsConstants {
8282

8383
/// A map of active instances, grouped by app. Keys are FirebaseApp names and values are arrays
8484
/// containing all instances of Functions associated with the given app.
85-
#if compiler(>=6.0)
86-
private nonisolated(unsafe) static var instances: AtomicBox<[String: [Functions]]> =
87-
AtomicBox([:])
88-
#else
89-
private static var instances: AtomicBox<[String: [Functions]]> = AtomicBox([:])
90-
#endif
85+
private nonisolated(unsafe) static var instances: AtomicBox<[String: [Functions]]> =
86+
AtomicBox([:])
9187

9288
/// The custom domain to use for all functions references (optional).
9389
let customDomain: String?
@@ -605,65 +601,34 @@ enum FunctionsConstants {
605601
}
606602
}
607603

608-
#if compiler(>=6.0)
609-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
610-
private func callableStreamResult(fromResponseData data: Data,
611-
endpointURL url: URL) throws -> sending JSONStreamResponse {
612-
let data = try processedData(fromResponseData: data, endpointURL: url)
613-
614-
let responseJSONObject: Any
615-
do {
616-
responseJSONObject = try JSONSerialization.jsonObject(with: data)
617-
} catch {
618-
throw FunctionsError(.dataLoss, userInfo: [NSUnderlyingErrorKey: error])
619-
}
620-
621-
guard let responseJSON = responseJSONObject as? [String: Any] else {
622-
let userInfo = [NSLocalizedDescriptionKey: "Response was not a dictionary."]
623-
throw FunctionsError(.dataLoss, userInfo: userInfo)
624-
}
604+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
605+
private func callableStreamResult(fromResponseData data: Data,
606+
endpointURL url: URL) throws -> sending JSONStreamResponse {
607+
let data = try processedData(fromResponseData: data, endpointURL: url)
625608

626-
if let _ = responseJSON["result"] {
627-
return .result(responseJSON)
628-
} else if let _ = responseJSON["message"] {
629-
return .message(responseJSON)
630-
} else {
631-
throw FunctionsError(
632-
.dataLoss,
633-
userInfo: [NSLocalizedDescriptionKey: "Response is missing result or message field."]
634-
)
635-
}
609+
let responseJSONObject: Any
610+
do {
611+
responseJSONObject = try JSONSerialization.jsonObject(with: data)
612+
} catch {
613+
throw FunctionsError(.dataLoss, userInfo: [NSUnderlyingErrorKey: error])
636614
}
637-
#else
638-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
639-
private func callableStreamResult(fromResponseData data: Data,
640-
endpointURL url: URL) throws -> JSONStreamResponse {
641-
let data = try processedData(fromResponseData: data, endpointURL: url)
642-
643-
let responseJSONObject: Any
644-
do {
645-
responseJSONObject = try JSONSerialization.jsonObject(with: data)
646-
} catch {
647-
throw FunctionsError(.dataLoss, userInfo: [NSUnderlyingErrorKey: error])
648-
}
649615

650-
guard let responseJSON = responseJSONObject as? [String: Any] else {
651-
let userInfo = [NSLocalizedDescriptionKey: "Response was not a dictionary."]
652-
throw FunctionsError(.dataLoss, userInfo: userInfo)
653-
}
616+
guard let responseJSON = responseJSONObject as? [String: Any] else {
617+
let userInfo = [NSLocalizedDescriptionKey: "Response was not a dictionary."]
618+
throw FunctionsError(.dataLoss, userInfo: userInfo)
619+
}
654620

655-
if let _ = responseJSON["result"] {
656-
return .result(responseJSON)
657-
} else if let _ = responseJSON["message"] {
658-
return .message(responseJSON)
659-
} else {
660-
throw FunctionsError(
661-
.dataLoss,
662-
userInfo: [NSLocalizedDescriptionKey: "Response is missing result or message field."]
663-
)
664-
}
621+
if let _ = responseJSON["result"] {
622+
return .result(responseJSON)
623+
} else if let _ = responseJSON["message"] {
624+
return .message(responseJSON)
625+
} else {
626+
throw FunctionsError(
627+
.dataLoss,
628+
userInfo: [NSLocalizedDescriptionKey: "Response is missing result or message field."]
629+
)
665630
}
666-
#endif // compiler(>=6.0)
631+
}
667632

668633
private func jsonData(jsonText: String) throws -> Data {
669634
guard let data = jsonText.data(using: .utf8) else {

FirebaseRemoteConfig/Tests/Swift/FakeUtils/MockURLProtocol.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,10 @@
1515
import Foundation
1616

1717
class MockURLProtocol: URLProtocol {
18-
#if compiler(>=6)
19-
nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> (
20-
Data,
21-
HTTPURLResponse
22-
))?
23-
#else
24-
static var requestHandler: ((URLRequest) throws -> (
25-
Data,
26-
HTTPURLResponse
27-
))?
28-
#endif
18+
nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> (
19+
Data,
20+
HTTPURLResponse
21+
))?
2922

3023
override class func canInit(with request: URLRequest) -> Bool {
3124
#if os(watchOS)

FirebaseSessions/Sources/Public/SessionsDependencies.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,10 @@ private final class AtomicBox<T> {
4646
/// dependent SDKs
4747
@objc(FIRSessionsDependencies)
4848
public class SessionsDependencies: NSObject {
49-
#if compiler(>=6)
50-
private nonisolated(unsafe) static let _dependencies: AtomicBox<Set<SessionsSubscriberName>> =
51-
AtomicBox(
52-
Set()
53-
)
54-
#else
55-
private static let _dependencies: AtomicBox<Set<SessionsSubscriberName>> = AtomicBox(
49+
private nonisolated(unsafe) static let _dependencies: AtomicBox<Set<SessionsSubscriberName>> =
50+
AtomicBox(
5651
Set()
5752
)
58-
#endif
5953

6054
static var dependencies: Set<SessionsSubscriberName> {
6155
_dependencies.value()

FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,19 +2611,11 @@ fileprivate struct _JSONKey : CodingKey {
26112611
//===----------------------------------------------------------------------===//
26122612

26132613
// NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled against the latest SDK (w/ ISO8601DateFormatter), but linked against whichever Foundation the user has. ISO8601DateFormatter might not exist, so we better not hit this code path on an older OS.
2614-
#if compiler(>=6)
26152614
nonisolated(unsafe) fileprivate var _iso8601Formatter: ISO8601DateFormatter = {
26162615
let formatter = ISO8601DateFormatter()
26172616
formatter.formatOptions = .withInternetDateTime
26182617
return formatter
26192618
}()
2620-
#else
2621-
fileprivate var _iso8601Formatter: ISO8601DateFormatter = {
2622-
let formatter = ISO8601DateFormatter()
2623-
formatter.formatOptions = .withInternetDateTime
2624-
return formatter
2625-
}()
2626-
#endif
26272619

26282620
//===----------------------------------------------------------------------===//
26292621
// Error Utilities

FirebaseVertexAI/Sources/Chat.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ public final class Chat: Sendable {
2727
}
2828

2929
private let historyLock = NSLock()
30-
#if compiler(>=6)
31-
private nonisolated(unsafe) var _history: [ModelContent] = []
32-
#else
33-
private var _history: [ModelContent] = []
34-
#endif
30+
private nonisolated(unsafe) var _history: [ModelContent] = []
3531
/// The previous content from the chat that has been successfully sent and received from the
3632
/// model. This will be provided to the model for each message sent as context for the discussion.
3733
public var history: [ModelContent] {

FirebaseVertexAI/Sources/VertexAI.swift

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,12 @@ public class VertexAI {
140140

141141
let apiConfig: APIConfig
142142

143-
#if compiler(>=6)
144-
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
145-
/// the format `appName:location`.
146-
private nonisolated(unsafe) static var instances: [InstanceKey: VertexAI] = [:]
143+
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
144+
/// the format `appName:location`.
145+
private nonisolated(unsafe) static var instances: [InstanceKey: VertexAI] = [:]
147146

148-
/// Lock to manage access to the `instances` array to avoid race conditions.
149-
private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init()
150-
#else
151-
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
152-
/// the format `appName:location`.
153-
private static var instances: [InstanceKey: VertexAI] = [:]
154-
155-
/// Lock to manage access to the `instances` array to avoid race conditions.
156-
private static var instancesLock: os_unfair_lock = .init()
157-
#endif
147+
/// Lock to manage access to the `instances` array to avoid race conditions.
148+
private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init()
158149

159150
let location: String?
160151

FirebaseVertexAI/Tests/Unit/MockURLProtocol.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@ import XCTest
1717

1818
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
1919
class MockURLProtocol: URLProtocol, @unchecked Sendable {
20-
#if compiler(>=6)
21-
nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> (
22-
URLResponse,
23-
AsyncLineSequence<URL.AsyncBytes>?
24-
))?
25-
#else
26-
static var requestHandler: ((URLRequest) throws -> (
27-
URLResponse,
28-
AsyncLineSequence<URL.AsyncBytes>?
29-
))?
30-
#endif
20+
nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> (
21+
URLResponse,
22+
AsyncLineSequence<URL.AsyncBytes>?
23+
))?
3124
override class func canInit(with request: URLRequest) -> Bool {
3225
#if os(watchOS)
3326
print("MockURLProtocol cannot be used on watchOS.")

0 commit comments

Comments
 (0)