Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test_expo_ios_link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- '**'
paths:
- 'test-expo/**'
- 'packages/app/package.json'
- '.github/workflows/test_expo_ios_link.yml'
- '.github/workflows/scripts/test-expo-ios-link.sh'
- 'packages/app/firebase_spm.rb'
Expand All @@ -21,6 +22,7 @@ on:
- release-v*
paths:
- 'test-expo/**'
- 'packages/app/package.json'
- '.github/workflows/test_expo_ios_link.yml'
- '.github/workflows/scripts/test-expo-ios-link.sh'
- 'packages/app/firebase_spm.rb'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_rn_bare_ios_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- '.github/workflows/test_rn_bare_ios_build.yml'
- '.github/workflows/scripts/test-rn-bare-ios-build.sh'
- 'packages/app/RNFBApp.podspec'
- 'packages/app/package.json'
- 'packages/app/ios/**'
- 'packages/app/firebase_spm.rb'
- 'packages/app/firebase_json.rb'
Expand All @@ -26,6 +27,7 @@ on:
- '.github/workflows/test_rn_bare_ios_build.yml'
- '.github/workflows/scripts/test-rn-bare-ios-build.sh'
- 'packages/app/RNFBApp.podspec'
- 'packages/app/package.json'
- 'packages/app/ios/**'
- 'packages/app/firebase_spm.rb'
- 'packages/app/firebase_json.rb'
Expand Down
4 changes: 2 additions & 2 deletions docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ Open your projects `/ios/Podfile` and add any of the globals shown below to the

```ruby
# Override Firebase SDK Version if desired
$FirebaseSDKVersion = '12.18.0'
$FirebaseSDKVersion = '12.19.3'
```

Once changed, reinstall your projects pods via pod install and rebuild your project with `npx react-native run-ios`.

Alternatively, if you cannot edit the Podfile easily (as when using Expo), you may add the environment variable `FIREBASE_SDK_VERSION=12.18.0` (or whatever version you need) to the command line that installs pods. For example `FIREBASE_SDK_VERSION=12.18.0 yarn expo prebuild --clean`
Alternatively, if you cannot edit the Podfile easily (as when using Expo), you may add the environment variable `FIREBASE_SDK_VERSION=12.19.3` (or whatever version you need) to the command line that installs pods. For example `FIREBASE_SDK_VERSION=12.19.3 yarn expo prebuild --clean`

### Android Performance

Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/RNFBAnalytics.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Pod::Spec.new do |s|
Pod::UI.puts "#{s.name}: Using FirebaseAnalytics/IdentitySupport with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps."
Pod::UI.puts "#{s.name}: You may set variable `$RNFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids."
end
s.dependency 'FirebaseAnalytics/IdentitySupport', firebase_sdk_version
s.dependency 'FirebaseAnalytics/IdentitySupport', rnfirebase_cocoapods_requirement(firebase_sdk_version)
end
end

Expand Down
4 changes: 4 additions & 0 deletions packages/app/__tests__/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Skips cleanly off macOS or when `clang`/`ar`/`file` are missing. Discovered and
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------- | -------------------------------------------------------------------------------------------------------- |
| `test_cocoapods_single_pod` | When SPM is not available, a single Firebase pod (like Auth) is added as a CocoaPods dependency with the correct name and version. | CocoaPods | `spm_dependency` undefined → `spec.dependency('Firebase/Auth', '12.10.0')` called once |
| `test_cocoapods_multiple_pods` | When SPM is not available and a module needs multiple pods (like Crashlytics + CoreExtension), all of them are added as CocoaPods dependencies. | CocoaPods | `spm_dependency` undefined → `spec.dependency` called twice (Crashlytics + CoreExtension) |
| `test_cocoapods_default_version_uses_compatible_release_requirement` | When SPM is not available, the default `sdkVersions.ios.firebase` is declared as `~> major.minor.0` on every pod. CocoaPods patch releases only republish changed pods, so exact pins cannot resolve. | CocoaPods | Default version → every `spec.dependency` version is `~> 12.19.0`-style |
| `test_cocoapods_user_pinned_version_stays_exact` | A version that is not the shipped default (a user `$FirebaseSDKVersion` pin) stays an exact CocoaPods requirement. | CocoaPods | Non-default version → `spec.dependency` version unchanged |
| `test_cocoapods_requirement_helper_matches_default_version` | `rnfirebase_cocoapods_requirement` loosens only the default version; any other value passes through (also used for the Analytics `IdentitySupport` subspec). | CocoaPods | Default → `~> major.minor.0`; other → unchanged |
| `test_cocoapods_requirement_helper_keeps_non_release_default_exact` | A default that is not a plain `x.y.z` release (for example a prerelease) is left exact instead of being rewritten. | CocoaPods | Prerelease default → returned unchanged |
| `test_spm_single_product` | When SPM is available, the Firebase dependency is declared via Swift Package Manager instead of CocoaPods, using the correct URL, version, and product name. | SPM | `spm_dependency` defined → called with `['FirebaseAuth']`, `spec.dependency` not called |
| `test_spm_multiple_products_ignores_cocoapods_extras` | When SPM is available, only the SPM product names are used. Extra CocoaPods-only dependencies (like FirebaseCoreExtension) are correctly ignored because SPM resolves them automatically as transitive dependencies. | SPM | `spm_dependency` defined → called with `['FirebaseCrashlytics']` only, ignores CocoaPods extras |
| `test_reads_spm_url_from_package_json` | The Firebase SPM repository URL is read from `package.json` instead of being hardcoded, ensuring a single source of truth for the SDK location. | Config | `$firebase_spm_url` reads from `package.json` → `https://github.com/firebase/firebase-ios-sdk.git` |
Expand Down
44 changes: 44 additions & 0 deletions packages/app/__tests__/firebase_spm_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,50 @@ def test_cocoapods_multiple_pods
end
end

# The shipped default is declared as a compatible-release requirement on
# CocoaPods: a patch release only republishes the pods that changed, so an
# exact pin for every pod cannot resolve.
def test_cocoapods_default_version_uses_compatible_release_requirement
load_firebase_spm
default_version = RNFirebaseSPM.default_version
major, minor = default_version.split('.')

spec = MockSpec.new
firebase_dependency(spec, default_version,
['FirebaseCrashlytics'],
['Firebase/Crashlytics', 'FirebaseCoreExtension'])

assert_equal 2, spec.dependencies.length
spec.dependencies.each do |dep|
assert_equal "~> #{major}.#{minor}.0", dep[:version]
end
end

def test_cocoapods_user_pinned_version_stays_exact
load_firebase_spm

spec = MockSpec.new
firebase_dependency(spec, '12.10.0', ['FirebaseAuth'], 'Firebase/Auth')

assert_equal '12.10.0', spec.dependencies[0][:version]
end

def test_cocoapods_requirement_helper_matches_default_version
load_firebase_spm
default_version = RNFirebaseSPM.default_version
major, minor = default_version.split('.')

assert_equal "~> #{major}.#{minor}.0", rnfirebase_cocoapods_requirement(default_version)
assert_equal '12.10.0', rnfirebase_cocoapods_requirement('12.10.0')
end

def test_cocoapods_requirement_helper_keeps_non_release_default_exact
load_firebase_spm
RNFirebaseSPM.instance_variable_set(:@default_version, '12.19.0-rc.1')

assert_equal '12.19.0-rc.1', rnfirebase_cocoapods_requirement('12.19.0-rc.1')
end

# ── SPM path (spm_dependency IS defined) ──

def test_spm_single_product
Expand Down
40 changes: 39 additions & 1 deletion packages/app/firebase_spm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ def url
end
end

# Default Firebase iOS SDK version (`sdkVersions.ios.firebase`) from the
# app's own package.json, cached like `url`. Used by
# `rnfirebase_cocoapods_requirement` to tell the shipped default apart
# from a version the user pinned themselves.
def default_version
@default_version ||= begin
app_package_path = File.join(__dir__, 'package.json')
app_package = JSON.parse(File.read(app_package_path))
app_package['sdkVersions']['ios']['firebase']
end
end

# Records that `firebase_dependency` (below) took the SPM path for at
# least one podspec in this install, and which Firebase SDK `version` it
# resolved with. Called once, from `firebase_dependency` itself, the
Expand Down Expand Up @@ -133,6 +145,7 @@ def reset!
@active = nil
@version = nil
@url = nil
@default_version = nil
end
end
end
Expand Down Expand Up @@ -1200,6 +1213,30 @@ def rnfirebase_apply_spm_build_settings(installer)

rnfirebase_hook_cocoapods_post_install!

# CocoaPods requirement for a Firebase iOS SDK pod dependency.
#
# SPM resolves from the firebase-ios-sdk git repo, where every release tags all
# products, so an exact version always exists. CocoaPods publishes per pod, and
# a patch release only republishes the pods that changed (12.19.3 exists for
# `Firebase`, `FirebaseCore` and `FirebaseFirestore` only). An exact
# `s.dependency 'FirebaseAnalytics/Core', '12.19.3'` therefore cannot resolve.
#
# When `version` is the shipped default (`sdkVersions.ios.firebase`), return a
# compatible-release requirement for its minor line (`~> 12.19.0`) so each pod
# resolves to its newest patch. Any other value is a version the user pinned via
# `$FirebaseSDKVersion` / `FIREBASE_SDK_VERSION` and stays an exact pin.
#
# @param version [String] Firebase SDK version (e.g., '12.19.3')
# @return [String] CocoaPods requirement (e.g., '~> 12.19.0') or `version` unchanged
def rnfirebase_cocoapods_requirement(version)
return version unless version == RNFirebaseSPM.default_version

match = /\A(\d+)\.(\d+)\.\d+\z/.match(version)
return version unless match

"~> #{match[1]}.#{match[2]}.0"
end

# @param spec [Pod::Specification] The podspec object (the `s` in podspec DSL)
# @param version [String] Firebase SDK version (e.g., '12.10.0')
# @param spm_products [Array<String>] SPM product names (e.g., ['FirebaseAuth'])
Expand Down Expand Up @@ -1228,8 +1265,9 @@ def firebase_dependency(spec, version, spm_products, pods)
end
end
pods = [pods] unless pods.is_a?(Array)
requirement = rnfirebase_cocoapods_requirement(version)
pods.each do |pod|
spec.dependency pod, version
spec.dependency pod, requirement
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
},
"sdkVersions": {
"ios": {
"firebase": "12.18.0",
"firebase": "12.19.3",
"firebaseSpmUrl": "https://github.com/firebase/firebase-ios-sdk.git",
"iosTarget": "15.0",
"macosTarget": "10.15",
Expand Down
2 changes: 1 addition & 1 deletion test-rn-bare/ios/testrnbare.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 12.18.0;
minimumVersion = 12.19.3;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Loading