I can't get this to work without using CocoaPods. This is the error I am getting when I try react-native run-ios
or building in XCode.
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 libRNFirebase.a(RNFirebase.o)
objc-class-ref in libRNFirebase.a(RNFirebaseUtil.o)
"_OBJC_CLASS_$_FIRInstanceID", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseInstanceId.o)
"_OBJC_CLASS_$_FIROptions", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebase.o)
ld: symbol(s) not found for architecture x86_64
I think that the react-native link react-native-firebase
is maybe causing the issue as suggested by @chrisbianca in https://github.com/invertase/react-native-firebase/issues/602#issuecomment-346435976
Is it possible that there is still some incompability issue with any version of React Native above 0.50
?
If I run react-native unlink react-native-firebase
the build succeeds but I get obviously an error message when running the app.
React Native Version: 0.55.4
React Native Firebase Version: 4.1.0
Firebase SDK Version: 4.13.0
This is exactly what I have done step by step:
Followed the Steps of the Initial Installation:
npm install --save react-native-firebase
Than the steps specific for iOS:
#import <Firebase.h>
at the top of AppDelegate.m
[FIRApp configure];
at the beginning of didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
within the same fileI than downloaded the Firebase 4.13.0 SDK Files and included the files following @AndreiCalazans suggestions in https://github.com/invertase/react-native-firebase/issues/1016#issuecomment-384027481:
Create a Firebase
folder in root/ios/Firebase
.
Copy the folder Analytics
, the module.modulemap
file and Firebase.h
inside to root/ios/Firebase
.
Added $(SRCROOT)/Firebase to both the Header Search Paths
and Framework Search Paths
.
Search for Other Linker Settings and made sure that the -ObjC
flag is set
Last but not least I executed react-native link react-native-firebase
.
I tried as well following the Firebase SDK Readme File instead of the above process, but without success. Whenever I try linking react-native-firebase
I get the above error.
Another thing I tried was the suggested solution from @paldepind in #602 of rm /node_modules/react-native-firebase/ios/RNFirebase.podspec
before linking but it didn't help.
It seems that the error was caused by missing some framework within the Link Binaries with Library
Step.
For anybody having the same problem, following these exact steps finally worked for me:
First of all we need to download our GoogleService-Info.plist
from the Firebase Console and save it to our /ios/AppName/
Folder.
Than we have to add it as well to our XCode Project.
Open the Project in XCode and click on File
» Add Files to …
and select the GoogleService-Info.plist
we just downloaded. Make sure that it is included within the right build target and check Copy files if needed
.
Now we have to add the Firebase SDK
to our Project without using CocoaPods
(Which is the recommended option but will likely break other dependencies).
Start by downloading the Firebase SDK Version 4.13.0.
(5.0.0 will break at time of this writing because its not yet compatible with react-native-firebase)
Unzip it and open the Analytics
subfolder.
Within XCode's Project Navigator Pane (Press ⌘ - 1
if its not already open) make a right click on the Libraries
Folder and select New Group with Folder
and name it Firebase
.
Drag each file from the Analytics
subfolder into the new Firebase
Folder.
In the Dialog that appears Make sure that the right target is selected and that you copy items if needed
Add the time of writing this should be the following Frameworks:
FirebaseAnalytics.framework
FirebaseCore.framework
FirebaseCoreDiagnostics.framework
FirebaseInstanceID.framework
FirebaseNanoPB.framework
GoogleToolboxForMac.framework
nanopb.framework
Next add the Contents of the Auth
Subfolder.
FirebaseAuth.framework
GTMSessionFetcher.framework
You might want to add further frameworks or ressources of other modules depending on your use case.
All of these frameworks should automatically be added to the Link Binaries with Library
Build Step, but double check that they really have been added.
Within XCode go to Build Settings
» Linking
» Other Linker Flags
and make sure that the -ObjC
Flag is added.
Make sure as well to add $(PROJECT_DIR)/Firebase
to both the Framework Search Path
and Header Search Path
Build Settings for the Target.
Last but not least add the Firebase.h
file from the root folder of the SDK to the same Firebase
Folder within XCode, again making sure to select the right target and to copy files if needed
. Double check that it has been added as well to the Link Binaries with Library
Step.
Afterwards we can import the Firebase SDK
within our AppDelegate.m
File by adding the Following line at the top:
// react-native-firebase
#import <Firebase.h>
At the beginning of didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
we add:
[FIRApp configure];
Thank you so much, jaschaio! It worked!!!!! YOU saved me a lot of time...
thank you @jaschaio , your solution worked smoothly after banging my head with the official docs. Saved my day!
rm -rf ~/Library/Developer/Xcode/DerivedData/ - clean xcode cache help me =)
@ktarasenkowow that command is integrated into the module 'react-native-clean-project', highly recommended any time you're not sure locally, and definitely on CI systems
@jaschaio , I am trying to follow these steps, but want to know if there is any way to check which version of Firebase SDK is compatible with react native as of now.
@akshaya-rao-s unfortunately I don't know – haven't worked with Firebase and react native for quite some time
The most current versions of the underlying SDKs are working with most current version of react-native-firebase v5 and v6+
do we have the option of using the legacy build system? I have some dependency in the project.
Right now I am facing this error:
`
Error: the use of xcframeworks is not supported in the legacy build system.
`
Most helpful comment
It seems that the error was caused by missing some framework within the
Link Binaries with Library
Step.For anybody having the same problem, following these exact steps finally worked for me:
First of all we need to download our
GoogleService-Info.plist
from the Firebase Console and save it to our/ios/AppName/
Folder.Than we have to add it as well to our XCode Project.
Open the Project in XCode and click on
File
»Add Files to …
and select theGoogleService-Info.plist
we just downloaded. Make sure that it is included within the right build target and checkCopy files if needed
.Now we have to add the
Firebase SDK
to our Project without usingCocoaPods
(Which is the recommended option but will likely break other dependencies).Start by downloading the Firebase SDK Version 4.13.0.
(5.0.0 will break at time of this writing because its not yet compatible with react-native-firebase)
Unzip it and open the
Analytics
subfolder.Within XCode's Project Navigator Pane (Press
⌘ - 1
if its not already open) make a right click on theLibraries
Folder and selectNew Group with Folder
and name itFirebase
.Drag each file from the
Analytics
subfolder into the newFirebase
Folder.In the Dialog that appears Make sure that the right target is selected and that you
copy items if needed
Add the time of writing this should be the following Frameworks:
FirebaseAnalytics.framework
FirebaseCore.framework
FirebaseCoreDiagnostics.framework
FirebaseInstanceID.framework
FirebaseNanoPB.framework
GoogleToolboxForMac.framework
nanopb.framework
Next add the Contents of the
Auth
Subfolder.FirebaseAuth.framework
GTMSessionFetcher.framework
You might want to add further frameworks or ressources of other modules depending on your use case.
All of these frameworks should automatically be added to the
Link Binaries with Library
Build Step, but double check that they really have been added.Within XCode go to
Build Settings
»Linking
»Other Linker Flags
and make sure that the-ObjC
Flag is added.Make sure as well to add
$(PROJECT_DIR)/Firebase
to both theFramework Search Path
andHeader Search Path
Build Settings for the Target.Last but not least add the
Firebase.h
file from the root folder of the SDK to the sameFirebase
Folder within XCode, again making sure to select the right target and tocopy files if needed
. Double check that it has been added as well to theLink Binaries with Library
Step.Afterwards we can import the
Firebase SDK
within ourAppDelegate.m
File by adding the Following line at the top:At the beginning of
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
we add:[FIRApp configure];