Skip to content

Commit aba8378

Browse files
authored
Swift 6 build fixes for Vertex AI (#14480)
1 parent eb52340 commit aba8378

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

FirebaseVertexAI/Sources/Protocols/Internal/CodableProtoEnum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
/// A type that represents a Protocol Buffer raw enum value.
16-
protocol ProtoEnum {
16+
protocol ProtoEnum: Sendable {
1717
/// The type representing the valid values for the protobuf enum.
1818
///
1919
/// > Important: This type must conform to `RawRepresentable` with the `RawValue == String`.

FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenAspectRatio.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Foundation
2121
/// documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/image/generate-images#aspect-ratio)
2222
/// for more details and examples of the supported aspect ratios.
2323
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
24-
public struct ImagenAspectRatio {
24+
public struct ImagenAspectRatio: Sendable {
2525
/// Square (1:1) aspect ratio.
2626
///
2727
/// Common uses for this aspect ratio include social media posts.

FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenSafetyFilterLevel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/// guidelines](https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters)
2424
/// for more details.
2525
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
26-
public struct ImagenSafetyFilterLevel: ProtoEnum {
26+
public struct ImagenSafetyFilterLevel: ProtoEnum, Sendable {
2727
enum Kind: String {
2828
case blockLowAndAbove = "block_low_and_above"
2929
case blockMediumAndAbove = "block_medium_and_above"

FirebaseVertexAI/Sources/Types/Public/Schema.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Schema {
4040

4141
/// Modifiers describing the expected format of an integer `Schema`.
4242
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
43-
public struct IntegerFormat: EncodableProtoEnum {
43+
public struct IntegerFormat: EncodableProtoEnum, Sendable {
4444
enum Kind: String {
4545
case int32
4646
case int64

FirebaseVertexAI/Sources/VertexAI.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,21 @@ public class VertexAI {
149149

150150
private let auth: AuthInterop?
151151

152-
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
153-
/// the format `appName:location`.
154-
private static var instances: [String: VertexAI] = [:]
155-
156-
/// Lock to manage access to the `instances` array to avoid race conditions.
157-
private static var instancesLock: os_unfair_lock = .init()
152+
#if compiler(>=6)
153+
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
154+
/// the format `appName:location`.
155+
private nonisolated(unsafe) static var instances: [String: VertexAI] = [:]
156+
157+
/// Lock to manage access to the `instances` array to avoid race conditions.
158+
private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init()
159+
#else
160+
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
161+
/// the format `appName:location`.
162+
private static var instances: [String: VertexAI] = [:]
163+
164+
/// Lock to manage access to the `instances` array to avoid race conditions.
165+
private static var instancesLock: os_unfair_lock = .init()
166+
#endif
158167

159168
let projectID: String
160169
let apiKey: String

0 commit comments

Comments
 (0)