Skip to content

fix(auth,ios): allow firebase_auth to compile under APPLICATION_EXTENSION_API_ONLY#18236

Open
MohamedAbdallah-14 wants to merge 1 commit intofirebase:mainfrom
MohamedAbdallah-14:fix/firebase_auth-app-extension-api
Open

fix(auth,ios): allow firebase_auth to compile under APPLICATION_EXTENSION_API_ONLY#18236
MohamedAbdallah-14 wants to merge 1 commit intofirebase:mainfrom
MohamedAbdallah-14:fix/firebase_auth-app-extension-api

Conversation

@MohamedAbdallah-14
Copy link
Copy Markdown

Fixes #18232.

What's wrong

When firebase_auth is built into an iOS target with APPLICATION_EXTENSION_API_ONLY=YES (Share Extension, Action Extension, etc.), Xcode rejects four call sites in FLTFirebaseAuthPlugin.m:

'addApplicationDelegate:' is unavailable: not available on iOS (App Extension)
  FLTFirebaseAuthPlugin.m:155

'sharedApplication' is unavailable: not available on iOS (App Extension)
  FLTFirebaseAuthPlugin.m:903
  FLTFirebaseAuthPlugin.m:913
  FLTFirebaseAuthPlugin.m:925

The current workaround — setting APPLICATION_EXTENSION_API_ONLY = NO on the firebase_auth pod via a Podfile post-install hook — lets the build pass, but the resulting extension binary contains references to APIs that App Store review can flag.

Fix

Wrap the four sites in #if !TARGET_OS_EXTENSION:

  1. [registrar addApplicationDelegate:instance] in +registerWithRegistrar: is gated; in extensions there is no application delegate to register against, so the openURL / scene-delegate paths below it are unreachable anyway.
  2. The presentationAnchorForAuthorizationController: method already branched on TARGET_OS_OSX; this PR splits the iOS branch into !TARGET_OS_EXTENSION (existing UIScene/keyWindow logic) and a fallback that returns nil. Sign-in flows that need a presentation anchor cannot run from an extension context — the host app is the only place that can present them — so the method is not expected to be invoked from an extension build.

iOS and macOS host-app behaviour is unchanged.

Test plan

  • Build a host iOS app with firebase_auth on Xcode 17 — confirm no regression in OAuth / Sign-in-with-Apple presentation flows.
  • Build a Share Extension target that registers firebase_auth via FLTFirebaseAuthPlugin.register(with:) with APPLICATION_EXTENSION_API_ONLY=YES — confirm clean compile, no "not available on iOS (App Extension)" diagnostics.
  • Build the macOS host app — confirm presentationAnchorForAuthorizationController: still returns the macOS key window.
  • Verify the build succeeds for both Swift Package Manager and CocoaPods consumers.

I have not yet run all of these locally; opening as a draft so a maintainer or CI can validate the full matrix before this is marked ready.

Notes

  • The macOS .m file at packages/firebase_auth/firebase_auth/macos/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m is a symlink to the iOS source, so this single edit covers both platforms.
  • I did not update CHANGELOG.md since flutterfire generates changelog entries from conventional commit subjects at release time via melos.

@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

Customization

To customize 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 counter productive. 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.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 28, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@MohamedAbdallah-14 MohamedAbdallah-14 force-pushed the fix/firebase_auth-app-extension-api branch from 12cca69 to 07b82ea Compare April 28, 2026 19:05
@MohamedAbdallah-14
Copy link
Copy Markdown
Author

@googlebot I signed it!

@MohamedAbdallah-14 MohamedAbdallah-14 marked this pull request as ready for review April 29, 2026 02:20
@Lyokone
Copy link
Copy Markdown
Contributor

Lyokone commented May 6, 2026

Hi @MohamedAbdallah-14, can you rebase your PR on the latest main, so we can see through CI errors a bit more clearly? Thanks :)

@Lyokone Lyokone added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label May 6, 2026
…SION_API_ONLY

Fixes firebase#18232.

Wraps the four call sites in FLTFirebaseAuthPlugin.m that reference
APIs unavailable to app extensions:

- -[FlutterPluginRegistrar addApplicationDelegate:] in
  +registerWithRegistrar: (line 156)
- +[UIApplication sharedApplication].connectedScenes (lines 904, 914)
- +[[UIApplication sharedApplication] keyWindow] fallback (line 926)

The first is gated with #if !TARGET_OS_EXTENSION. The
presentationAnchorForAuthorizationController: method already had
TARGET_OS_OSX branching; this adds an extension branch that returns
nil. Sign-in flows that require a presentation anchor cannot run from
an extension context, so this method is not expected to be invoked
there.

Pre-extension behaviour is unchanged on iOS and macOS host targets.
@MohamedAbdallah-14 MohamedAbdallah-14 force-pushed the fix/firebase_auth-app-extension-api branch from 07b82ea to e602426 Compare May 6, 2026 18:08
@MohamedAbdallah-14
Copy link
Copy Markdown
Author

@Lyokone rebased on main (e602426), CI re-running. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked: customer-response Waiting for customer response, e.g. more information was requested.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[firebase_auth]: iOS plugin can't compile under APPLICATION_EXTENSION_API_ONLY=YES - blocks use in app

2 participants