[🐛] Rnfirebase RealTime database does not work with pods
Rnfirebase realtime database does not work with pods.
I ran these commands on a new plain react project:
# Install & setup the app module
yarn add @react-native-firebase/app
# Install the database module
yarn add @react-native-firebase/database
# If you're developing your app using iOS, run this command
cd ios/ && pod install && cd ..
when running pod install I get the following error
pod install
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration
Auto-linking React Native modules for target `engly`: RNFBApp and RNFBDatabase
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "Firebase/Database":
In Podfile:
RNFBDatabase (from `../node_modules/@react-native-firebase/database`) was resolved to 12.7.2, which depends on
Firebase/Database (= 8.6.0)
None of your spec sources contain a spec satisfying the dependency: `Firebase/Database (= 8.6.0)`.
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
I have tried changing the IOS version in the iOS/podfile I have also tried running:
pod install --repo-update
pod repo update
and the error still occurs
Project Files
Javascript
Click To Expand
`{
"name": "engly", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-firebase/app": "^12.7.2", "@react-native-firebase/database": "^12.7.2", "react": "17.0.2", "react-native": "0.65.1" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "7.14.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.66.0", "react-native-codegen": "^0.0.7", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } } `:
# N/A
firebase.json for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
# require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'engly' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
target 'englyTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
AppDelegate.m:
// #import <Firebase.h>
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"engly"
initialProperties:nil];
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
Environment
Click To Expand
react-native info output:
info Fetching system and libraries information...
System:
OS: macOS 11.5
CPU: (8) x64 Apple M1
Memory: 36.74 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.5.0 - /usr/local/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 6.14.11 - /usr/local/bin/npm
Watchman: 2021.08.02.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
- Platform that you're experiencing the issue on:
- [ x] iOS
- [ ] Android
- [ x] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
react-native-firebaseversion you're using that has this issue:e.g. 5.4.3
Firebasemodule(s) you're using that has the issue:e.g. Instance ID
- Are you using
TypeScript?N
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
It works fine, pod install --repo-update (repo-update is the key)
https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh
I see that this was closed, but neither of those 2 commands worked for me, and OP says he tried them.
pod update worked tho
Not sure what's wrong but those two commands are both doing the same thing under the covers: syncing the cocoapods definition files from the github repo, at which point firebase-ios-sdk cocoapods 8.6.0 is defined.
It (firebase-ios-sdk 8.6.0) definitely exists, this is not a problem with react-native-firebase, it's a problem somewhere on the local machine / local network with getting cocoapods synced.
Not sure what's wrong but those two commands are both doing the same thing under the covers: syncing the cocoapods definition files from the github repo, at which point firebase-ios-sdk cocoapods 8.6.0 is defined.
It (firebase-ios-sdk 8.6.0) definitely exists, this is not a problem with react-native-firebase, it's a problem somewhere on the local machine / local network with getting cocoapods synced.
I've ran both those commands and they do t work... However you mention that it's a problem with the local machine.
I'm using a MacBook Pro M1
What else can I do to fix this since I can't move on without this being fixed...
I have the same problem, any solution?
arch -x86_64 pod install
am on MacBook M1, and this worked.
That's (using Rosetta2) also not necessary, examine: https://github.com/facebook/react-native/issues/31941 and I have tested my make-demo.sh script on an M1, I'm one of the primary M1 testers for react-native on this last 0.65 react-native release.
Something is wrong with your local machine. What? I do not know, sorry, but this stuff works on an M1
Here's verifiable proof 8.6.0 exists, by the way: https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/8.6.0/Firebase.podspec.json