invertase / react-native-firebase

šŸ”„ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.54k stars 2.19k forks source link

'FirebaseAnalytics/FirebaseAnalytics.h' file not found #1016

Closed andr3a88 closed 6 years ago

andr3a88 commented 6 years ago

Issue: Cannot build the project

After updating RNFirebaseĀ“andFirebase` iOS SDK cannot build the project:

Environment

iOS 11.3 macOS High Sierra Xcode 9.3 ReactNative 0.55.1 RNFirebase Version: 4.0.5

Firebase version: Firebase 4.13.0 FirebaseAnalytics FirebaseCore 4.0.20

jeanregisser commented 6 years ago

Do you use CocoaPods for Firebase/* and RNFirebase?

AndreiCalazans commented 6 years ago

Environment OS: macOS High Sierra 10.13.4 Node: 9.4.0 Yarn: 1.3.2 npm: 5.6.0 Watchman: 4.7.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed) react: 16.3.1 => 16.3.1 react-native: 0.55.1 => 0.55.1

I'm having the same issue. I was able to get passed the Firebase.h by adding Firebase.h into project_root/ios/Firebase/Firebase.h .

but I'm still getting the second error.

In Firebase.h

'FirebaseAnalytics/FirebaseAnalytics.h' file not found

I installed it manually, I'm not using CocoaPods.

Steps to reproduce:

  1. yarn add react-native-firebase
  2. react-native link react-native-firebase
  3. Add GoogleService-Info.plist to /ios/appName/
  4. Drag Firebase framework files to project root inside xcode as the README of Firebase specified
  5. Add the -ObjC flag to "Other Linker Settings":
chrisbianca commented 6 years ago

Please take a look at option 2 of https://rnfirebase.io/docs/v4.0.x/installation/ios#1.3.-Install-Firebase-Library

This explains that if you're not using cocoapods, you need to add the frameworks to an ios/Firebase folder for them to be picked up by RNFirebase.

AndreiCalazans commented 6 years ago

Thanks @chrisbianca I totally missed out on that.

For anyone else trying to get this to work manually. The following steps worked for me.

  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.

  1. Create a Firebase folder in root/ios/Firebase.

  2. Copy the folder Analytics and all other module folders you pretend to use, the module.modulemap file and Firebase.h inside to root/ios/Firebase.

  3. 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

  4. Then Search for Framework Search Paths and add this $(SRCROOT)/Firebase.

  5. Search for Other Linker Settings and add the -ObjC

  6. in ios/[YOUR APP NAME]/AppDelegate.m add #import <Firebase.h> at the top.

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

Once you have done the above steps rebuild your app and it should be fine.

willbattel commented 6 years ago

@chrisbianca any idea why we're getting the same error even though we have always used Cocoapods? We started getting this error after the iOS SDK had their hiccup with 4.12.0. We now get this no matter what version we use.

screen shot 2018-04-28 at 8 12 44 pm
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios/RNFirebase.podspec'
  pod 'Firebase/Core'
  pod 'Firebase/AdMob'
  pod 'Firebase/Analytics'
  pod 'Firebase/Auth'
  pod 'Firebase/Database'
  pod 'Firebase/Performance'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'
  pod 'Fabric', '~> 1.7.2'
  pod 'Crashlytics', '~> 3.9.3'

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 6.10.3
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.3 => 0.55.3
  react-native-firebase: 4.0.6 => 4.0.6
willbattel commented 6 years ago

Actually, I can't get it to work even if I do include+link the SDK in the ios directory. I followed the instructions shared by AndreiCalazans but no bueno.

I don't have any idea what changed between it working and not working. I'm using version control and can't find any changes to the Podfile, Podfile.lock, etc...

loukandr commented 6 years ago

In my case, what was missing from @AndreiCalazans ' instructions to fix my problem was one more step at the end, just before building the project, that is:

12: In Xcode right click the project name folder, select Add files to ā€œappNameā€ and select the ios/Firebase folder.

malangaveuday commented 6 years ago

@AndreiCalazans, I am confused in this two files the module.modulemap file and Firebase.h, I am not able to see this in react-native-firebase sdk.

mycob commented 5 years ago

@AndreiCalazans Thanks for your help!

kolohelios commented 5 years ago

I wasn't able to do get what @loukandr suggests to work, but adding the Frameworks as individual files instead of the whole folder did work. Thanks to both @loukandr and @AndreiCalazans !

Aung-Myint-Thein commented 5 years ago

I have managed to followed @AndreiCalazans and @loukandr .. but after that i get a different error and it says "undefined symbols for architecture x86_64 react native" :( Anyone faced it and solved it before?

I am using the following:

"react-native": "^0.55.4", "react-native-firebase": "^4.3.7", Firebase iOS SDK - 5.3.0

I am only using DynamicLink and Messaging. Following is the trace:


Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FIRAnalytics", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseAnalytics.o)
  "_OBJC_CLASS_$_FIRAnalyticsConfiguration", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseAnalytics.o)
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in AppDelegate.o
      objc-class-ref in libRNFirebase.a(RNFirebase.o)
      objc-class-ref in libRNFirebase.a(RNFirebaseUtil.o)
  "_OBJC_CLASS_$_FIRDynamicLinkAndroidParameters", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkComponents", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkComponentsOptions", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkGoogleAnalyticsParameters", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkIOSParameters", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkItunesConnectAnalyticsParameters", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkNavigationInfoParameters", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinkSocialMetaTagParameters", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRDynamicLinks", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseLinks.o)
  "_OBJC_CLASS_$_FIRInstanceID", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseInstanceId.o)
      objc-class-ref in libRNFirebase.a(RNFirebaseMessaging.o)
  "_OBJC_CLASS_$_FIRMessaging", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebaseMessaging.o)
  "_OBJC_CLASS_$_FIROptions", referenced from:
      objc-class-ref in libRNFirebase.a(RNFirebase.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)```
Aung-Myint-Thein commented 5 years ago

I set up using pod and it is working fine. So, maybe above comment is not valid anymore. Thanks guys! Followings are the steps I did in my project:

react-native unlink react-native-firebase react-native install --save react-native-firebase cd ios pod init pod update pod install (will get some warnings but the above link shows how to solve them. open xcworkspace file in xcode and solve them.) react-native link react-native-firebase open xcworkspace file in xcode. Build

JulienMalige commented 5 years ago

@AndreiCalazans your comment should be part of the doc ("without cocoapods" section)

henkkasoft commented 5 years ago

Thank you @AndreiCalazans @loukandr @kolohelios for saving my day! @JulienMalige suggestion for updating the docs for "without cocoapods" -parts would be really helpful for others like me not using Cocoapods.

I am quite noob specially with iOS development and used react-native-firebase first with Android and now it took 2 days to get it working in iOS. Yesterday I tried to use Cocoapods but it broke some other libraries so today I started to install react-native-firebase without cocoapods. Some comments for my installation problems:

For some reason my $(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase was broken. I might broke something myself but I did "react-native link react-native-firebase" on Windows environment. My url was using \ instead of / and xCode did not understand that at all when started to work on MAC with iOS. Then I noticed that when I updated project.pbxproj directly in editor it did not get updated to Xcode even with Xcode->Product->Clean, Xcode shutdown, Library->Developer->Xcode->DerivedData deletion. So I edited them again in Xcode. Maybe some cache problem still?

For noobs like me @AndreiCalazans step 7 would need addition that the $(SRCROOT)/Firebase should be set recursive. And the step 8 would be good to point that you have to search "Framework Search Paths" so that the Build Settings "All" is selected. I had the Customized selected and it was not found.

For the step 4: To help to find the Firebase SDK zip here is a link: https://firebase.google.com/docs/ios/setup At the bottom is the instructions to Integrate without CocoaPods and the link. (I was wondering how to know what version of SDK I have after download the zip?)

And finally @loukandr great suggestion for adding the ios/Firebase folder did not help but the @kolohelios suggestion to add all frameworks separately did work!

There was different kind of error messages I had before this was solved. Here are some I still remember:

tenchoklang commented 5 years ago

For anyone who is still having trouble, I had to modify @AndreiCalazans step 6 and 7 (for step 7 I followed @henkkasoft).For step 6 instead of dragging the entire folder like the Analytics folder into the root/ios/firebase drag the contents within the folder, if your desired sdk file has a folder called RESOURCES drag the contents of that file too. As far as the executables if there is any they dont have to be added i think. I also had to restart xcode and android studio as the app kept crashing when opened. And thank you @AndreiCalazans

AndresCardonaDev commented 5 years ago

HI Guys, i just ran into the same issue, and i read aggain the documentation from the Cocoapod, it says, that the pod for just Firebase needs to be added, then any sub module, so i leaved my configuration as follows and no more File not found exception or anything:

  pod 'Firebase', '~> 5.0.1'
  pod 'Firebase/Core', '~> 5.0.1'
  pod 'Firebase/Auth', '~> 5.0.1'
  pod 'Firebase/Database', '~> 5.0.1'
  pod 'Firebase/Firestore', '~> 5.0.1'
  pod 'Firebase/Messaging', '~> 5.0.1'

(Note, i don't know cocoapods, i come from maven world, but react-native happens and here i am :D, i think is better to set an specific version, and remember to run pod update && pod install on your project, as Firebase startup guide suggests

MWSPL commented 5 years ago

Removing pod 'Firebase/Messaging' and re-installing it solve the issue it seems for

X-code - 10 swift - 4.2 Deployment target - 10.0

bernhardt1 commented 5 years ago

@AndreiCalazans

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

BartoszFicek commented 4 years ago

If you use CocoaPods, just add these lines to your Podfile:

 post_install do |installer|
    rnfirebase = installer.pods_project.targets.find { |target| target.name == 'RNFirebase' }
    rnfirebase.build_configurations.each do |config|
      config.build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ${PODS_ROOT}/Headers/Public/**'
    end
  end
Air-Craft commented 3 years ago

This worked for me. I'm guessing that firebase has nested folders and the non-recursive default by CP doesn't find the modulemaps?