Add FoundationModelsFake, a nested Swift package that fakes Apple's
Foundation Models framework, so that GeminiLanguageModel (GLM) can build
and run its unit tests on Linux and on OS versions without the real
framework. It's used only for development and testing.
- GLM depends on the fake through a `FoundationModelsFake` package
trait, which is on by default where Darwin isn't available (e.g.,
Linux). With the trait off, the fake isn't built. The root
`Package.swift` and podspecs can't reach it.
- The fake mirrors Apple's public API and availability in the 27.2
SDKs, including `@Generable` macro expansions. It omits
PrivateCloudComputeLanguageModel, OCRTool, BarcodeReaderTool, the
adapter and feedback APIs, and deprecated APIs.
SystemLanguageModel is always unavailable. Below Swift 6.4 it
compiles to an empty module.
- Decoding rejects transcript images with `file:` URLs and schemas
whose references never resolve, instead of reading local files or
overflowing the stack.
- Without ImageIO, GLM passes PNG, JPEG, WebP, HEIC, and HEIF images
through to Gemini after checking their signatures, and rejects
images that would need re-encoding.
- Add CI jobs that run both packages' tests against the fake: one on
Linux in a digest-pinned `swift:6.4.2` container, and one on macOS
with Xcode 27.2. Skip `sdk.ai` for changes that only touch the fake.
Default to VALIDATED function calling mode in GeminiLanguageModel and
switch guided generation to responseJsonSchema.
Previously, tool-calling requests mapped the default or allowed mode to
AUTO, which does not strictly enforce parameter schemas. Because Swift
decodes tool arguments strictly, schema malformation results in failed
turns. Additionally, guided generation used responseFormat, which the
Gemini backend ignores when VALIDATED mode is active during tool-calling
sessions, dropping response schemas and causing structured decoding
failures in respond(to:generating:).
* Default unset and explicit .allowed toolCallingMode to VALIDATED mode
to strictly enforce schema adherence via constrained decoding.
* Throw LanguageModelError.unsupportedCapability on unrecognized future
tool calling modes instead of silently falling back to allowed.
* Omit functionCallingConfig entirely when requests declare no functions
to avoid contradictory constrained decoding states.
* Send responseJsonSchema with application/json MIME type for guided
generation, which constrained decoding honors alongside VALIDATED.
* Remove unused _responseJsonSchema property from GenerationConfig.
* End SSE response streams and cancel tasks upon receiving terminal
finish reasons or prompt feedback block reasons.
* Add integration test for combined tool calling and guided generation.
* Refresh cached App Check debug tokens proactively within TTL window.
Establishes the integration testing foundation and parameterized test
suites for `GeminiLanguageModel`, enabling fast local execution via
`swift test` and automated CI verification on iOS Simulator.
Key Changes:
- `IntegrationTestingBackend`: Defines canonical backend configurations
(`.developerAPI`, `.firebaseAILogicDeveloperAPI`, and
`.firebaseAILogicAgentPlatform`), dynamically resolving endpoints,
model resource paths, and auth headers from available credentials.
- `IntegrationTestEnvironment`: Centralizes credential discovery
(`GEMINI_API_KEY`, `GOOGLE_API_KEY`, and `FIREBASE_PLIST_PATH`) into
an immutable, thread-safe configuration struct with cached process
access to avoid redundant disk I/O.
- `AppCheckDebugClient`: Implements a lightweight client to exchange
debug tokens for App Check tokens without Keychain dependencies,
deduplicating token requests across test runs with an in-memory cache.
- Parameterized Tests: Adds `BasicContentGenerationIntegrationTests`
running against all available backends, tagged with `@Tag.integration`
and gated by condition traits to cleanly skip when credentials are
missing.
- CI Workflow: Adds `.github/workflows/sdk.geminilanguagemodel.yml` to
run integration tests against Firebase AI Logic on iOS Simulator
using decrypted repo secrets.