Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com>
In a Simulator, AppCheckDebugProvider now uses the debug token that
`firebase appcheck:debugtokens:create` saves to
~/.config/configstore/firebase-appcheck.json on the host, so apps
launched from Xcode work without manually registering a token. The
token is looked up by each app's Google App ID through
SIMULATOR_HOST_HOME. The lookup is compiled out on devices, macOS and
Mac Catalyst. No public API changes.
Debug tokens are now resolved in this order:
1. AppCheckDebugToken or FIRAAppCheckDebugToken environment variable
2. Token from the CLI config store (Simulator only)
3. Token stored in UserDefaults
4. Newly generated UUID
The config store comes before the stored token so a newly provisioned
token takes effect without reinstalling the app.
Logging:
- I-FAA004003: debug token loaded from the config store.
- I-FAA004004: exchanging the config store token failed; suggests
re-running the CLI with --force and relaunching.
- I-FAA004002: exchanging an environment variable token failed; now
names the variables instead of showing an unrelated local token.
- I-FAA004005: the config store exists but can't be read or parsed.
A missing file, or a path where it can't exist (e.g., ~/.config is a
regular file), is silent. Exchange-failure warnings are skipped when
the server is unreachable, and no message includes the token.
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.
Move the `.reasoning` transcript check into
`sessionRespondSingleToolCall` and remove
`sessionRespondWithReasoningAndToolCalls`, which used `gemini-3.8-flash`
and often timed out. All Gemini 3 models are reasoning models and
return thought signatures with function calls, so the default
`gemini-3.5-flash-lite` model covers this and the suite makes one fewer
live call per backend.
The TestApp previously relied entirely on Xcode-generated Info.plist
keys (GENERATE_INFOPLIST_FILE with INFOPLIST_KEY_* build settings), so
there was no plist file for other build systems (e.g., Bazel) to use.
Add a minimal Resources/Info.plist and point INFOPLIST_FILE at it.
GENERATE_INFOPLIST_FILE remains enabled, so Xcode still merges the
existing INFOPLIST_KEY_* settings and the Xcode build is unchanged.
The plist is excluded from the FirebaseAITestApp-SPM target's bundle
resources via a membership exception.
Version strings are literals instead of $(MARKETING_VERSION) and
$(CURRENT_PROJECT_VERSION) because rules_apple only expands a small
set of variables; the values match the project's current settings.
Declare the vision capability in GeminiLanguageModel and translate
prompt image attachments into Gemini inlineData parts. Previously,
any attachment segment in a transcript threw an error.
Key changes and implementation details:
- Pass-through optimization: PNG, JPEG, WebP, HEIC, and HEIF file URLs
that are already upright are sent unchanged without re-encoding.
Multi-image files are only passed through if the primary image is
the first image.
- Re-encoding and normalization: All other image sources (CGImage,
CIImage, CVPixelBuffer, other formats, or rotated files) are rotated
to display orientation and encoded as JPEG (quality 0.9, matching
Transcript Codable conformance). Grayscale, extended-range, and HDR
images are converted to sRGB, compositing transparency over black.
- Platform portability: Re-encoding relies solely on CoreGraphics,
ImageIO, and UniformTypeIdentifiers to maintain watchOS support.
- Scoping and validation: Image attachments are supported only in
prompt entries. Non-file URLs are rejected by scheme to avoid
leaking tokens or dumping long payloads.
- Ordering: Prompt segments retain their order, with adjacent text runs
merged into single text parts.
- Tests: Add extensive unit and integration tests covering formats,
orientations, color spaces, and backend image understanding.