diff --git a/FirebaseVertexAI.podspec b/FirebaseVertexAI.podspec index dd4d236209a..0adcb666022 100644 --- a/FirebaseVertexAI.podspec +++ b/FirebaseVertexAI.podspec @@ -49,6 +49,10 @@ Firebase SDK. s.dependency 'FirebaseCore', '~> 11.12.0' s.dependency 'FirebaseCoreExtension', '~> 11.12.0' + s.pod_target_xcconfig = { + 'SWIFT_UPCOMING_FEATURE_INTERNAL_IMPORTS_BY_DEFAULT' => 'YES', + } + s.test_spec 'unit' do |unit_tests| unit_tests_dir = 'FirebaseVertexAI/Tests/Unit/' unit_tests.scheme = { :code_coverage => true } diff --git a/FirebaseVertexAI/Sources/GenerateContentResponse.swift b/FirebaseVertexAI/Sources/GenerateContentResponse.swift index a8a11a21e1f..8d10d17ca7f 100644 --- a/FirebaseVertexAI/Sources/GenerateContentResponse.swift +++ b/FirebaseVertexAI/Sources/GenerateContentResponse.swift @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation +public import Foundation /// The model's response to a generate content request. @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) diff --git a/FirebaseVertexAI/Sources/GenerativeAIRequest.swift b/FirebaseVertexAI/Sources/GenerativeAIRequest.swift index 4f3291e1913..1df54df7cbf 100644 --- a/FirebaseVertexAI/Sources/GenerativeAIRequest.swift +++ b/FirebaseVertexAI/Sources/GenerativeAIRequest.swift @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation +public import Foundation @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) protocol GenerativeAIRequest: Sendable, Encodable { diff --git a/FirebaseVertexAI/Sources/PartsRepresentable+Image.swift b/FirebaseVertexAI/Sources/PartsRepresentable+Image.swift index 5bedeb8f3d1..16c27f34dda 100644 --- a/FirebaseVertexAI/Sources/PartsRepresentable+Image.swift +++ b/FirebaseVertexAI/Sources/PartsRepresentable+Image.swift @@ -12,11 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +import CoreGraphics import UniformTypeIdentifiers + #if canImport(UIKit) - import UIKit // For UIImage extensions. + public import UIKit // For UIImage extensions. #elseif canImport(AppKit) - import AppKit // For NSImage extensions. + public import AppKit // For NSImage extensions. +#endif + +#if canImport(CoreImage) + import CoreImage #endif private let imageCompressionQuality: CGFloat = 0.8 diff --git a/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenImagesBlockedError.swift b/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenImagesBlockedError.swift index e23beab5248..6408c2dfeb9 100644 --- a/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenImagesBlockedError.swift +++ b/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenImagesBlockedError.swift @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation +public import Foundation /// An error that occurs when image generation fails due to all generated images being blocked. /// diff --git a/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenInlineImage.swift b/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenInlineImage.swift index a526dca3e56..3e2296f2e1f 100644 --- a/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenInlineImage.swift +++ b/FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenInlineImage.swift @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation +public import Foundation /// An image generated by Imagen, represented as inline data. @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) diff --git a/FirebaseVertexAI/Sources/Types/Public/Part.swift b/FirebaseVertexAI/Sources/Types/Public/Part.swift index 4890b725f4d..7edccbb2381 100644 --- a/FirebaseVertexAI/Sources/Types/Public/Part.swift +++ b/FirebaseVertexAI/Sources/Types/Public/Part.swift @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation +public import Foundation /// A discrete piece of data in a media format interpretable by an AI model. /// diff --git a/FirebaseVertexAI/Sources/VertexAI.swift b/FirebaseVertexAI/Sources/VertexAI.swift index 112d117047d..ad33b23fcb0 100644 --- a/FirebaseVertexAI/Sources/VertexAI.swift +++ b/FirebaseVertexAI/Sources/VertexAI.swift @@ -14,11 +14,10 @@ import FirebaseAppCheckInterop import FirebaseAuthInterop -import FirebaseCore +import FirebaseCoreExtension import Foundation -// Avoids exposing internal FirebaseCore APIs to Swift users. -@_implementationOnly import FirebaseCoreExtension +public import FirebaseCore /// The Vertex AI for Firebase SDK provides access to Gemini models directly from your app. @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) diff --git a/FirebaseVertexAI/Sources/VertexLog.swift b/FirebaseVertexAI/Sources/VertexLog.swift index ff94a2d435e..b10c9b18881 100644 --- a/FirebaseVertexAI/Sources/VertexLog.swift +++ b/FirebaseVertexAI/Sources/VertexLog.swift @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +import FirebaseCoreExtension import Foundation import os.log -@_implementationOnly import FirebaseCoreExtension - enum VertexLog { /// Log message codes for the Vertex AI SDK /// diff --git a/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift b/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift index 290238445c5..75a4c117599 100644 --- a/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift +++ b/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift @@ -15,9 +15,10 @@ import FirebaseAppCheckInterop import FirebaseAuthInterop import FirebaseCore +import FirebaseVertexAI import XCTest -@testable import FirebaseVertexAI +@testable import struct FirebaseVertexAI.APIConfig @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) final class GenerativeModelTests: XCTestCase { @@ -1690,8 +1691,7 @@ struct AppCheckErrorFake: Error {} @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) extension SafetyRating: Swift.Comparable { - public static func < (lhs: FirebaseVertexAI.SafetyRating, - rhs: FirebaseVertexAI.SafetyRating) -> Bool { + public static func < (lhs: SafetyRating, rhs: SafetyRating) -> Bool { return lhs.category.rawValue < rhs.category.rawValue } } diff --git a/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift b/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift index 6535ba26137..7f8fbf4c502 100644 --- a/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift +++ b/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift @@ -13,12 +13,12 @@ // limitations under the License. @preconcurrency import FirebaseCore +import FirebaseCoreExtension +import FirebaseVertexAI import Foundation import XCTest -@_implementationOnly import FirebaseCoreExtension - -@testable import FirebaseVertexAI +@testable import struct FirebaseVertexAI.APIConfig @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) class VertexComponentTests: XCTestCase { diff --git a/Package.swift b/Package.swift index c19869071fc..0eee4361f4c 100644 --- a/Package.swift +++ b/Package.swift @@ -1308,7 +1308,10 @@ let package = Package( "FirebaseCore", "FirebaseCoreExtension", ], - path: "FirebaseVertexAI/Sources" + path: "FirebaseVertexAI/Sources", + swiftSettings: [ + .enableUpcomingFeature("InternalImportsByDefault"), + ] ), .testTarget( name: "FirebaseVertexAIUnit", @@ -1323,6 +1326,9 @@ let package = Package( ], cSettings: [ .headerSearchPath("../../../"), + ], + swiftSettings: [ + .enableUpcomingFeature("InternalImportsByDefault"), ] ), ] + firestoreTargets(), diff --git a/scripts/check_imports.swift b/scripts/check_imports.swift index ee058f4b0e2..fee25f61a88 100755 --- a/scripts/check_imports.swift +++ b/scripts/check_imports.swift @@ -84,7 +84,11 @@ private func checkFile(_ file: String, logger: ErrorLogger, inRepo repoURL: URL, // Swift specific checks. fileContents.components(separatedBy: .newlines) .enumerated() // [(lineNum, line), ...] - .filter { $1.starts(with: "import FirebaseCoreExtension") } + .filter { + $1.starts(with: "import FirebaseCoreExtension") + /* FirebaseVertexAI is using `InternalImportsByDefault` so its files are not checked. */ + && !file.contains("FirebaseVertexAI") + } .forEach { lineNum, line in logger .importLog(