Error: RNFirebase core module was not found native

2019-02-06 01:22发布

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",

3条回答
小情绪 Triste *
2楼-- · 2019-02-06 01:24

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
查看更多
Lonely孤独者°
3楼-- · 2019-02-06 01:26

I had the same problem, while trying to fix it was making my app to crash on start up.

I moved it through the terminal under the ios/AppFolder/ but the Xcode was never aware of this file.

What helped me was to open my project in Xcode. Then left-click on my AppFolder > Add Files and then add the GoogleService-Info.plist.

查看更多
Emotional °昔
4楼-- · 2019-02-06 01:31

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.

查看更多
登录 后发表回答