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:
Did you run react-native link
?
Sure did.
Sent from my iPhone
On Nov 12, 2017, at 4:37 PM, Elliot Hesp notifications@github.com 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.
I have the same problem with
~~~
"react-native": "0.50.1"
"react-native-firebase": "^3.0.6"
~
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 notifications@github.com 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.
In my case I had this line use_frameworks!
on my pod file. I commented it and ran again pod install
.
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.
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.
@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 ????
@FakhruddinAbdi try bumping to 3.2.2, there were some header fixes which might help
I did @chrisbianca but still im getting the error :(
@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.
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.
@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
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)")
}
}
}
}
@chrisbianca @Salakar @Ehesp
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
toBuild 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
Hi @sturmenta ,
How to generate or download the file, libRNFirebase.a, mentioned in Step 3?
Thanks for your help.
@FengPu this can be of help:
https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-2
i try @sturmenta solution but still getting error 💃
I had to delete ios/build folder
I had to install 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. Manual linking also worked. 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.
After spending a while going through this thread and making the suggested changes, I managed to get past
RNFirebase core module was not found natively on ios
by running my app through XCode instead of react-native run-ios
. Every time I use the latter, I get this error.
Would there be any reason for that?
It sounds like the issue is still open for more than 1 year and no solution works!!
I even use the latest and recommended pod 'Firebase/Core', '~> 5.15.0'
Hi, am having a similar issue: the command react-native run-ios
does not work, however the build and run work fine in XCode
Did anyone ever find a solution ?
Tried removing the caches using teh commands from @sturmenta , I tried deleting my ios/build
folder, am not using use_frameworks
Also worth noting that the project builds and opens fine on my colleagues machines, so there's definitely some weird caching issue on my machine but where ???
Any help appreciated
Thanks
@vinoa-team
for me, I just forgot about react-native-firebase and used the firebase library
https://www.npmjs.com/package/firebase
Thanks @assafco
For me, I ended up creating a new folder in a new location (on my local machine), pulling the sources from Github, and it all worked.
There's definitely some caching issue in the react-native run-ios
command that differs from the command that is executed in XCode, and that throws things off
For me, Xcode build was working but react-native run-ios
not worked. I removed ios/build
and it has been fixed.
Added libFirebase.a to linked libraries under build phases. Added inherited in Framework Search Paths under RNFirebase Target. And then in Header Search Paths under RNFirebase Target, add a reference to header files in PODS\Private folder (it already contains reference to PODS\Public folder). This solved the issue... thank God! :)
The following steps did it for me on iOS:-
pod install
pod update
Build Phases > Link Binary with Libraries
add libRNFirebase.a (this file wasn't showing up at first but after pod install & update, it showed up)App>Libraries
add RNFirebase.xcodeproj from node_modules > react-native-firebase > RNFirebase > RNFirebase.xcodeproj
@PurnimaNaik - what do you mean by "In App>Libraries
"?
I had a similar issue and then I just linked library manually through XCODE and everything worked fine.
n App>Libraries add RNFirebase.xcodeproj from node_modules > react-native-firebase > RNFirebase > RNFirebase.xcodeproj
@PurnimaNaik I use jest for a test in _Development Operating System_: windows and when run the npm test I got these 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
so how to handle this ?
I'm facing the same issue but in my case, I'm able to run the app, both in Release and Debug mode, on my emulator. The app, however, crashes with You attempted to use a firebase module that's not installed natively on your iOS project by calling firebase.storage()
when I deploy it to testflight. Can someone please tell me a solution for this issue?
I'm not sure about all the differences possible between release mide and archiving but it's my understanding derived data can have stale content. Try install React-native-clean-project then run react-native clean-project, answer yes to clean ios build, it has functionality I added to purge all known ios build stuff including derived data
2 years using react-native and still a freaking pain to use native libraries
In other news people demand leaky abstractions (ability to twiddle with native things under the react-native covers) but people complain about leaky abstractions ;-). I think the answer you want is Expo for a non-leaky abstraction, but then you'd have to count the "but it doesn't work with Expo..." issues for balance.
Here is my working pod file
platform :ios, '9.0'
pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
I met this problem when i tried to run my tests on jest
@Temirtator I also had such a problem. This worked for me
Most helpful comment
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 arecursive
value.Also, In my case it seems that
react-native link
wasn't working properly, so make sure that onBuild Phases/Link Binary with Libraries
you addlibRNFirebase.a
if it's not there, which might not.