mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
The Xcode 27.2 SDK (FoundationModels 2.1) adds a `Transcript.Entry.data` case, which triggers a "switch must be exhaustive" warning in `GeminiTranscriptTranslator`. Handle the new case by throwing `unsupportedTranscriptContent`, gated with `canImport(FoundationModels, _version: 2.1)` so only the one case is conditionally compiled and Xcode 27.0 and 27.1 continue to build. Add a unit test for the new case. It requires macOS 27.2 or later at runtime, so it is skipped on earlier OS versions. Add a `unit-tests` job to the GeminiLanguageModel workflow that runs `swift test --skip IntegrationTests` on Xcode 27.0 and 27.2, as well as on Xcode 26.6 (macOS 26) and Xcode 26.2 (macOS 15). The FoundationModels code is compiled out on Xcode 26, so those jobs verify that the package still builds and its remaining tests pass with older toolchains. Update the test READMEs to use `--skip IntegrationTests`, since `--skip Integration` also skips the `IntegrationTestingBackendTests` unit tests.
GeminiLanguageModel Integration Tests
End-to-end integration tests validating GeminiLanguageModel sessions against
remote Gemini and Firebase AI Logic backends.
Quick Start
# Run integration tests (using environment variables or GoogleService-Info.plist)
swift test --filter IntegrationTests
# Run a specific integration test suite
swift test --filter ToolCallingIntegrationTests
# Run all unit tests (fast, skips all integration tests)
swift test --skip IntegrationTests
Running Integration Tests
Integration tests in this directory connect to Google Cloud or Firebase endpoints when credentials are configured:
- Gemini Developer API:
Set
GEMINI_API_KEYorGOOGLE_API_KEYin your environment. - Firebase AI Logic:
Provide credentials via a configuration file or individual variables:
- Set
FIREBASE_PLIST_PATHpointing to a validGoogleService-Info.plistfile, along withAppCheckDebugToken. - Alternatively, supply
FIREBASE_PROJECT_ID,FIREBASE_APP_ID,FIREBASE_API_KEY, andAppCheckDebugToken.
- Set
Automatic Skipping
If credentials are not present in the environment, integration tests marked with
.requireIntegrationTestingBackend are automatically and cleanly skipped
without failing test execution.
Supported Backends
All integration tests are parameterized across
IntegrationTestingBackend.availableBackends:
.developerAPI: Direct Gemini Developer API (generativelanguage.googleapis.com)..firebaseAILogicDeveloperAPI: Firebase AI Logic proxy to Gemini Developer API (firebasevertexai.googleapis.com)..firebaseAILogicAgentPlatform(location:): Firebase AI Logic proxy to Gemini Enterprise Agent Platform (defaulting tolocation: "global").
Files in this Directory
BasicContentGenerationIntegrationTests.swift: Parameterized integration tests for single-turn prompt response, multi-turn chat sessions, and streaming chunk responses.GuidedGenerationIntegrationTests.swift: Parameterized integration tests for guided generation (structured outputs) using@Generabletypes, including single-turn and streaming generation, enum classification, and rich multi-type recursive hierarchies.ToolCallingIntegrationTests.swift: Parameterized integration tests for tool calling (function calling) using FoundationModelsTooldefinitions, covering single-turn tool calls, sequential tool calls, parallel tool calls, tool calling mode configuration, parameterless tools with empty arguments, and reasoning models.IntegrationTestingBackend+GeminiLanguageModel.swift: Convenience extension providingbackend.makeModel()to instantiate a pre-configuredGeminiLanguageModel.
Writing New Integration Tests
To add a new integration test suite, parameterize on
IntegrationTestingBackend:
@Suite("My New Feature Integration Tests", .requireFoundationModels)
struct MyNewFeatureIntegrationTests {
@Test(
.tags(.integration),
.requireIntegrationTestingBackend,
arguments: IntegrationTestingBackend.availableBackends
)
@available(macOS 27.0, iOS 27.0, watchOS 27.0, visionOS 27.0, *)
func testFeature(backend: IntegrationTestingBackend) async throws {
let model = try await backend.makeModel()
let session = LanguageModelSession(model: model)
// Execute test assertions...
}
}