diff --git a/.github/workflows/vertexai.yml b/.github/workflows/vertexai.yml index 2b727b13831..3e9bf41e292 100644 --- a/.github/workflows/vertexai.yml +++ b/.github/workflows/vertexai.yml @@ -72,6 +72,29 @@ jobs: retry_wait_seconds: 120 command: scripts/build.sh FirebaseVertexAIIntegration ${{ matrix.target }} spm + pod-lib-lint: + # Don't run on private repo unless it is a PR. + if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request' + strategy: + matrix: + target: [ios] + os: [macos-14] + include: + - os: macos-14 + xcode: Xcode_15.2 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Clone mock responses + run: scripts/update_vertexai_responses.sh + - uses: ruby/setup-ruby@v1 + - name: Setup Bundler + run: scripts/setup_bundler.sh + - name: Xcode + run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer + - name: Build and test + run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseVertexAI.podspec --platforms=${{ matrix.target }} + sample: strategy: matrix: diff --git a/FirebaseVertexAI-Docs.not_podspec b/FirebaseVertexAI-Docs.not_podspec deleted file mode 100644 index 4c447335f65..00000000000 --- a/FirebaseVertexAI-Docs.not_podspec +++ /dev/null @@ -1,47 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'FirebaseVertexAI-Docs' - s.version = '10.27.0' - s.summary = 'Firebase Vertex AI' - - s.description = <<-DESC - Placeholder podspec for docsgen only. Do not use this pod. - - NOTE: Rename the file extension from `.not_podspec` to `.podspec` before - running `pod gen` for docs generation. - DESC - - s.homepage = 'https://firebase.google.com' - s.license = { :type => 'Apache-2.0', :file => 'LICENSE' } - s.authors = 'Google, Inc.' - - s.source = { - :git => 'https://github.com/firebase/firebase-ios-sdk.git', - :tag => 'CocoaPods-' + s.version.to_s - } - - s.social_media_url = 'https://twitter.com/Firebase' - - ios_deployment_target = '15.0' - osx_deployment_target = '11.0' - - s.ios.deployment_target = ios_deployment_target - s.osx.deployment_target = osx_deployment_target - - s.cocoapods_version = '>= 1.12.0' - s.prefix_header_file = false - - s.source_files = [ - 'FirebaseVertexAI/Sources/**/*.swift', - ] - - s.swift_version = '5.9' - - s.framework = 'Foundation' - s.ios.framework = 'UIKit' - s.osx.framework = 'AppKit' - - s.dependency 'FirebaseAppCheckInterop', '~> 10.17' - s.dependency 'FirebaseAuthInterop', '~> 10.25' - s.dependency 'FirebaseCore', '~> 10.5' - s.dependency 'FirebaseCoreExtension', '~> 10.0' -end diff --git a/FirebaseVertexAI.podspec b/FirebaseVertexAI.podspec new file mode 100644 index 00000000000..a5251b4dc1f --- /dev/null +++ b/FirebaseVertexAI.podspec @@ -0,0 +1,67 @@ +Pod::Spec.new do |s| + s.name = 'FirebaseVertexAI' + s.version = '11.2.0-beta' + s.summary = 'Vertex AI in Firebase - Public Preview' + + s.description = <<-DESC +[Public Preview] Build AI-powered apps and features with the Gemini API using +the Vertex AI in Firebase SDK. + DESC + + s.homepage = 'https://firebase.google.com' + s.license = { :type => 'Apache-2.0', :file => 'LICENSE' } + s.authors = 'Google, Inc.' + + s.source = { + :git => 'https://github.com/firebase/firebase-ios-sdk.git', + :tag => 'CocoaPods-' + s.version.to_s + } + + s.social_media_url = 'https://twitter.com/Firebase' + + ios_deployment_target = '15.0' + osx_deployment_target = '11.0' + tvos_deployment_target = '15.0' + watchos_deployment_target = '8.0' + + s.ios.deployment_target = ios_deployment_target + s.osx.deployment_target = osx_deployment_target + s.tvos.deployment_target = tvos_deployment_target + s.watchos.deployment_target = watchos_deployment_target + + s.cocoapods_version = '>= 1.12.0' + s.prefix_header_file = false + + s.source_files = [ + 'FirebaseVertexAI/Sources/**/*.swift', + ] + + s.swift_version = '5.9' + + s.framework = 'Foundation' + s.ios.framework = 'UIKit' + s.osx.framework = 'AppKit' + s.tvos.framework = 'UIKit' + s.watchos.framework = 'WatchKit' + + s.dependency 'FirebaseAppCheckInterop', '~> 11.2' + s.dependency 'FirebaseAuthInterop', '~> 11.2' + s.dependency 'FirebaseCore', '~> 11.2' + s.dependency 'FirebaseCoreExtension', '~> 11.2' + + s.test_spec 'unit' do |unit_tests| + unit_tests_dir = 'FirebaseVertexAI/Tests/Unit/' + unit_tests.scheme = { :code_coverage => true } + unit_tests.platforms = { + :ios => ios_deployment_target, + :osx => osx_deployment_target, + :tvos => tvos_deployment_target + } + unit_tests.source_files = [ + unit_tests_dir + '**/*.swift', + ] + unit_tests.resources = [ + unit_tests_dir + 'vertexai-sdk-test-data/mock-responses/**/*.{txt,json}', + ] + end +end diff --git a/FirebaseVertexAI/Tests/Unit/ChatTests.swift b/FirebaseVertexAI/Tests/Unit/ChatTests.swift index 56dbf5ff5cc..2e55b73020f 100644 --- a/FirebaseVertexAI/Tests/Unit/ChatTests.swift +++ b/FirebaseVertexAI/Tests/Unit/ChatTests.swift @@ -32,7 +32,12 @@ final class ChatTests: XCTestCase { } func testMergingText() async throws { - let fileURL = try XCTUnwrap(Bundle.module.url( + #if SWIFT_PACKAGE + let bundle = Bundle.module + #else // SWIFT_PACKAGE + let bundle = Bundle(for: Self.self) + #endif // SWIFT_PACKAGE + let fileURL = try XCTUnwrap(bundle.url( forResource: "streaming-success-basic-reply-parts", withExtension: "txt" )) diff --git a/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift b/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift index ef494760b60..f112168151a 100644 --- a/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift +++ b/FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift @@ -1278,7 +1278,12 @@ final class GenerativeModelTests: XCTestCase { #if os(watchOS) throw XCTSkip("Custom URL protocols are unsupported in watchOS 2 and later.") #endif // os(watchOS) - let fileURL = try XCTUnwrap(Bundle.module.url(forResource: name, withExtension: ext)) + #if SWIFT_PACKAGE + let bundle = Bundle.module + #else // SWIFT_PACKAGE + let bundle = Bundle(for: Self.self) + #endif // SWIFT_PACKAGE + let fileURL = try XCTUnwrap(bundle.url(forResource: name, withExtension: ext)) return { request in let requestURL = try XCTUnwrap(request.url) XCTAssertEqual(requestURL.path.occurrenceCount(of: "models/"), 1) diff --git a/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift b/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift index 3ee12eb1c4d..a6f77467c24 100644 --- a/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift +++ b/FirebaseVertexAI/Tests/Unit/VertexComponentTests.swift @@ -14,9 +14,10 @@ import FirebaseCore import Foundation -import SharedTestUtilities import XCTest +@_implementationOnly import FirebaseCoreExtension + @testable import FirebaseVertexAI @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) diff --git a/Package.swift b/Package.swift index ca02d9e4ff0..675d1e3e7aa 100644 --- a/Package.swift +++ b/Package.swift @@ -1305,7 +1305,7 @@ let package = Package( ), .testTarget( name: "FirebaseVertexAIUnit", - dependencies: ["FirebaseVertexAI", "SharedTestUtilities"], + dependencies: ["FirebaseVertexAI"], path: "FirebaseVertexAI/Tests/Unit", resources: [ .process("vertexai-sdk-test-data/mock-responses"),