react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

RNFirebase core module was not found natively on ios

Open chris-rowe opened this issue 9 years ago • 39 comments

Issue

I created a brand new RN project with react-native init, followed all the instructions for setting up firebase on iOS and Android, added the Firestore module, added some simple code to App.js, and I received this error right off the bat. Here are my setup files: package.json

{
	"name": "Test",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"start": "node node_modules/react-native/local-cli/cli.js start",
		"test": "jest"
	},
	"dependencies": {
		"react": "16.0.0",
		"react-native": "0.50.3",
		"react-native-firebase": "^3.1.0"
	},
	"devDependencies": {
		"babel-jest": "21.2.0",
		"babel-preset-react-native": "4.0.0",
		"jest": "21.2.1",
		"react-test-renderer": "16.0.0"
	},
	"jest": {
		"preset": "react-native"
	}
}

App.js

import React, { Component } from 'react';
import {
  Text,
  View
} from 'react-native';
import firebase from 'react-native-firebase';

export default class App extends Component {
  constructor() {
    super();
    this.ref = firebase.firestore().collection('users');
  }

  addUser() {
    this.ref.add({
      firstName: "John",
      lastName: "Smith"
    }); 
  }

  componentDidMount() {

  }
  render() {
    return (
      <View>
        <Text>Hello</Text>
        <Button 
          title="Add user"
          onPress={() => this.addUser()}
        />  
      </View>  
    );
  }
}

PodFile

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

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

  # Pods for Driven
  pod 'Firebase/Core'
  pod 'Firebase/Firestore'

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

end

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

  # Pods for Driven-tvOS

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

end

Output from pod install

Analyzing dependencies
Downloading dependencies
Using BoringSSL (9.1)
Using Firebase (4.5.0)
Using FirebaseAnalytics (4.0.4)
Using FirebaseAuth (4.3.1)
Using FirebaseCore (4.0.10)
Using FirebaseFirestore (0.9.1)
Using FirebaseInstanceID (2.0.5)
Using GTMSessionFetcher (1.1.12)
Using GoogleToolboxForMac (2.1.3)
Using Protobuf (3.4.0)
Using gRPC (1.7.1)
Using gRPC-Core (1.7.1)
Using gRPC-ProtoRPC (1.7.1)
Using gRPC-RxLibrary (1.7.1)
Using leveldb-library (1.20)
Using nanopb (0.3.8)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 16 total pods installed.

Here is the full error: screen shot 2017-11-12 at 3 47 58 pm

Environment

  1. Application Target Platform: iOS
  1. Development Operating System: macOS Sierra
  1. Build Tools: xcode v8.3.1 - Not used except to ensure plist file was added
  1. React Native version: 0.50.3
  1. RNFirebase Version: 3.1.0
  1. Firebase Module: Core, Firestore

chris-rowe avatar Nov 12 '17 20:11 chris-rowe

Did you run react-native link?

Ehesp avatar Nov 12 '17 21:11 Ehesp

Sure did.

Sent from my iPhone

On Nov 12, 2017, at 4:37 PM, Elliot Hesp [email protected] wrote:

Did you run react-native link?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

chris-rowe avatar Nov 12 '17 21:11 chris-rowe

I have the same problem with

"react-native": "0.50.1"
"react-native-firebase": "^3.0.6"

jorgemasta avatar Nov 12 '17 22:11 jorgemasta

I fixed it. Go up to the menu for the simulator and click “Reset content and settings” Then do react-native run-ios

Chris Rowe AtmosFit, Founder & CEO w: atmosfit.com p: 386-793-1666 e: [email protected]

On Nov 12, 2017, at 5:10 PM, Jorge Marrero [email protected] wrote:

I have the same problem with

"react-native": "0.50.1" "react-native-firebase": "^3.0.6" — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invertase/react-native-firebase/issues/614#issuecomment-343772270, or mute the thread https://github.com/notifications/unsubscribe-auth/AB04uFY9CREvyP19ls_MsJtw7RCJWznyks5s12zYgaJpZM4QbCWW.

chris-rowe avatar Nov 12 '17 23:11 chris-rowe

In my case I had this line use_frameworks! on my pod file. I commented it and ran again pod install.

arcesoj avatar Dec 03 '17 16:12 arcesoj

If this is still an issue for anybody on this thread, my solution was to run pod update and then pod install again. a fresh pod install on a new project doesn't pull the latest pods.

jwrubel avatar Dec 08 '17 13:12 jwrubel

I will just leave it here, in case someone comes and it's still struggling with this. Make sure that on [yourproject]/Build Settings/Framework Search Paths you have added $(inherited) both for Debug and Release with a recursive value.

Also, In my case it seems that react-native link wasn't working properly, so make sure that on Build Phases/Link Binary with Libraries you add libRNFirebase.a if it's not there, which might not.

facuacostag avatar Jan 05 '18 10:01 facuacostag

@jwrubel i have updated my pod and installed it again. @arcesoj i have commented out use_frameworks line from pod file @chris-rowe i have reseted configs from ios simulator @Ehesp Im sure i have linked using react-native link

my rnFirebase version is "3.2.0" pod version is "1.4.0"

Im using expo starter kit for my project.

WHY IM STILL GETTING THIS ERROR ????

abdifardin avatar Jan 25 '18 17:01 abdifardin

@FakhruddinAbdi try bumping to 3.2.2, there were some header fixes which might help

chrisbianca avatar Jan 25 '18 18:01 chrisbianca

I did @chrisbianca but still im getting the error :(

abdifardin avatar Jan 25 '18 18:01 abdifardin

@FakhruddinAbdi ensure your syntax is correct when importing and configuring the Firebase module in AppDelegate.m. I got this error due to a missing semicolon. I fixed that, then reset content and settings on the simulator and ran the app without errors.

kpgaffney avatar Jan 27 '18 18:01 kpgaffney

Thanks @gaffneyk , i just remembered to mention that i don't have AppDelegate.m when i setup ios project using xcode. Instead it has created AppDelegate.swift. When i added the codes there, it give me an error and i had to remove them.

abdifardin avatar Jan 27 '18 18:01 abdifardin

@chrisbianca could you please let me know if i should follow same instruction in AppDelegate.swift as the one wrote for AppDelegate.m in the README.md ?

How does AppDelegate.swift replace AppDelegate.h and AppDelegate.m in Xcode 6.3

abdifardin avatar Jan 27 '18 18:01 abdifardin

here is my AppDelegate.swift @chrisbianca

import UIKit
import CoreData
import Firebase


 @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    [FIRApp configure];
    return true
}

func applicationWillResignActive(_ application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    // Saves changes in the application's managed object context before the application terminates.
    self.saveContext()
}

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentContainer = {
    /*
     The persistent container for the application. This implementation
     creates and returns a container, having loaded the store for the
     application to it. This property is optional since there are legitimate
     error conditions that could cause the creation of the store to fail.
    */
    let container = NSPersistentContainer(name: "harzaan")
    container.loadPersistentStores(completionHandler: { (storeDescription, error) in
        if let error = error as NSError? {
            // Replace this implementation with code to handle the error appropriately.
            // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
             
            /*
             Typical reasons for an error here include:
             * The parent directory does not exist, cannot be created, or disallows writing.
             * The persistent store is not accessible, due to permissions or data protection when the device is locked.
             * The device is out of space.
             * The store could not be migrated to the current model version.
             Check the error message to determine what the actual problem was.
             */
            fatalError("Unresolved error \(error), \(error.userInfo)")
        }
    })
    return container
}()

// MARK: - Core Data Saving support

func saveContext () {
    let context = persistentContainer.viewContext
    if context.hasChanges {
        do {
            try context.save()
        } catch {
            // Replace this implementation with code to handle the error appropriately.
            // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            let nserror = error as NSError
            fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
        }
    }
}

}

abdifardin avatar Jan 28 '18 08:01 abdifardin

@chrisbianca @Salakar @Ehesp

abdifardin avatar Feb 10 '18 07:02 abdifardin

In my case:

1 -- had no comment on the use_frameworks! line in the Podfile. arcesoj comment

2 -- I did a cleaning and install again with the help of justinswart comment

rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; pod install;

3 -- and add libRNFirebase.a to Build Phases / Link Binary with Libraries facuacosta comment I had not realized that simple step, thank you @FacuAcosta

And the application worked! 🎉

Thank you very much @chrisbianca for your time invested in react-native-firebase

sturmenta avatar Apr 28 '18 07:04 sturmenta

Hi @sturmenta ,

How to generate or download the file, libRNFirebase.a, mentioned in Step 3?

Thanks for your help.

FengPu avatar Jun 10 '18 04:06 FengPu

@FengPu this can be of help: https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-2

sturmenta avatar Jun 10 '18 18:06 sturmenta

i try @sturmenta solution but still getting error 💃

Mogust avatar Aug 01 '18 08:08 Mogust

I had to delete ios/build folder

celest67 avatar Oct 19 '18 15:10 celest67