diff --git a/FirebaseAuth/Sources/Swift/Backend/IdentityToolkitRequest.swift b/FirebaseAuth/Sources/Swift/Backend/IdentityToolkitRequest.swift index 08f9f9f30d6..7378b517a7d 100644 --- a/FirebaseAuth/Sources/Swift/Backend/IdentityToolkitRequest.swift +++ b/FirebaseAuth/Sources/Swift/Backend/IdentityToolkitRequest.swift @@ -19,15 +19,9 @@ private let kHttpProtocol = "http:" private let kEmulatorHostAndPrefixFormat = "%@/%@" -#if compiler(>=6) - /// Host for server API calls. This should be changed via - /// `IdentityToolkitRequest.setHost(_ host:)` for testing purposes only. - private nonisolated(unsafe) var gAPIHost = "www.googleapis.com" -#else - /// Host for server API calls. This should be changed via - /// `IdentityToolkitRequest.setHost(_ host:)` for testing purposes only. - private var gAPIHost = "www.googleapis.com" -#endif // compiler(>=6) +/// Host for server API calls. This should be changed via +/// `IdentityToolkitRequest.setHost(_ host:)` for testing purposes only. +private nonisolated(unsafe) var gAPIHost = "www.googleapis.com" private let kFirebaseAuthAPIHost = "www.googleapis.com" private let kIdentityPlatformAPIHost = "identitytoolkit.googleapis.com" diff --git a/FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift b/FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift index 175b1889b96..cd26caa83f5 100644 --- a/FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift +++ b/FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift @@ -54,15 +54,9 @@ private let kRefreshTokenKey = "refreshToken" /// The key for the "code" parameter in the request. private let kCodeKey = "code" -#if compiler(>=6) - /// Host for server API calls. This should be changed via - /// `SecureTokenRequest.setHost(_ host:)` for testing purposes only. - private nonisolated(unsafe) var gAPIHost = "securetoken.googleapis.com" -#else - /// Host for server API calls. This should be changed via - /// `SecureTokenRequest.setHost(_ host:)` for testing purposes only. - private var gAPIHost = "securetoken.googleapis.com" -#endif // compiler(>=6) +/// Host for server API calls. This should be changed via +/// `SecureTokenRequest.setHost(_ host:)` for testing purposes only. +private nonisolated(unsafe) var gAPIHost = "securetoken.googleapis.com" /// Represents the parameters for the token endpoint. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) diff --git a/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift b/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift index 3e428f8a88e..f28c2038582 100644 --- a/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift +++ b/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatStorage.swift @@ -52,22 +52,9 @@ final class HeartbeatStorage: Sendable, HeartbeatStorageProtocol { // MARK: - Instance Management /// Statically allocated cache of `HeartbeatStorage` instances keyed by string IDs. - #if compiler(>=6) - // In Swift 6, this property is not concurrency-safe because it is - // nonisolated global shared mutable state. Because this target's - // deployment version does not support Swift concurrency, it is marked as - // `nonisolated(unsafe)` to disable concurrency-safety checks. The - // property's access is protected by an external synchronization mechanism - // (see `instancesLock` property). - private nonisolated(unsafe) static var cachedInstances: AtomicBox< - [String: WeakContainer] - > = AtomicBox([:]) - #else - // TODO(Xcode 16): Delete this block when minimum supported Xcode is - // Xcode 16. - static var cachedInstances: AtomicBox<[String: WeakContainer]> = - AtomicBox([:]) - #endif // compiler(>=6) + private nonisolated(unsafe) static var cachedInstances: AtomicBox< + [String: WeakContainer] + > = AtomicBox([:]) /// Gets an existing `HeartbeatStorage` instance with the given `id` if one exists. Otherwise, /// makes a new instance with the given `id`. diff --git a/FirebaseFunctions/Sources/Functions.swift b/FirebaseFunctions/Sources/Functions.swift index fa943bc3f6d..e747f56467a 100644 --- a/FirebaseFunctions/Sources/Functions.swift +++ b/FirebaseFunctions/Sources/Functions.swift @@ -82,12 +82,8 @@ enum FunctionsConstants { /// A map of active instances, grouped by app. Keys are FirebaseApp names and values are arrays /// containing all instances of Functions associated with the given app. - #if compiler(>=6.0) - private nonisolated(unsafe) static var instances: AtomicBox<[String: [Functions]]> = - AtomicBox([:]) - #else - private static var instances: AtomicBox<[String: [Functions]]> = AtomicBox([:]) - #endif + private nonisolated(unsafe) static var instances: AtomicBox<[String: [Functions]]> = + AtomicBox([:]) /// The custom domain to use for all functions references (optional). let customDomain: String? @@ -605,65 +601,34 @@ enum FunctionsConstants { } } - #if compiler(>=6.0) - @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) - private func callableStreamResult(fromResponseData data: Data, - endpointURL url: URL) throws -> sending JSONStreamResponse { - let data = try processedData(fromResponseData: data, endpointURL: url) - - let responseJSONObject: Any - do { - responseJSONObject = try JSONSerialization.jsonObject(with: data) - } catch { - throw FunctionsError(.dataLoss, userInfo: [NSUnderlyingErrorKey: error]) - } - - guard let responseJSON = responseJSONObject as? [String: Any] else { - let userInfo = [NSLocalizedDescriptionKey: "Response was not a dictionary."] - throw FunctionsError(.dataLoss, userInfo: userInfo) - } + @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) + private func callableStreamResult(fromResponseData data: Data, + endpointURL url: URL) throws -> sending JSONStreamResponse { + let data = try processedData(fromResponseData: data, endpointURL: url) - if let _ = responseJSON["result"] { - return .result(responseJSON) - } else if let _ = responseJSON["message"] { - return .message(responseJSON) - } else { - throw FunctionsError( - .dataLoss, - userInfo: [NSLocalizedDescriptionKey: "Response is missing result or message field."] - ) - } + let responseJSONObject: Any + do { + responseJSONObject = try JSONSerialization.jsonObject(with: data) + } catch { + throw FunctionsError(.dataLoss, userInfo: [NSUnderlyingErrorKey: error]) } - #else - @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) - private func callableStreamResult(fromResponseData data: Data, - endpointURL url: URL) throws -> JSONStreamResponse { - let data = try processedData(fromResponseData: data, endpointURL: url) - - let responseJSONObject: Any - do { - responseJSONObject = try JSONSerialization.jsonObject(with: data) - } catch { - throw FunctionsError(.dataLoss, userInfo: [NSUnderlyingErrorKey: error]) - } - guard let responseJSON = responseJSONObject as? [String: Any] else { - let userInfo = [NSLocalizedDescriptionKey: "Response was not a dictionary."] - throw FunctionsError(.dataLoss, userInfo: userInfo) - } + guard let responseJSON = responseJSONObject as? [String: Any] else { + let userInfo = [NSLocalizedDescriptionKey: "Response was not a dictionary."] + throw FunctionsError(.dataLoss, userInfo: userInfo) + } - if let _ = responseJSON["result"] { - return .result(responseJSON) - } else if let _ = responseJSON["message"] { - return .message(responseJSON) - } else { - throw FunctionsError( - .dataLoss, - userInfo: [NSLocalizedDescriptionKey: "Response is missing result or message field."] - ) - } + if let _ = responseJSON["result"] { + return .result(responseJSON) + } else if let _ = responseJSON["message"] { + return .message(responseJSON) + } else { + throw FunctionsError( + .dataLoss, + userInfo: [NSLocalizedDescriptionKey: "Response is missing result or message field."] + ) } - #endif // compiler(>=6.0) + } private func jsonData(jsonText: String) throws -> Data { guard let data = jsonText.data(using: .utf8) else { diff --git a/FirebaseRemoteConfig/Tests/Swift/FakeUtils/MockURLProtocol.swift b/FirebaseRemoteConfig/Tests/Swift/FakeUtils/MockURLProtocol.swift index 7761e4e523d..82fa9c6fe34 100644 --- a/FirebaseRemoteConfig/Tests/Swift/FakeUtils/MockURLProtocol.swift +++ b/FirebaseRemoteConfig/Tests/Swift/FakeUtils/MockURLProtocol.swift @@ -15,17 +15,10 @@ import Foundation class MockURLProtocol: URLProtocol { - #if compiler(>=6) - nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> ( - Data, - HTTPURLResponse - ))? - #else - static var requestHandler: ((URLRequest) throws -> ( - Data, - HTTPURLResponse - ))? - #endif + nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> ( + Data, + HTTPURLResponse + ))? override class func canInit(with request: URLRequest) -> Bool { #if os(watchOS) diff --git a/FirebaseSessions/Sources/Public/SessionsDependencies.swift b/FirebaseSessions/Sources/Public/SessionsDependencies.swift index 4f366df9ba4..e929fff98d4 100644 --- a/FirebaseSessions/Sources/Public/SessionsDependencies.swift +++ b/FirebaseSessions/Sources/Public/SessionsDependencies.swift @@ -46,16 +46,10 @@ private final class AtomicBox { /// dependent SDKs @objc(FIRSessionsDependencies) public class SessionsDependencies: NSObject { - #if compiler(>=6) - private nonisolated(unsafe) static let _dependencies: AtomicBox> = - AtomicBox( - Set() - ) - #else - private static let _dependencies: AtomicBox> = AtomicBox( + private nonisolated(unsafe) static let _dependencies: AtomicBox> = + AtomicBox( Set() ) - #endif static var dependencies: Set { _dependencies.value() diff --git a/FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift b/FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift index c783718c50d..cc3dc36bd30 100644 --- a/FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift +++ b/FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift @@ -2611,19 +2611,11 @@ fileprivate struct _JSONKey : CodingKey { //===----------------------------------------------------------------------===// // 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. -#if compiler(>=6) nonisolated(unsafe) fileprivate var _iso8601Formatter: ISO8601DateFormatter = { let formatter = ISO8601DateFormatter() formatter.formatOptions = .withInternetDateTime return formatter }() -#else -fileprivate var _iso8601Formatter: ISO8601DateFormatter = { - let formatter = ISO8601DateFormatter() - formatter.formatOptions = .withInternetDateTime - return formatter -}() -#endif //===----------------------------------------------------------------------===// // Error Utilities diff --git a/FirebaseVertexAI/Sources/Chat.swift b/FirebaseVertexAI/Sources/Chat.swift index 2c3ce2d4c7f..1aa2c3490c7 100644 --- a/FirebaseVertexAI/Sources/Chat.swift +++ b/FirebaseVertexAI/Sources/Chat.swift @@ -27,11 +27,7 @@ public final class Chat: Sendable { } private let historyLock = NSLock() - #if compiler(>=6) - private nonisolated(unsafe) var _history: [ModelContent] = [] - #else - private var _history: [ModelContent] = [] - #endif + private nonisolated(unsafe) var _history: [ModelContent] = [] /// The previous content from the chat that has been successfully sent and received from the /// model. This will be provided to the model for each message sent as context for the discussion. public var history: [ModelContent] { diff --git a/FirebaseVertexAI/Sources/VertexAI.swift b/FirebaseVertexAI/Sources/VertexAI.swift index c3ef7d2df73..fef0d5c3fd1 100644 --- a/FirebaseVertexAI/Sources/VertexAI.swift +++ b/FirebaseVertexAI/Sources/VertexAI.swift @@ -140,21 +140,12 @@ public class VertexAI { let apiConfig: APIConfig - #if compiler(>=6) - /// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in - /// the format `appName:location`. - private nonisolated(unsafe) static var instances: [InstanceKey: VertexAI] = [:] + /// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in + /// the format `appName:location`. + private nonisolated(unsafe) static var instances: [InstanceKey: VertexAI] = [:] - /// Lock to manage access to the `instances` array to avoid race conditions. - private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init() - #else - /// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in - /// the format `appName:location`. - private static var instances: [InstanceKey: VertexAI] = [:] - - /// Lock to manage access to the `instances` array to avoid race conditions. - private static var instancesLock: os_unfair_lock = .init() - #endif + /// Lock to manage access to the `instances` array to avoid race conditions. + private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init() let location: String? diff --git a/FirebaseVertexAI/Tests/Unit/MockURLProtocol.swift b/FirebaseVertexAI/Tests/Unit/MockURLProtocol.swift index 335af1b5667..5385b164015 100644 --- a/FirebaseVertexAI/Tests/Unit/MockURLProtocol.swift +++ b/FirebaseVertexAI/Tests/Unit/MockURLProtocol.swift @@ -17,17 +17,10 @@ import XCTest @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) class MockURLProtocol: URLProtocol, @unchecked Sendable { - #if compiler(>=6) - nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> ( - URLResponse, - AsyncLineSequence? - ))? - #else - static var requestHandler: ((URLRequest) throws -> ( - URLResponse, - AsyncLineSequence? - ))? - #endif + nonisolated(unsafe) static var requestHandler: ((URLRequest) throws -> ( + URLResponse, + AsyncLineSequence? + ))? override class func canInit(with request: URLRequest) -> Bool { #if os(watchOS) print("MockURLProtocol cannot be used on watchOS.")