React-native-firebase: [v6 + RN59] 'RCTVersion.h' file not found (with solution)

Created on 5 Oct 2019  ·  29Comments  ·  Source: invertase/react-native-firebase


Issue



Getting the following error when trying to setup project using native react-native-firebase

#import "RCTVersion.h"

Screenshot 2019-10-05 at 4 38 08 PM

Github Repo for the Project with Podfile.lock

or

Link for the Podfile.lock file

What have I tried?

  1. Deleting Pod file and Podfile.lock
  2. pod install
  3. pod update

Project Files






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.0'

target 'frontend' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for frontend
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
  target 'frontendTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'frontend-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for frontend-tvOS

  target 'frontend-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

#### `AppDelegate.m`:
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"
#import <Firebase.h>
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"frontend"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end


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`:

// 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:**

 OUTPUT GOES HERE
- **Platform that you're experiencing the issue on**: - [ x ] 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:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/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]

Most helpful comment

I resolve this issue. 😄
In my case, my cocoapods version is 1.8.4 and use the use_frameworks! key words

target 'HoverCamera2' do
  use_frameworks!
# use_modular_headers!
  libPath = '..'
  nodeModules = "#{libPath}/node_modules"
  rnPath = "#{nodeModules}/react-native"

  pod 'FBLazyVector', :path => "#{rnPath}/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "#{rnPath}/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "#{rnPath}/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "#{rnPath}/Libraries/TypeSafety"
  pod 'React', :path => "#{rnPath}/"

Resolve:
Add script postinstall.sh which use sed to modify the files:

'RNFBVersion.m' :

#import "RCTVersion.h"  ==>  #import <React/RCTVersion.h>

'RNFBUtilsModule.h' :

#import "RCTBridgeModule.h"  ==> #import <React/RCTBridgeModule.h>

Add postinstall.sh into package.json

 "scripts": {
    "postinstall": "npx jetify && ./scripts/postinstall.sh",
    "start": "tsc -w & react-native start --resetCache",
    "test": "jest",
    "lint": "eslint ."
  },

postinstall.sh implementation:

sysOS=`uname -s`
mySed () {
  if [ "$sysOS" = "Darwin" ];then
    sed -i '' "s/$1/$2/" $3
  elif [ "$sysOS" = "Linux" ];then
    sed -i "s/$1/$2/" $3
  fi
}

mySed 's.static_framework    = false' 's.static_framework    = true' "./node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec"
mySed 's.static_framework    = false' 's.static_framework    = true' "./node_modules/@react-native-firebase/app/RNFBApp.podspec"
mySed '#import "RCTVersion.h"' '#import <React\/RCTVersion.h>' "./node_modules/@react-native-firebase/app/ios/RNFBApp/RNFBVersion.m"
mySed '#import "RCTBridgeModule.h"' '#import <React\/RCTBridgeModule.h>' "./node_modules/@react-native-firebase/app/ios/RNFBApp/RNFBSharedUtils.h"

All 29 comments

This looks like a general issue with Pods not related to this library, as we just import it.

My suggestion would be to try the following steps to make sure you're up-to-date on everything locally:

cd ios/
rm -rf Podfile.lock
rm -rf Pods/
pod install --repo-update

That should do a fresh install (think node modules nuke) and re-download all Pods specified in the project.

This looks like a general issue with Pods not related to this library, as we just import it.

My suggestion would be to try the following steps to make sure you're up-to-date on everything locally:

cd ios/
rm -rf Podfile.lock
rm -rf Pods/
pod install --repo-update

That should do a fresh install (think node modules nuke) and re-download all Pods specified in the project.

@Ehesp tried the same.

Tried the same before posting (wrote the same in issue description as well)

What have I tried?
Deleting Pod file and Podfile.lock
pod install
pod update

Also, I am doing manual integration so adding this in pods

pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'

If it's a manual install, have you followed the steps here: https://facebook.github.io/react-native/docs/integration-with-existing-apps?

@irohitb have you been able to solve this? It seems that I have the same issue.
I already used the library on android and that's working.

@Ehesp, @TomVanBoghout Since the issue was closed I thought it isn't necessary to share an update (sorry).

Anyway, My pod file was basically empty, I deleted iOS folder and probably did react-native update which created a new/fresh ios folder having all the necessary pods.

Thanks for your help and assistance

I still having this issue, have you guys any solution?

I've tried with a fresh react-app with 0.59.10 version when that error appears.

Can someone help me? What version should I use with react-native 0.59.10?

Thanks.

@emilioheinz I would've been able to help you if you were using react-native 0.60> and react-native-firebase 0.59.10.

I suspect, there is a problem with pods, If you can share your pod file the maintainers and I can try to help you.

@irohitb A few minutes after my comment here I found out a work around. For me the error was because this pod pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' was installing a react version inside Pods folder and then it was a conflict with the current react folder in my main node_modules.

To solve that I've to add this in my pod file:

pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

I don't know if this will help everyone but it worked for me.

Hello @emilioheinz I had the same error as you RCTVersion.h' file not found
, for a fresh repo, without having any Pods installed, while setting up for iOS the librairie...
So I had your lines (Pods for React, because RNF was installing a react version indeed on his side... ), but I get this error :

error Failed to build iOS project. We ran "xcodebuild" command but it 
exited with error code 65.
To debug build logs further, consider building your app with Xcode.app,
by opening project.xcworkspace

Any ideas ? Why so difficult to just do the setup.... 🤯🤯🤯

@MayoudP

What RN FIrebase version you are using? and what is your react version? Also, Can you share your complete pod file?

@MayoudP

What RN FIrebase version you are using? and what is your react version? Also, Can you share your complete pod file?

Theses one :

"react": "16.8.3",
react-native-cli: 2.0.1
react-native: 0.59.1
"@react-native-firebase/app": "^6.0.1",
"@react-native-firebase/messaging": "^6.0.1",
project 'project.xcodeproj/'

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

target 'project' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' 
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  # Pods for project

  target 'projectUITEsts' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'projectTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

@MayoudP I guess react-native-firebase version 6 is compatible with RN >= 6.0 (not the official source quoting here but go through the docs thoroughly).

Did you do pod install? for RN Version below 6.0, you need to auto-linking AS WELL..

Probably ask it on stackoverflow or create a new issue using issue template

I do have done Pod install of course, no errors on this side. It's when I try to build react-native run-ios
I'll see if @emilioheinz can enventually help, because the error looks very similar, and else yeap I'll do it...

ohh, It's listed in the error itself that it is building the app with "xcodebuild" and you need to use xcworkspace.

In xcode, Open xcworkspace and build using it from xcode

Screenshot 2019-10-16 at 2 42 04 PM

@MayoudP
What RN FIrebase version you are using? and what is your react version? Also, Can you share your complete pod file?

Theses one :

"react": "16.8.3",
react-native-cli: 2.0.1
react-native: 0.59.1
"@react-native-firebase/app": "^6.0.1",
"@react-native-firebase/messaging": "^6.0.1",
project 'project.xcodeproj/'

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

target 'project' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' 
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  # Pods for project

  target 'projectUITEsts' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'projectTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

i tried this one.. but also encountered an error on the folly..

include not found error

i am using react-native 59.9
did all the manual stuff based on the documentation seen here.

Luckily i was able to run it on android using jetifier but no luck on iOS.

Hi guys i manage to build it successfully after applying the solution to this issue.

I think the full solution for those errors are the following steps:

1 - Put these lines on the top of your pod file:

pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

2 - Put these code on the end of your pod file:

 pod 'Folly', :podspec => "./node_modules/react-native/third-party-podspecs/Folly.podspec"

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

3 - Run the following commands inside ios folder:

rm -rf Pods Podfile.lock
pod install --repo-update

4 - Run the project with xcode by opening the .xcworkspace file.

So the final result of the Podfile file for a fresh React Native install with just Firebase and Firebase Analytics as dependencies is:

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

target 'firebasepoc' do
  # Comment the next line if you don't want to use dynamic frameworks
  # use_frameworks!

  # Pods for firebasepoc
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
  pod 'RNFBAnalytics', :path => '../node_modules/@react-native-firebase/analytics'
  pod 'Folly', :podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec"

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

end

I guess these steps would fix your problem @MayoudP. Thanks for @trglairnarra for remember that issue, it helped me too.

I just relabeled this one to capture what it turned out to be about - I think! hopefully I got it right - for anyone in the future trying v6 + RN59

Got to much conflicts on the end...
Finally downgraded to
"react-native-firebase": "^5.5.6", pod 'Firebase/Core', '~> 6.3.0' pod 'Firebase/Messaging', '~> 6.3.0'

Fixed the problem

I've downgraded too, mainly because of conflicts between fbsdk, firebase and androidx support.

I guess these steps would fix your problem @MayoudP. Thanks for @trglairnarra for remember that issue, it helped me too.

thank you so much this saved me. I couldn't see the Folly error code until i ran it directly in xcode. When running in react native it only showed error code 65.

I resolve this issue. 😄
In my case, my cocoapods version is 1.8.4 and use the use_frameworks! key words

target 'HoverCamera2' do
  use_frameworks!
# use_modular_headers!
  libPath = '..'
  nodeModules = "#{libPath}/node_modules"
  rnPath = "#{nodeModules}/react-native"

  pod 'FBLazyVector', :path => "#{rnPath}/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "#{rnPath}/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "#{rnPath}/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "#{rnPath}/Libraries/TypeSafety"
  pod 'React', :path => "#{rnPath}/"

Resolve:
Add script postinstall.sh which use sed to modify the files:

'RNFBVersion.m' :

#import "RCTVersion.h"  ==>  #import <React/RCTVersion.h>

'RNFBUtilsModule.h' :

#import "RCTBridgeModule.h"  ==> #import <React/RCTBridgeModule.h>

Add postinstall.sh into package.json

 "scripts": {
    "postinstall": "npx jetify && ./scripts/postinstall.sh",
    "start": "tsc -w & react-native start --resetCache",
    "test": "jest",
    "lint": "eslint ."
  },

postinstall.sh implementation:

sysOS=`uname -s`
mySed () {
  if [ "$sysOS" = "Darwin" ];then
    sed -i '' "s/$1/$2/" $3
  elif [ "$sysOS" = "Linux" ];then
    sed -i "s/$1/$2/" $3
  fi
}

mySed 's.static_framework    = false' 's.static_framework    = true' "./node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec"
mySed 's.static_framework    = false' 's.static_framework    = true' "./node_modules/@react-native-firebase/app/RNFBApp.podspec"
mySed '#import "RCTVersion.h"' '#import <React\/RCTVersion.h>' "./node_modules/@react-native-firebase/app/ios/RNFBApp/RNFBVersion.m"
mySed '#import "RCTBridgeModule.h"' '#import <React\/RCTBridgeModule.h>' "./node_modules/@react-native-firebase/app/ios/RNFBApp/RNFBSharedUtils.h"

I am having the same error 'RCTVersion.h' file not found, but I do not use cocoa pods, and I am using RN 0.59.10 with _@react-native-firebase/app_ and _@react-native-firebase/messaging_. I am implementing notifications into my project.

Firebase project folder is imported to my project and it is located inside the _ios_ folder. Also, Header Search Paths and Library Search Paths both contains _recursive $(PROJECT_DIR)/Firebase)_ config.

Am I missing any imports?

I don't believe any testing at all is done on the RN0.59 + RNFBv6 combo. The assumption is you'll move to RN0.60+. The upgrade is worth it...

I have upgraded to v0.60.0. And i am still facing this issue.

I'm facing the same issue.
I've asked the question on stackoverflow. Here's the link to it:
https://stackoverflow.com/questions/62643509/rctversion-h-file-not-found

Same issue:

RN 0.59.9 + v8

I would not attempt to use RN59 any more, I believe there were a batch of issues discovered and fixed with regard to Xcode 11/12 support (which implies, required fixes for ios13/14 support) as well as Android 10/11

Was this page helpful?
0 / 5 - 0 ratings