Skip to content

[firebase_analytics]: FIREBASE_ANALYTICS_WITHOUT_ADID is broken under SPM #18335

@Lz-

Description

@Lz-

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Analytics

Which platforms are affected?

iOS

Description

Enabling the IDFA-free Analytics build under Swift Package Manager FIREBASE_ANALYTICS_WITHOUT_ADID=true fails to resolve, because firebase_analytics's Package.swift links a product that no longer exists in the Firebase iOS SDK:

let analyticsProduct = useWithoutAdId ? "FirebaseAnalyticsWithoutAdIdSupport" : "FirebaseAnalytics"

FirebaseAnalyticsWithoutAdIdSupport was removed from firebase-ios-sdk in 12.0.0 and replaced by FirebaseAnalyticsCore.
The SPM switch was added in #18061, by which point the pinned SDK was already 12.x - so this path has never resolved in any released version.
With the flag unset, the build links the full FirebaseAnalytics(which links AdSupport/IDFA)
with it set, the build fails.
No version combination avoids this: every firebase_analytics carrying the env-var branch pins a 12.x SDK, while the product only exists in ≤ 11.13.0.

The CocoaPods path is already correct - firebase_analytics.podspec maps $FirebaseAnalyticsWithoutAdIdSupport to the FirebaseAnalytics/Core subspec.
Only the SPM manifest was left pointing at the old product name.

#17958 added this mechanism and was closed as completed, but the resolution was never verified.
Related: #12081, #13205

Reproducing the issue

  1. A project on SPM (not CocoaPods) depending on firebase_analytics
  2. Request the IDFA-free variant: FIREBASE_ANALYTICS_WITHOUT_ADID=true flutter build ios
  3. Package resolution fails (log below).

With the flag unset it builds, but links the full, IDFA-collecting FirebaseAnalytics

Firebase Core version

4.9.0

Flutter Version

3.41.9

Relevant Log Output

xcodebuild: error: Could not resolve package dependencies:
  product 'FirebaseAnalyticsWithoutAdIdSupport' required by package 'firebase_analytics' target 'firebase_analytics' not found in package 'firebase-ios-sdk'.

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.11.5
Flutter SDK 3.41.9
...
dependencies:
- firebase_analytics 12.4.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_core 4.9.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 5.2.2 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_messaging 16.2.2 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_performance 0.11.4+1 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter]
- firebase_remote_config 6.5.1 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter]
...
dev dependencies:
- firebase_core_platform_interface 7.0.1 [collection flutter flutter_test meta plugin_platform_interface]
...
transitive dependencies:
- firebase_analytics_platform_interface 6.0.1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.6.1+7 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_core_web 3.7.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics_platform_interface 3.8.22 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 4.7.11 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 4.1.7 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- firebase_performance_platform_interface 0.2.0+1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_performance_web 0.1.8+7 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins]
- firebase_remote_config_platform_interface 3.0.1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_web 1.10.8 [_flutterfire_internals firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins]
...

Additional context and comments

Suggested fix
One line, matching what the podspec already does (FirebaseAnalytics/Core):

let analyticsProduct = useWithoutAdId ? "FirebaseAnalyticsCore" : "FirebaseAnalytics"

This restores the IDFA-free build under SPM and is sufficient on its own.


Proposal (optional, separate from the fix)
The selection mechanism is also worth reconsidering.
An environment variable is a weak source of truth for whether an app links AdSupport/IDFA:
It's invisible in the repo, can't be code-reviewed, and has to be replicated identically across every shell, CI job, IDE run config, and direct Xcode build - miss it anywhere and IDFA silently comes back.
Two directions that put the choice under version control:

  • (A) A declarative flag in pubspec.yaml read at manifest-eval time the same way firebase_core already reads firebase_sdk_version.rb via loadFirebaseSDKVersion(). This keeps everything in one package with an unchanged public API; it does add manifest-side plumbing to parse the flag.
firebase_analytics:
  ad_id_support: false
  • (B) A separate, opt-in dependency that links FirebaseAnalyticsCore mirroring the way firebase-ios-sdk already exposes FirebaseAnalytics and FirebaseAnalyticsCore as distinct products.
    A firebase_analytics_core package, selected as its own dependency, would let apps opt out of IDFA through the dependency list rather than an env var, while the default firebase_analytics behavior stays unchanged.

Docs
There's currently no guidance for opting out of IDFA under SPM - the iOS data-collection page only covers the native FirebaseAnalyticsCore dependency, which doesn't map to how Flutter selects native dependencies. Whichever mechanism lands should be documented on the Analytics SPM / data-collection pages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions