Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: RNFirebase core module was not found natively on iOS

Tags:

I created a new app and I am trying to use react-native-firebase. But I continually get this error:

RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects 'Podfile' and have run 'pod install'.

See http://invertase.link/ios for the ios setup guide.

Steps that I have done:

  1. yarn add react-native-firebase

  2. react-native link react-native-firebase

  3. Set up my .plist file from Google under .../myproject/ios/myproject
  4. Ran pod updateafter ensuring I was using Ruby 2.5.0
  5. Ran pod install

The pod file that I am currently using is:

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

target 'MyProject' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
    pod 'Firebase/Core'
    pod 'Firebase/Database'
    pod 'Firebase/Messaging'

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

end

These are the versions that I am using:

"react": "^16.3.0-alpha.1",
"react-native": "0.54.2",
"react-native-firebase": "^3.3.1",
like image 307
user8951490 Avatar asked Mar 22 '18 11:03

user8951490


2 Answers

If you don't want to manually link, you can try installing RNFirebase as a pod install directly:

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

Changing or hardcoding HEADER_SEARCH_PATHS did not help me. When the error recurs, it's not necessary to rm -rf node_modules nor delete the pod file etc, I found it useful to clear the cache.

like image 197
ehacinom Avatar answered Sep 17 '22 12:09

ehacinom


I always prefer not to use pods with react native, however, the react-native-firebase's instructions for the non-pop installation will not work.

The reason for this is the package's search paths which assumes either /pods or /firebase

Source of the problem

Hence, to make it link properly follow these steps:

  1. download firebase sdk
  2. make a folder directly under ios and call it Firebase, copy the frameworks needed of the sdk in that folder WITHOUT keeping the sub-folders (note, you have not entered XCode yet)
  3. If you haven't already npm install -s react-native-firebase
  4. Open XCode and drag and drop the desired frameworks to the Frameworks-folder in XCode (Eg. in my example the contents of the Analytics, Messaging and DynamicLinks folder). Do not copy items when asked as you already have then in the Firebase subfolder of ios: Add frameworks

  5. In XCode right-click Libraries and select "Add files to [project]". Find RNFirebase-project in node_modules and select the RNFirebase.xcodeproj, do not "copy items" RN project file

  6. In Project/Target settings go to Linked Frameworks and Libraries. Find and add libRNFirebase.a libRNFirebase.a

  7. In AppDelegate.m make adjustments as per the instructions from react-native-firebase, eg: import <Firebase.h> and [FIRAPP configure]; in didFinishLaunchingWithOptions

  8. In Header Search Paths AND Framework Search Paths, add $(PROJECT_DIR)/Firebase
  9. Don't forget to add you GoogleServices-Info.plist to your project
like image 37
lovbrand Avatar answered Sep 20 '22 12:09

lovbrand