invertase / invertase/react-native-firebase

[🐛] SPM + dynamic frameworks (Expo SDK 57): GoogleUtilities classes duplicated in RNFBAnalytics / RNFBMessaging

Open
#9,322 1 comment 0 reactions 0 assignees View on GitHub
platform: expo platform: ios plugin: analytics plugin: messaging type: bug
Dominant language
TypeScript
Stars
12.3k
Forks
2.3k
Avg merge
3d 3h
Merged PRs (30d)
79

Description

## Issue

With SPM mode and `ios.useFrameworks: "dynamic"` (Expo SDK 57), the app builds and launches, but the Objective‑C runtime reports duplicate classes at startup: several GoogleUtilities classes are implemented both in the SPM package‑product framework and statically inside `RNFBAnalytics.framework` (and, for Reachability, also inside `RNFBMessaging.framework`).

`FIRApp` is not duplicated (so the FirebaseCore part of #9140 looks fixed), but GoogleUtilities pulled in via FirebaseAnalytics/FirebaseMessaging still seems to be linked statically into the RNFB pod frameworks. We observed no crash in a short smoke run, but the runtime warns about "spurious casting failures and mysterious crashes".

**Console (excerpt)**

```
Class GULNetwork is implemented in both …/Frameworks/GULAppDelegateSwizzler_-24B6F7B546001A5C_PackageProduct.framework/GULAppDelegateSwizzler_-24B6F7B546001A5C_PackageProduct and …/RNFBAnalytics.framework/RNFBAnalytics. This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.
```

Affected classes in `RNFBAnalytics`:
`GULMutableDictionary`, `GULNetwork`, `GULNetworkURLSession`, `GULNetworkURLSessionWeakHolder`, `GULReachabilityChecker`, `GULSessionDeallocTracker`, `GoogleUtilities_GoogleUtilities_Network_SWIFTPM_MODULE_BUNDLER_FINDER`, `GoogleUtilities_GoogleUtilities_Reachability_SWIFTPM_MODULE_BUNDLER_FINDER`

In `RNFBMessaging`:
`GULReachabilityChecker`, `GoogleUtilities_GoogleUtilities_Reachability_SWIFTPM_MODULE_BUNDLER_FINDER`

**Steps to reproduce**

1. Expo SDK 57 app with the RNFB modules listed below; `@react-native-firebase/app` config plugin without `disableSPM`; `expo-build-properties` with `ios.useFrameworks: "dynamic"` (no RNFB entries in `forceStaticLinking`).
2. `npx expo prebuild --clean`, `pod install`, build Release for the iOS Simulator, launch and watch the console.

**Expected:** each GoogleUtilities product linked once (from the dynamic SPM package product), no duplicate classes.

**Note:** The same app in CocoaPods mode (`disableSPM`, `useFrameworks: "static"`) shows no duplicates. Related: #9140.

---

## Project Files

### Javascript

Click To Expand

#### `package.json`:

```json
{
"dependencies": {
"@react-native-firebase/analytics": "^26.4.0",
"@react-native-firebase/app": "^26.4.0",
"@react-native-firebase/app-check": "^26.4.0",
"@react-native-firebase/auth": "^26.4.0",
"@react-native-firebase/crashlytics": "^26.4.0",
"@react-native-firebase/firestore": "^26.4.0",
"@react-native-firebase/functions": "^26.4.0",
"@react-native-firebase/messaging": "^26.4.0",
"expo": "~57.0.18",
"expo-build-properties": "~57.0.15",
"react-native": "0.86.3"
}
}
```

#### `firebase.json` for react-native-firebase v6:

```json
# N/A
```

### iOS

Click To Expand

#### `ios/Podfile`:

- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:

```ruby
# Generated by Expo prebuild (CNG). Relevant config (app.config.ts):
# plugins: [
# "@react-native-firebase/app", // no disableSPM → SPM mode
# ["expo-build-properties", { ios: { useFrameworks: "dynamic" } }],
# ]
# Precompiled Expo modules enabled (Expo SDK 57 default).
```

#### `AppDelegate.m`:

```objc
// N/A (Expo-generated AppDelegate.swift)
```

---

### Android

Click To Expand

#### Have you converted to AndroidX?

- [ ] my application is an AndroidX application?
- [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility?
- [ ] I am using the NPM package `jetifier` for react-native compatibility?

#### `android/build.gradle`:

```groovy
// N/A (iOS-only issue)
```

#### `android/app/build.gradle`:

```groovy
// N/A
```

#### `android/settings.gradle`:

```groovy
// N/A
```

#### `MainApplication.java`:

```java
// N/A
```

#### `AndroidManifest.xml`:

```xml

```

---

## Environment

Click To Expand

**`react-native info` output:**

```
react-native 0.86.3 (New Architecture), Expo SDK 57
Xcode 26.6, CocoaPods 1.16.2, macOS 26.4.1
Firebase iOS SDK via SPM, resolved to 12.19.1
Build: Release, iOS Simulator (arm64)
```

- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [ ] Android
- [x] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- `26.4.0`
- **`Firebase` module(s) you're using that has the issue:**
- `Analytics`, `Messaging` (GoogleUtilities linkage)
- **Are you using `TypeScript`?**
- `Y` & `6.0.3`

Contributor guide

Open the contributing guide

Research direction

Start with package.json and the generated ios/Podfile configuration described from app.config.ts, then reproduce using npx expo prebuild --clean, pod install, and a Release iOS Simulator build. Inspect the RNFBAnalytics and RNFBMessaging frameworks and console output; done means each GoogleUtilities product is linked once and duplicate-class warnings are absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, ios, react-native, typescript
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.