firebase / firebase/firebase-ios-sdk

Firebase/React Native iOS Build Issue: Abseil Undefined Symbols, React Native0.76.5, Firebase and Xcode26.2

Open
#15,642 3 comments 0 reactions 2 assignees Claimed by @cherylEnkidu View on GitHub
api: firestore
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description

Building a React Native iOS app with Firebase Firestore results in **50+ undefined symbol errors** for `absl::lts_20240722::*` functions. The symbols exist in the abseil library (verified with `nm`), but are not being resolved by the linker despite using `-force_load`.

**Critical Finding:** Symbols ARE present in the archive, but `-force_load` is not loading all archive members. Some abseil symbols ARE resolved (e.g., `Mutex::Mutex()`), but many others are not (e.g., `CHexEscape`, `FormatTime`, `SimpleAtod`, etc.).

## Environment History

### React Native Versions Tested
- **Started with:** React Native 0.74.5 (original issue)
- **Upgraded to:** React Native 0.76.5 (issue persists)
- **Rationale for upgrade:** Attempted to resolve compatibility issues, but did not fix the abseil linking problem

### Xcode Versions Tested
- **Xcode 26.2** (Build 17C52) - Issue present
- **Xcode 16.4** - Issue persists, additionally had `glog` build problems
- **Current:** Xcode 26.2

### Current Environment
- **React Native:** 0.76.5
- **Firebase iOS SDK:** 12.6.0
- **abseil:** 1.20240722.0
- **CocoaPods:** 1.16.2 (also tried 1.15.2 - same results)
- **xcodeproj gem:** 1.27.0
- **Platform:** iOS Simulator (arm64)
- **Linkage Mode:** Static libraries (not frameworks)

## Error Messages

```
Undefined symbols for architecture arm64:
"absl::lts_20240722::CHexEscape(std::__1::basic_string_view>)"
"absl::lts_20240722::FormatTime(std::__1::basic_string_view>, absl::lts_20240722::Time, absl::lts_20240722::TimeZone)"
"absl::lts_20240722::SimpleAtod(std::__1::basic_string_view>, double*)"
"absl::lts_20240722::SimpleAtof(std::__1::basic_string_view>, float*)"
"absl::lts_20240722::Base64Escape(...)"
... (50+ more similar errors)
```

## Verification: Symbols Exist in Archive ✅

**Confirmed with `nm` command:**
```bash
nm libabseil.a | grep CHexEscape
# Output: 0000000000000684 T __ZN4absl12lts_20240722CHexEscapeENS0_11string_viewE

nm libabseil.a | grep FormatTime
# Output: 0000000000000000 T __ZN4absl12lts_2024072210FormatTimeENS0_11string_viewENS0_4TimeENS0_8TimeZoneE
```

**Archive Details:**
- Archive exists at: `${PODS_CONFIGURATION_BUILD_DIR}/abseil/libabseil.a`
- Architecture: Universal binary (arm64 + x86_64) ✅
- Symbols present: Verified with `nm` ✅
- Some symbols DO resolve: `Mutex::Mutex()`, `Notification::WaitForNotification()` ✅
- Many symbols DO NOT resolve: `CHexEscape`, `FormatTime`, `SimpleAtod`, etc. ❌

**Linker Command Observation:**
- `-Wl,-force_load,${PODS_CONFIGURATION_BUILD_DIR}/abseil/libabseil.a` is present ✅
- Flag is positioned BEFORE `$(inherited)` ✅
- Archive path resolves correctly ✅
- **BUT:** Symbols still not resolved ❌

## Comprehensive List of Attempted Fixes

### 1. Firebase Recommended Workaround ✅ Applied
- **Action:** Set `CLANG_CXX_LANGUAGE_STANDARD = 'gnu++14'` for abseil target
- **Location:** Applied at the very end of Podfile `post_install` hook
- **Result:** ❌ Did not resolve the issue
- **Verification:** Confirmed workaround is applied (shown in `pod install` output)

### 2. CocoaPods Version Changes ✅ Tested
- **Versions tried:** CocoaPods 1.16.2 (latest) and 1.15.2 (older)
- **Result:** ❌ Both versions produce identical errors
- **xcodeproj gem:** 1.27.0 (required for CocoaPods 1.16+)

### 3. Xcode Version Changes ✅ Tested
- **Xcode 26.2:** Issue present
- **Xcode 16.4:** Same errors, plus `glog` build issues
- **Result:** ❌ Xcode version is not the root cause

### 4. React Native Version Upgrade ✅ Tested
- **Started:** React Native 0.74.5
- **Upgraded to:** React Native 0.76.5 (hoping to fix compatibility issues)
- **Result:** ❌ Issue persists on both versions

### 5. Linker Flag Approaches ✅ Multiple Attempts

#### A. Added `-force_load` to intermediate targets
- **Action:** Added `-Wl,-force_load` for abseil to gRPC-Core, FirebaseFirestoreInternal, gRPC-C++ targets
- **Result:** ❌ Symbols still undefined

#### B. Added `-force_load` to main app target
- **Action:** Added `-Wl,-force_load,${PODS_CONFIGURATION_BUILD_DIR}/abseil/libabseil.a` to ResponderMapNew target's OTHER_LDFLAGS
- **Position:** BEFORE `$(inherited)` to ensure early processing
- **Result:** ❌ Symbols still undefined

#### C. Tried `-all_load` flag
- **Action:** Attempted `-Wl,-all_load` instead of `-force_load`
- **Result:** ❌ Same errors, also causes issues with other libraries

#### D. Verified flag position in linker command
- **Action:** Confirmed `-force_load` appears before other libraries in actual linker command
- **Result:** ✅ Flag is correctly positioned, but still not working

### 6. Abseil Build Configuration ✅ Applied

All of the following settings are applied to the abseil target in Podfile `post_install`:

```ruby
config.build_settings['MACH_O_TYPE'] = 'staticlib'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'YES'
config.build_settings['SKIP_INSTALL'] = 'NO'
config.build_settings['ARCHS'] = 'arm64 x86_64'
config.build_settings['DEAD_CODE_STRIPPING'] = 'NO'
config.build_settings['SYMBOLS_HIDDEN_BY_DEFAULT'] = 'NO'
config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'gnu++14' # Firebase workaround
```

- **Result:** ❌ Issue persists with all these settings

### 7. Target Dependencies ✅ Applied
- **Action:** Added abseil as explicit target dependency for ResponderMapNew
- **Result:** ❌ Does not resolve the linking issue

### 8. Clean Builds ✅ Performed Multiple Times
- **Actions:**
- Cleaned DerivedData multiple times
- Removed Pods directory and reinstalled
- Clean Build Folder in Xcode
- Rebuilt from scratch
- **Result:** ❌ Issue persists after every clean build

### 9. Module Map Fixes ✅ Applied
- **Action:** Fixed gRPC-Core.modulemap path issues (common Firebase/React Native issue)
- **Location:** Created modulemap and added pre-compile script
- **Result:** ✅ Module map issues resolved, but abseil linking issue persists

### 10. React Native Upgrade Related Fixes ✅ Applied
- **Action:** Applied fixes for React Native 0.76.5:
- Global `use_modular_headers!` for Firebase Swift pods
- gRPC-Core.modulemap creation and pre-compile script
- Fixed react-native-maps EventEmitterCallbackWrapper access (separate issue)
- **Result:** ✅ These fixes applied successfully, but abseil linking issue persists

## Current Podfile Configuration

### Key post_install Hook Sections:

1. **Abseil Build Settings:**
- Forces static library build
- Disables dead code stripping
- Disables symbol hiding
- Sets C++ standard to `gnu++14`
- Builds universal binary

2. **Force Load Flag:**
```ruby
abseil_force_load_flag = '-Wl,-force_load,${PODS_CONFIGURATION_BUILD_DIR}/abseil/libabseil.a'
# Prepend BEFORE $(inherited) in OTHER_LDFLAGS
```

3. **Target Dependencies:**
- Explicitly adds abseil as dependency for ResponderMapNew target

## Critical Observations

1. **Partial Linking Success:**
- Some abseil symbols ARE resolved (e.g., `Mutex::Mutex()` found in `libabseil.a[arm64][82](mutex.o)`)
- Many abseil symbols are NOT resolved (e.g., `CHexEscape`, `FormatTime`)
- This suggests the archive IS being processed, but not all members are loaded

2. **Symbol Verification:**
- Verified with `nm` that missing symbols exist in the archive
- Archive is a valid universal binary with both architectures
- Archive path is correct and accessible

3. **Linker Behavior:**
- `-force_load` flag is present and correctly positioned
- Linker processes the archive (some symbols work)
- But `-force_load` is not forcing ALL archive members to load

4. **Consistency Across Versions:**
- Issue persists across React Native 0.74.5 and 0.76.5
- Issue persists across Xcode 26.2 and 16.4
- Standard linking fixes have no effect

## Hypothesis

The issue appears to be that `-force_load` is not functioning as expected for the abseil static library. Possible causes:

1. **Linker Bug:** There may be a bug in the linker (ld) that prevents `-force_load` from loading all archive members for this specific library
2. **Archive Structure:** The abseil archive might have a structure that prevents `-force_load` from working correctly
3. **Symbol Visibility:** Despite setting `SYMBOLS_HIDDEN_BY_DEFAULT = NO`, symbols might still have hidden visibility
4. **Build Toolchain Issue:** Combination of React Native, Firebase, abseil, and Xcode might expose a toolchain bug

## Additional Context

- **Android Build:** Works correctly (not affected by this iOS-specific issue)
- **Other Libraries:** No linking issues with other Firebase or React Native libraries
- **Project Complexity:** Standard React Native app with Firebase Firestore, Auth, Functions, Messaging

## Request for Help

This issue has persisted through:
- Multiple React Native versions (0.74.5 → 0.76.5)
- Multiple Xcode versions (26.2, 16.4)
- Extensive configuration changes
- All standard troubleshooting approaches

Given that:
1. Symbols exist in the archive (verified)
2. `-force_load` is correctly configured (verified)
3. Some symbols ARE resolved (proving the archive is processed)
4. Many symbols are NOT resolved (despite being in the archive)

We believe this may be:
- A deeper linker/toolchain issue
- A compatibility problem between React Native, Firebase, abseil, and recent Xcode versions
- A bug that requires upstream fixes

**Questions for Firebase/React Native Firebase team:**
1. Is this a known issue with React Native 0.74.5+ / 0.76.5 and Firebase?
2. Are there any workarounds beyond the standard `gnu++14` setting?
3. Is there a different linking approach we should try?
4. Should we consider downgrading Firebase iOS SDK versions?
5. Are there any pending fixes for abseil linking in upcoming releases?

## Files Modified

- `ios/Podfile` - Extensive `post_install` hooks for abseil configuration
- `ios/Pods/Target Support Files/**/*.xcconfig` - Modified to fix module map paths
- `node_modules/react-native-maps/ios/generated/RNMapsSpecs/*` - Fixed for RN 0.76.5 compatibility

## Build Command Output

The linker command includes:
```
-Wl,-force_load,/path/to/Build/Products/Debug-iphonesimulator/abseil/libabseil.a
```

Positioned before all other library flags, but symbols still not resolved.

---

**Date:** December 23, 2024
**Status:** Issue unresolved after extensive troubleshooting
**Next Steps:** Awaiting guidance from Firebase/React Native Firebase support

### Reproducing the issue

## Reproduction Steps

1. Create React Native 0.76.5 project
2. Install Firebase: `npm install @react-native-firebase/app @react-native-firebase/firestore`
3. Run `cd ios && pod install`
4. Build in Xcode
5. Observe undefined symbol errors for abseil functions

### Firebase SDK Version

12.6.0

### Xcode Version

26.2

### Installation Method

CocoaPods

### Firebase Product(s)

All

### Targeted Platforms

iOS, macOS

### Relevant Log Output

```shell

```

### If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

```json

Replace this line with the contents of your Package.resolved.

```

### If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

```yml

Replace this line with the contents of your Podfile.lock!

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.