React-native-firebase: [SOLVED] 🔥React-Native Manual Setup - 'Firebase.h' file not found RNFirebaseUtil.h

Created on 21 Jan 2019  ·  14Comments  ·  Source: invertase/react-native-firebase


Issue

Can't get iOS to build using manual setup instructions. Each time I get... 'Firebase.h' file not found RNFirebaseUtil.h.

My steps:

1) yarn add react-native-firebase
2) react-native link react-native-firebase

3) download GoogleService-Info.plist from firebase setup, add to XCode project here
screen shot 2019-01-21 at 11 59 28 am

4) create a Firebase Folder in the root of my XCode project and drag each of the files/resources into the folder like so
screen shot 2019-01-21 at 12 01 02 pm

5) Added the import and configure to AppDelegate.m

screen shot 2019-01-21 at 12 03 30 pm

6) Added '$(SRCROOT)/Firebase' to Framework Search Paths and Header Search Paths
screen shot 2019-01-21 at 12 05 41 pm

7) Found -ObjC to "Other Linker Options" (didn't have to add as -ObjC was already added)
screen shot 2019-01-21 at 12 05 41 pm

Then when I try to build 'RNFirebaseUtil.h' throws the 'Firebase.h' not found error
screen shot 2019-01-21 at 12 22 34 pm


Project Files






iOS

ios/Podfile:

  • [x] I'm not using Pods
  • [ ] I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * 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 <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <Firebase.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  NSURL *jsCodeLocation;

  #ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  #else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"artsfolio"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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;
}

@end


Environment

  • 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

  • If known, the version of the platform are you experiencing the issue on:

    • ADD_SOMETHING_HERE e.g. iOS 10 or Android API 28

  • Operating System:

    • [x] MacOS, version: High Sierra 10.13.3

    • [ ] Windows, version: N/A

    • [ ] Other, please specify: N/A

  • Build Tools:

    • Xcode 9.2

  • React Native version:

    • 0.57.8

  • React Native Firebase library version:

    • 5.2.0

  • Firebase module(s) you're using that has the issue:

    • [x] N/A

    • [ ] Authentication

    • [ ] Analytics

    • [ ] Cloud Firestore

    • [ ] Cloud Messaging (FCM)

    • [ ] Crashlytics

    • [ ] Dynamic Links

    • [ ] Functions Callable

    • [ ] Invites

    • [ ] Instance ID

    • [ ] Notifications

    • [ ] Performance Monitoring

    • [ ] Realtime Database

    • [ ] Remote Config

    • [ ] Storage

  • Are you using TypeScript?

    • [x ] No

    • [ ] Yes, version: N/A

  • Are you using Expo, e.g. ExpoKit?

    • [x] No

    • [ ] Yes, I've _not_ ejected

    • [ ] Yes, but I have ejected to ExpoKit

    • [ ] Yes, but I have ejected to vanilla React Native

    • Expo version: N/A




Think react-native-firebase is great? Please consider supporting the project with any of the below:

Most helpful comment

Finally got this to build, oh what fun. It looks like the issue most likely has to do with XCode not updating if you add files in a certain way. In case anyone else is having similar issues, here's what finally worked for me. Special thanks @andreicalazans's installation procedure in #1016 with a few alterations. For whatever reason, XCode isn't keeping in-sync with my local files, so I had to add the SDK files differently.

1) _yarn add react-native-firebase_
2) _react-native link react-native-firebase_
3) _Add GoogleService-Info.plist to /ios/appName/_
4) _Download the Firebase sdk zip._

_Note: Here instead of following the readme inside the Firebase folder you downloaded follow the below steps._

5) Create a Firebase folder in your local "{projectName}/ios/" folder, not in XCode.

6) Copy all of the folders and their resources (if they exist for said module) into your newly created Firebase folder (attaching a screenshot of my final folder's content's at the end of this post)

7) Open your project in XCode. Right click your ".xcodeproj" and click "Add Files to {yourProjectName}..."
screen shot 2019-01-27 at 3 42 37 pm

8) Find the "Firebase" folder you just created and select it.
screen shot 2019-01-27 at 3 48 40 pm

9) _Before clicking "Add", to the left you'll see an "Options" button. Click it, and make sure "Create Groups" and "Add to targets" for your project are both selected.
screen shot 2019-01-27 at 3 46 21 pm

10) _In xcode and in your build settings for your project (You need to have your project selected under targets and not just under Project). Search for Header Search Paths and add this $(SRCROOT)/Firebase._ Set path to "recursive"

11) _Then Search for Framework Search Paths and add this $(SRCROOT)/Firebase._ Set path to "recursive"

12) _Search for Other Linker Settings and add the -ObjC_ (This didn't pertain to my situation as -ObjC was already under "Other Linker Settings"

13) _in ios/[YOUR APP NAME]/AppDelegate.m add #import at the top.

14) _still in AppDelegate.m add [FIRApp configure]; in the beginning of the method didFinishLaunchingWithOptions:(NSDictionary *)launchOptions.

After the above steps the app was building, but I had a few additional steps for iOS and Android

iOS
Invite was hard-crashing the app, so I needed to add URL Types. Clicking on my project => Info => URL Types. Click the (+) to add two new schemes. The only field you have to fill out is "URL Schemes". For the first one your "URL Schemes" will be your package.name (same as entered on Firebase or under General Tab), and the second is your "Reversed Client Id" which can be found in your GoogleService-Info.plist file.

Android
Following RNFirebase's setup instructions worked, except for versioning. In 'app/build.gradle' file I had to update a few dependencies versions.

In android/build.gradle:

I had to update classpath to the most recent version, 'com.google.gms:google-services:4.2.0' (was 4.0.1, you can find the most recent version here ).

Under allprojects, I updated maven's url to 'url "$rootDir/../node_modules/react-native/android"'

In app/build.gradle
Updated dependencies version to "implementation 'com.google.firebase:firebase-core:16.0.6'" (16.0.1 in the instructions, find the most recent version here)

//====================================================
// Screenshots referenced earlier
//====================================================

Firebase folder containing all modules...
screen shot 2019-01-27 at 3 51 55 pm
screen shot 2019-01-27 at 3 52 05 pm

All 14 comments

Hey, could you manually change the firebase import in 'RNFirebaseUtil.h' to: #import <Firebase/Firebase.h> and let me know if it builds? If so I'll clean these up for a v5.2.1 release


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@telkandrew also; out of curiosity/research - whats the reasoning behind not using Pods in your case, if you don't mind me asking?

Even though I cleared watchman, cache, and rebooted XCode multiple times earlier, trying it again the issue seems to have resolved itself, and am now on to a new error.

"FirebaseCore/FirebaseCore.h" file not found from "Firebase.h"
screen shot 2019-01-21 at 8 26 10 pm

On a side not I did try changing to in 'RNFirebaseUtil.h' and it broke the build. I believe seems to be working.

I'm not using Pods because I have to integrate Firebase into a very large, pre-existing project soon, so I wanted to try it fresh project first. When we originally built the other project, Pods was breaking/not playing nicely with a few of our NPMs. I can't remember all of them off-hand, but I do believe one of them was 'react-native-camera'.

Finally got this to build, oh what fun. It looks like the issue most likely has to do with XCode not updating if you add files in a certain way. In case anyone else is having similar issues, here's what finally worked for me. Special thanks @andreicalazans's installation procedure in #1016 with a few alterations. For whatever reason, XCode isn't keeping in-sync with my local files, so I had to add the SDK files differently.

1) _yarn add react-native-firebase_
2) _react-native link react-native-firebase_
3) _Add GoogleService-Info.plist to /ios/appName/_
4) _Download the Firebase sdk zip._

_Note: Here instead of following the readme inside the Firebase folder you downloaded follow the below steps._

5) Create a Firebase folder in your local "{projectName}/ios/" folder, not in XCode.

6) Copy all of the folders and their resources (if they exist for said module) into your newly created Firebase folder (attaching a screenshot of my final folder's content's at the end of this post)

7) Open your project in XCode. Right click your ".xcodeproj" and click "Add Files to {yourProjectName}..."
screen shot 2019-01-27 at 3 42 37 pm

8) Find the "Firebase" folder you just created and select it.
screen shot 2019-01-27 at 3 48 40 pm

9) _Before clicking "Add", to the left you'll see an "Options" button. Click it, and make sure "Create Groups" and "Add to targets" for your project are both selected.
screen shot 2019-01-27 at 3 46 21 pm

10) _In xcode and in your build settings for your project (You need to have your project selected under targets and not just under Project). Search for Header Search Paths and add this $(SRCROOT)/Firebase._ Set path to "recursive"

11) _Then Search for Framework Search Paths and add this $(SRCROOT)/Firebase._ Set path to "recursive"

12) _Search for Other Linker Settings and add the -ObjC_ (This didn't pertain to my situation as -ObjC was already under "Other Linker Settings"

13) _in ios/[YOUR APP NAME]/AppDelegate.m add #import at the top.

14) _still in AppDelegate.m add [FIRApp configure]; in the beginning of the method didFinishLaunchingWithOptions:(NSDictionary *)launchOptions.

After the above steps the app was building, but I had a few additional steps for iOS and Android

iOS
Invite was hard-crashing the app, so I needed to add URL Types. Clicking on my project => Info => URL Types. Click the (+) to add two new schemes. The only field you have to fill out is "URL Schemes". For the first one your "URL Schemes" will be your package.name (same as entered on Firebase or under General Tab), and the second is your "Reversed Client Id" which can be found in your GoogleService-Info.plist file.

Android
Following RNFirebase's setup instructions worked, except for versioning. In 'app/build.gradle' file I had to update a few dependencies versions.

In android/build.gradle:

I had to update classpath to the most recent version, 'com.google.gms:google-services:4.2.0' (was 4.0.1, you can find the most recent version here ).

Under allprojects, I updated maven's url to 'url "$rootDir/../node_modules/react-native/android"'

In app/build.gradle
Updated dependencies version to "implementation 'com.google.firebase:firebase-core:16.0.6'" (16.0.1 in the instructions, find the most recent version here)

//====================================================
// Screenshots referenced earlier
//====================================================

Firebase folder containing all modules...
screen shot 2019-01-27 at 3 51 55 pm
screen shot 2019-01-27 at 3 52 05 pm

https://github.com/invertase/react-native-firebase/issues/1847#issuecomment-457952828 with this, don't forget to copy the Firebase.h file from FirebaseSDk and paste it in ios/Firebase folder

@andrewtelkamp

There is one crucial step you've missed that I had to work through to get my build to pass.

@ step 4) DO NOT DOWNLOAD THE IOS SDK THAT FIREBASE RECOMMENDS. You must check the supported versions table to make you iOS SDK version match with the react-native version you are using + the react-native-firebase version you have installed: https://github.com/invertase/react-native-firebase/tree/v5.x.x#supported-versions---react-native--firebase

You can download the correct version from here: https://github.com/firebase/firebase-ios-sdk/releases/tag/5.20.2

Also, step 6 should possibly include advice to add the firebase.h file to the Firebase folder.

The sdk versions must match the react native firebase compatibility table yes, good point

Documentation PRs al ways welcome there is an edit link on each page and github allows easy Doc edits via the web...

Thank you @andrewtelkamp! Been stuck for days and your instructions are what finally got everything working.

Couple notes:

  • Step 4: as @bernhardt1 mentioned, I had to ensure I downloaded the correct version of the Firebase iOS SDK. I'm using "react-native": "0.57.8", "react-native-firebase": "5.2.3", and used the 5.17.0 release of the Firebase iOS SDK. I attempted to follow the instructions but later realized I downloaded the wrong package — I needed to click on the link under Assets that said "Firebase-5.17.0.zip", not "Source code (zip)"
    Screenshot 2019-07-02 12 43 34
  • Step 6: I initially attempted to copy all Firebase modules over to ios/Firebase, but this led to a successful build that hung on app startup. Only importing the packages I needed fixed this.

finally solved, I find that react native firebase package was install globally. it causes RNFirebaseUtil.h can't find the pod header file. by remove the global one and make sure it is installed locally, now it is working.

Wow @Salakar if you do a rnfb doctor type script that last comment is interesting. Conflict with local vs global install. I never would have thought of that

Another super important thing for those who get this error (I fought with this for an entire afternoon): you must use the folder ios/Firebase exactly, if you put the file in any other folder or name the folder differently (even different case), you will get the Firebase.h not found error because the RNFireBase.xcodeproj has the search path hard-coded to ios/Firebase.

@andrewtelkamp may I reconfirm, step no. 6 "Copy all of the folders and their resources (if they exist for said module) into your newly created Firebase folder", do you mean the whole Firebase SDK folder or the whole RNFirebase folder?

Was this page helpful?
0 / 5 - 0 ratings