React-native-firebase: 馃敟When firebase is a pod and RNFirebase linked project build fails because RNFirebase cannot find React headers

Created on 12 Jun 2019  路  12Comments  路  Source: invertase/react-native-firebase

Issue

Similar to #738 but I've gone through that and have not managed to successfully build my project.

Main difference is that I am on RN 0.59.8 and RN Firebase 5.4.2. Also after following the instructions I am linking Firebase as a pod and RNFirebase through react-native link. BUT I have not set up React as a Pod (and I can't see anywhere where it says I should...).

So my podfile is minimal (as shown below)

(Same error persists regardless of use_frameworks commented or not)

My scheme build has parallel builds turned off.
It builds React first followed by my project.

Error message is usually
/Users/robin/Documents/myproject/node_modules/react-native-firebase/ios/RNFirebase/RNFirebaseUtil.h:5:9: 'React/RCTEventEmitter.h' file not found

But can sometimes be that RCTBridge not found (Not predictably though - it seems a bit random but is essentially that it cannot find React lib at all and fails at the first ref to React header file.

iOS

Click To Expand

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

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'MyProject' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Analytics'

end
#### `AppDelegate.m`:
# N/A


Android

Click To Expand

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

// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->


Environment

Click To Expand

**`react-native info` output:** ``` React Native Environment Info: System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz Memory: 697.58 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.1 - /usr/local/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 25.0.2, 27.0.3, 28.0.0, 28.0.0, 28.0.2, 28.0.3 System Images: android-23 | Google APIs ARM EABI v7a, android-23 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: ^16.8.3 => 16.8.3 react-native: ^0.59.8 => 0.59.8 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-create-library: 3.1.2 react-native-git-upgrade: 0.2.7 react-native: 0.56.0``` - **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `N`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Build Error

Most helpful comment

The podfile support is getting better I think - it might be the default recommendation for v5 even, shortly, especially with the use_frameworks patch from @moox - really glad to hear your build is working

All 12 comments

There is a header problem right now - but there is a workaround as well and I demonstrate current react-native + react-native-firebase (via link) + firebase ios sdk (via pod) working here - pay special attention to the copy line in the Podfile - https://github.com/mikehardy/rnfbdemo / https://github.com/mikehardy/rnfbdemo/blob/master/Podfile#L93

We're working on this over here #2163

If that doesn't fix it for you maybe collaborate over there? I haven't had time to fix it yet but the simple Podfile copy fix is effective enough that for v5 it lowered the priority for me

Also, apologies in general this happened and isn't formally documented - I was hoping to have it fixed shortly but it's taken longer than I want. A PR to the installation doc explaining this temporary fix, if it works for you would be most welcome...

We are having the same problem. @mikehardy pod file solution seems to fix this locally, but the build still fails in AppCenter with the same problem.

I take that back. In AppCenter it fails archive because it cannot find RCTDefines.h, and sometimes RCTEventEmitter.h. One of the things we found was that since we have to disable parallelizeBuildables on the RNFirebase project to get it to be right locally, we would probably have to do the same thing in AppCenter. Unfortunately, that setting ultimately lives in the project in node_modules. We certainly aren't going to commit our node_modules folder, so I tried using a number of methods including: using Xcodeproj to generate the schemes using ruby logic in the podfile in the post_install hook, using awk to find and replace that specific line in the .xcscheme file, and also just plain committing that specific scheme file with our source and then copying it into the appropriate location on the node_modules folder during the post_install hook. While this does seem to work locally, it still doesn't work in AppCenter. As it stands, with RNFirebase 5.5.3, we are unable to do CI builds. We will have to build locally, then push the *.ipa up manually for distribution.

Hmm, xcodeproj can control legacy build or not I think, that isn't sufficient? It is also possible to generate a duff and apply via patch package, won't be stable across versions but patch package managed that well with good warnings and errors

Similar issue for us, ever since we switched on use_frameworks! in our Podfile. The odd thing is that it works the second time it runs, must be derived data cache kicking in. The problem is you can't do an archive build because that always does a clean build. Is there a way that we can get RNFirebase working as pod with use_frameworks!?

In fact yes - it is not released yet but if you try the current tip of the v5.x.x branch, there was a patch recently that supposedly (as in I would love feedback) fixes use_frameworks - #2235

you would with npm do something like npm i 鈥榞it+https://github.com/invertase/react-native-firebase.git#v5.x.x I believe

I was thinking of including something else before I did 5.5.5 but I could kick out a release as soon as I heard confirmation this fixed your build if it worked for you.

Ok, let me try it out, i'll keep you posted ;-)

@mikehardy You my friend just saved me sooo much time. I just built it, works like a charm :-).

I would recommend this for anyone that has had issues with header files missing for this project, just unlink RNFirebase from your project and add this to your Podfile:

pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'

The podfile support is getting better I think - it might be the default recommendation for v5 even, shortly, especially with the use_frameworks patch from @moox - really glad to hear your build is working

released 5.5.4 with use_frameworks support today!

Was this page helpful?
0 / 5 - 0 ratings