Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(ai): Handle Xcode 27 LanguageModelSession.Error collision#16257

Merged
andrewheard merged 2 commits into
mainfirebase/firebase-ios-sdk:mainfrom
ah/ai-error-collision-xc27firebase/firebase-ios-sdk:ah/ai-error-collision-xc27Copy head branch name to clipboard
Jun 10, 2026
Merged

fix(ai): Handle Xcode 27 LanguageModelSession.Error collision#16257
andrewheard merged 2 commits into
mainfirebase/firebase-ios-sdk:mainfrom
ah/ai-error-collision-xc27firebase/firebase-ios-sdk:ah/ai-error-collision-xc27Copy head branch name to clipboard

Conversation

@andrewheard

@andrewheard andrewheard commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Explicitly qualified the any Error as any Swift.Error in the FoundationModels.LanguageModelSession extension for _ModelSession conformance to fix the namespace collision with the built-in Swift Error protocol and the FoundationModels.LanguageModelSession.Error type introduced in Xcode 27. This resolves #16252.

Error Details
This is due to an ambiguity between `Error` and and [`FoundationModels.LanguageModelSession.Error`](https://developer.apple.com/documentation/foundationmodels/languagemodelsession/error) since the extension is declared on `FoundationModels.LanguageModelSession`.

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:95:61: error: 'any' has no effect on concrete type 'LanguageModelSession.Error'
 93 |                                 includeSchemaInPrompt: Bool,
 94 |                                 options: any GenerationOptionsRepresentable)
 95 |       -> sending AsyncThrowingStream<_ModelSessionResponse, any Error> {
    |                                                             `- error: 'any' has no effect on concrete type 'LanguageModelSession.Error'
 96 |       return AsyncThrowingStream { continuation in
 97 |         let foundationModelsPrompt: Prompt

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:95:65: error: 'Error' is only available in iOS 27.0 or newer
 90 |     ///     `false`, structured output (JSON) is requested but the schema is not strictly enforced.
 91 |     ///   - options: A set of options, represented as a ``GenerationOptionsRepresentable`` type.
 92 |     public func _streamResponse(to prompt: [any Part], schema: FirebaseAI.GenerationSchema?,
    |                 `- note: add '@available' attribute to enclosing instance method
 93 |                                 includeSchemaInPrompt: Bool,
 94 |                                 options: any GenerationOptionsRepresentable)
 95 |       -> sending AsyncThrowingStream<_ModelSessionResponse, any Error> {
    |                                                                 `- error: 'Error' is only available in iOS 27.0 or newer
 96 |       return AsyncThrowingStream { continuation in
 97 |         let foundationModelsPrompt: Prompt

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:22:3: error: type 'LanguageModelSession' does not conform to protocol '_ModelSession'
 20 |   @available(tvOS, unavailable)
 21 |   @available(watchOS, unavailable)
 22 |   extension FoundationModels.LanguageModelSession: _ModelSession {
    |   |- error: type 'LanguageModelSession' does not conform to protocol '_ModelSession'
    |   `- note: add stubs for conformance
 23 |     /// Returns `true` if the session has history (i.e., it has already had one or more chat turns).
 24 |     ///
    :
 90 |     ///     `false`, structured output (JSON) is requested but the schema is not strictly enforced.
 91 |     ///   - options: A set of options, represented as a ``GenerationOptionsRepresentable`` type.
 92 |     public func _streamResponse(to prompt: [any Part], schema: FirebaseAI.GenerationSchema?,
    |                 `- note: candidate has non-matching type '([any Part], FirebaseAI.GenerationSchema?, Bool, any GenerationOptionsRepresentable) -> sending AsyncThrowingStream<_ModelSessionResponse, LanguageModelSession.Error>'
 93 |                                 includeSchemaInPrompt: Bool,
 94 |                                 options: any GenerationOptionsRepresentable)

FirebaseAI/Sources/Protocols/Public/ModelSession.swift:50:10: note: protocol requires function '_streamResponse(to:schema:includeSchemaInPrompt:options:)' with type '([any Part], FirebaseAI.GenerationSchema?, Bool, any GenerationOptionsRepresentable) -> sending AsyncThrowingStream<_ModelSessionResponse, any Error>'
48 |     ///   - options: A set of options, represented as a ``GenerationOptionsRepresentable`` type.
49 |     @available(macOS 12.0, watchOS 8.0, *)
50 |     func _streamResponse(to prompt: [any Part],
   |          `- note: protocol requires function '_streamResponse(to:schema:includeSchemaInPrompt:options:)' with type '([any Part], FirebaseAI.GenerationSchema?, Bool, any GenerationOptionsRepresentable) -> sending AsyncThrowingStream<_ModelSessionResponse, any Error>'
51 |                          schema: FirebaseAI.GenerationSchema?,
52 |                          includeSchemaInPrompt: Bool,

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:96:14: error: initializer 'init(_:bufferingPolicy:_:)' requires the types 'LanguageModelSession.Error' and 'any Error' be equivalent
 94 |                                 options: any GenerationOptionsRepresentable)
 95 |       -> sending AsyncThrowingStream<_ModelSessionResponse, any Error> {
 96 |       return AsyncThrowingStream { continuation in
    |              `- error: initializer 'init(_:bufferingPolicy:_:)' requires the types 'LanguageModelSession.Error' and 'any Error' be equivalent
 97 |         let foundationModelsPrompt: Prompt
 98 |         do {

_Concurrency.AsyncThrowingStream.init:2:8: note: where 'Failure' = 'LanguageModelSession.Error'
1 | generic struct AsyncThrowingStream {
2 | public init(_ elementType: Element.Type = Element.self, bufferingPolicy limit: AsyncThrowingStream<Element, Failure>.Continuation.BufferingPolicy = .unbounded, _ build: (AsyncThrowingStream<Element, Failure>.Continuation) -> Void) where Failure == any Error}
  |        `- note: where 'Failure' = 'LanguageModelSession.Error'
3 | 

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:101:41: error: cannot convert value of type 'any Error' to expected argument type 'LanguageModelSession.Error'
 99 |           foundationModelsPrompt = try prompt.toFoundationModelsPrompt()
100 |         } catch {
101 |           continuation.finish(throwing: error)
    |                                         `- error: cannot convert value of type 'any Error' to expected argument type 'LanguageModelSession.Error'
102 |           return
103 |         }

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:95:61: error: 'any' has no effect on concrete type 'LanguageModelSession.Error'
 93 |                                 includeSchemaInPrompt: Bool,
 94 |                                 options: any GenerationOptionsRepresentable)
 95 |       -> sending AsyncThrowingStream<_ModelSessionResponse, any Error> {
    |                                                             `- error: 'any' has no effect on concrete type 'LanguageModelSession.Error'
 96 |       return AsyncThrowingStream { continuation in
 97 |         let foundationModelsPrompt: Prompt

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:95:65: error: 'Error' is only available in iOS 27.0 or newer
 90 |     ///     `false`, structured output (JSON) is requested but the schema is not strictly enforced.
 91 |     ///   - options: A set of options, represented as a ``GenerationOptionsRepresentable`` type.
 92 |     public func _streamResponse(to prompt: [any Part], schema: FirebaseAI.GenerationSchema?,
    |                 `- note: add '@available' attribute to enclosing instance method
 93 |                                 includeSchemaInPrompt: Bool,
 94 |                                 options: any GenerationOptionsRepresentable)
 95 |       -> sending AsyncThrowingStream<_ModelSessionResponse, any Error> {
    |                                                                 `- error: 'Error' is only available in iOS 27.0 or newer
 96 |       return AsyncThrowingStream { continuation in
 97 |         let foundationModelsPrompt: Prompt

FirebaseAI/Sources/Extensions/Internal/LanguageModelSession+ModelSession.swift:22:3: error: type 'LanguageModelSession' does not conform to protocol '_ModelSession'
 20 |   @available(tvOS, unavailable)
 21 |   @available(watchOS, unavailable)
 22 |   extension FoundationModels.LanguageModelSession: _ModelSession {
    |   |- error: type 'LanguageModelSession' does not conform to protocol '_ModelSession'
    |   `- note: add stubs for conformance
 23 |     /// Returns `true` if the session has history (i.e., it has already had one or more chat turns).
 24 |     ///
    :
 90 |     ///     `false`, structured output (JSON) is requested but the schema is not strictly enforced.
 91 |     ///   - options: A set of options, represented as a ``GenerationOptionsRepresentable`` type.
 92 |     public func _streamResponse(to prompt: [any Part], schema: FirebaseAI.GenerationSchema?,
    |                 `- note: candidate has non-matching type '([any Part], FirebaseAI.GenerationSchema?, Bool, any GenerationOptionsRepresentable) -> sending AsyncThrowingStream<_ModelSessionResponse, LanguageModelSession.Error>'
 93 |                                 includeSchemaInPrompt: Bool,
 94 |                                 options: any GenerationOptionsRepresentable)

FirebaseAI/Sources/Protocols/Public/ModelSession.swift:50:10: note: protocol requires function '_streamResponse(to:schema:includeSchemaInPrompt:options:)' with type '([any Part], FirebaseAI.GenerationSchema?, Bool, any GenerationOptionsRepresentable) -> sending AsyncThrowingStream<_ModelSessionResponse, any Error>'
48 |     ///   - options: A set of options, represented as a ``GenerationOptionsRepresentable`` type.
49 |     @available(macOS 12.0, watchOS 8.0, *)
50 |     func _streamResponse(to prompt: [any Part],
   |          `- note: protocol requires function '_streamResponse(to:schema:includeSchemaInPrompt:options:)' with type '([any Part], FirebaseAI.GenerationSchema?, Bool, any GenerationOptionsRepresentable) -> sending AsyncThrowingStream<_ModelSessionResponse, any Error>'
51 |                          schema: FirebaseAI.GenerationSchema?,
52 |                          includeSchemaInPrompt: Bool,

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request addresses a compilation issue caused by a namespace collision in Xcode 27. By disambiguating the Error type, the code ensures compatibility with the updated SDK while maintaining existing functionality for model session streaming.

Highlights

  • Namespace Collision Resolution: Explicitly qualified the Error type as Swift.Error in the _streamResponse method signature to resolve a naming conflict with the new FoundationModels.LanguageModelSession.Error type introduced in Xcode 27.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Activity
  • Pull request created by andrewheard.
  • Automated Gemini Code Assist bot provided usage instructions.
  • Author requested a summary of the pull request using the /gemini summary command.

@andrewheard
andrewheard marked this pull request as ready for review June 10, 2026 14:46
@andrewheard
andrewheard merged commit 57e4e51 into main Jun 10, 2026
77 checks passed
@andrewheard
andrewheard deleted the ah/ai-error-collision-xc27 branch June 10, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AI] LanguageModelSession fails to conform to _ModelSession when building with Xcode 27 beta / iOS 27 SDK

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.