Repository navigation
Conversation
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.
There was a problem hiding this comment.
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.
| final withoutPin = withRequirement.replaceFirst( | ||
| RegExp('\nlet firebaseSdkVersion: Version = "[^"]+"\n'), | ||
| '\n', | ||
| ); | ||
| return withoutPin.replaceAll(RegExp('\n{3,}'), '\n\n'); |
There was a problem hiding this comment.
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.
| 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
left a comment
There was a problem hiding this comment.
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.
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.
Description
Swift Package Manager builds fail when an app resolves FlutterFire plugins that were published with different exact
firebase-ios-sdkpins. pub never sees that pin, so it can select those plugins together, and Xcode then cannot resolve a single SDK version.Each plugin
Package.swiftnow accepts the SDK it was generated against, up to the next major (from: "13.2.0").firebase_corekeeps an exact pin (13.2.0). Every other plugin depends onfirebase_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. Afromrequirement onfirebase_coreas well would let the resolver pick a newer SDK than the plugins were built against, which is what brokecloud_firestorein #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.yamland changelogs is not required.///).melos run analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your 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 thespm_sdk_pinCI job): core exact13.2.0with a pluginfrom: "13.2.0"resolved13.2.0and did not float to a newer13.3.0tag. An older pluginfrom: "13.1.1"also resolved13.2.0. Core exact13.1.1with a pluginfrom: "13.2.0"failed resolution. Core onfrom: "13.0.0"floated to13.3.0. The published pin is13.2.0, which is also the newest 13.x tag, so this used a local git fixture.dart run scripts/generate_versions_spm.dartleft thePackage.swiftfiles unchanged.melos run check-license-header./.github/workflows/scripts/validate-formatting.shdart analyze --fatal-infosonscripts/generate_versions_spm.dartandscripts/generate_versions_spm_test.dartdart pub global run flutter_plugin_tools analyze --base-branch=origin/main --custom-analysis=.github/workflows/config/custom_analysis.yamlcompleted with no issues.