Skip to content

fix(apple): resolve one Firebase iOS SDK version from firebase_core - #18987

Open
SelaseKay wants to merge 3 commits into
mainfrom
fix/spm-ios-sdk-range
Open

SelaseKay wants to merge 3 commits into
mainfrom
fix/spm-ios-sdk-range

Conversation

@SelaseKay

@SelaseKay SelaseKay commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Swift Package Manager builds fail when an app resolves FlutterFire plugins that were published with different exact firebase-ios-sdk pins. pub never sees that pin, so it can select those plugins together, and Xcode then cannot resolve a single SDK version.

Each plugin Package.swift now accepts the SDK it was generated against, up to the next major (from: "13.2.0"). firebase_core keeps an exact pin (13.2.0). Every other plugin depends on firebase_core, so Swift Package Manager selects that pin when core is current. A plugin generated against 13.2.0 does not accept an older core pin: Swift Package Manager reports a version conflict instead of compiling the plugin against an SDK that is missing APIs it uses. A from requirement on firebase_core as well would let the resolver pick a newer SDK than the plugins were built against, which is what broke cloud_firestore in #18319.

Plugins already published with an exact pin keep that pin. An app that still resolves one of those versions can hit the same conflict until it upgrades to a release that contains this change.

Related Issues

Fixes #18984

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Test plan

  • dart run scripts/generate_versions_spm_test.dart (melos run test:spm-generator, also the analyze job)
  • scripts/verify_spm_sdk_pin.sh (melos run test:spm-sdk-pin, also the spm_sdk_pin CI job): core exact 13.2.0 with a plugin from: "13.2.0" resolved 13.2.0 and did not float to a newer 13.3.0 tag. An older plugin from: "13.1.1" also resolved 13.2.0. Core exact 13.1.1 with a plugin from: "13.2.0" failed resolution. Core on from: "13.0.0" floated to 13.3.0. The published pin is 13.2.0, which is also the newest 13.x tag, so this used a local git fixture.
  • A second dart run scripts/generate_versions_spm.dart left the Package.swift files unchanged.
  • melos run check-license-header
  • ./.github/workflows/scripts/validate-formatting.sh
  • dart analyze --fatal-infos on scripts/generate_versions_spm.dart and scripts/generate_versions_spm_test.dart
  • dart pub global run flutter_plugin_tools analyze --base-branch=origin/main --custom-analysis=.github/workflows/config/custom_analysis.yaml completed with no issues.

Plugins published against different exact pins cannot be resolved together, and pub never sees that Swift package constraint. Keep the exact pin on firebase_core and let the other plugins accept any version in that major.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions the Firebase Flutter plugins' Swift Package Manager (SPM) configurations from pinning exact SDK versions to using a major version floor (e.g., from 13.0.0), while keeping the exact pin only on firebase_core. This change allows SwiftPM to resolve dependencies more flexibly. It also adds a Dart script (generate_versions_spm.dart) with corresponding tests and a verification shell script to automate and validate these updates. The feedback suggests enhancing the Dart script's regular expressions to robustly handle Windows-style line endings when stripping out the old version pins.

Comment thread scripts/generate_versions_spm.dart Outdated
Comment on lines +85 to +89
final withoutPin = withRequirement.replaceFirst(
RegExp('\nlet firebaseSdkVersion: Version = "[^"]+"\n'),
'\n',
);
return withoutPin.replaceAll(RegExp('\n{3,}'), '\n\n');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current regular expressions for removing the SDK version pin assume Unix-style line endings (\n). If the script is run on Windows or if the files are checked out with Windows-style line endings (\r\n), the match might leave stray \r characters or fail to collapse multiple blank lines correctly.

Using \r?\n and (\r?\n){3,} makes the line-ending handling robust across different platforms.

Suggested change
final withoutPin = withRequirement.replaceFirst(
RegExp('\nlet firebaseSdkVersion: Version = "[^"]+"\n'),
'\n',
);
return withoutPin.replaceAll(RegExp('\n{3,}'), '\n\n');
final withoutPin = withRequirement.replaceFirst(
RegExp(r'\r?\nlet firebaseSdkVersion: Version = "[^"]+"\r?\n'),
'\n',
);
return withoutPin.replaceAll(RegExp(r'(\r?\n){3,}'), '\n\n');

@demolaf demolaf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Keeping only firebase_core on an exact pin means Swift Package Manager still selects that version, and the plugins' firebase_core pubspec constraint keeps core at or above the version each plugin shipped with. The comments below are all non-blocking.

Comment thread scripts/generate_versions_spm.dart Resolved
Comment thread scripts/generate_versions_spm_test.dart Resolved
Comment thread scripts/generate_versions_spm.dart Resolved
A major floor let an older firebase_core pin compile a plugin against an SDK it was not built for. Keep the floor at the generated version, collapse blank lines only where that pin was removed, and run the resolver checks in CI.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[multiple]: Version conflict on firebase-ios-sdk when using multiple flutterfire plugins

2 participants