invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.74k stars 2.22k forks source link

You attempted to use a firebase module that's not installed natively on your iOS project by calling firebase.auth() #2959

Closed minuhariharan closed 4 years ago

minuhariharan commented 4 years ago

Issue

Describe your issue here

I am using react native version 60 and react native firebase version 5.5.6 and added my application ow requires Firebase storage and Firebase Auth, so I followed the instructions in this link [https://rnfirebase.io/docs/v5.x.x/auth/ios]. What I have tried so far, which did not work:

Just Pod install Just Pod update A combination of both Using Firebase Auth 6.11.0 and 6.3.0

This works fine for the development environment i.e. when I run on the iOS Simulator most of the times, but there as well I have seen this errors a couple of times, so it's not reliable. It is working fine for Android but on iOS I am hitting this issue:

You attempted to use a firebase module that's not installed natively on your iOS project by calling firebase.auth().

Ensure you have the required Firebase iOS SDK pod for this module included in your Podfile, in this instance confirm you've added "pod 'Firebase/Auth'" to your Podfile

See http://invertase.link/ios for full setup instructions.


Project Files

Javascript

Click To Expand

`import Firebase from 'react-native-firebase'` `Firebase.auth() .signInWithCustomToken(authToken) ...` #### `package.json`: ```json `{ "name": "GalarmApp", "version": "2.9.0", "private": true, "scripts": { "start": "react-native start", "test": "jest", "lint": "eslint .", "postinstall": "npx jetify", "deep-clean": "./node_modules/.bin/react-native-clean-project --keep-node-modules --remove-iOS-build --keep-brew --keep-pods --remove-iOS-pods --remove-android-build && yarn clean", "clean": "\\rm -fr ./node_modules && \\rm -fr dist/* && \\rm -fr ios/build ios/Pods ios/KScoreApp.xcarchive && \\rm -fr android/build android/app/build" }, "dependencies": { "@react-native-community/async-storage": "^1.6.1", "@react-native-community/netinfo": "^4.1.3", "@react-native-community/slider": "^2.0.0", "buffer": "^5.2.1", "core-js": "^2.5.7", "fast-deep-equal": "^2.0.1", "fast-memoize": "^2.5.1", "firebase": "^6.3.4", "invariant": "^2.2.4", "jsc-android": "^241213.2.0", "libphonenumber-js": "^1.7.22", "lodash": "^4.17.15", "moment-timezone": "^0.5.26", "prop-types": "^15.7.2", "raven-js": "^3.27.2", "react": "^16.8.6", "react-fast-compare": "^2.0.4", "react-native": "^0.60.4", "react-native-action-button": "^2.8.5", "react-native-animatable": "^1.3.2", "react-native-clean-project": "^3.3.0", "react-native-collapsible": "^1.5.1", "react-native-communications": "^2.2.1", "react-native-config": "^0.11.7", "react-native-contacts": "^5.0.2", "react-native-country-picker-modal": "^1.8.1", "react-native-device-info": "^2.3.2", "react-native-dialogs": "github:varungupta85/react-native-dialogs", "react-native-elements": "^1.1.0", "react-native-fast-image": "^6.1.1", "react-native-firebase": "^5.5.6", "react-native-gifted-chat": "github:varungupta85/react-native-gifted-chat", "react-native-i18n": "^2.0.15", "react-native-iap": "^3.4.13", "react-native-image-crop-picker": "^0.25.0", "react-native-ios-notification-actions": "github:holmesal/react-native-ios-notification-actions", "react-native-keyboard-aware-scroll-view": "^0.8.0", "react-native-keyboard-spacer": "^0.4.1", "react-native-localize": "^1.1.4", "react-native-navigation": "2.27.9", "react-native-parsed-text": "0.0.21", "react-native-permissions": "^1.2.0", "react-native-radio-buttons": "^1.0.0", "react-native-sound": "github:varungupta85/react-native-sound", "react-native-splash-screen": "^3.2.0", "react-native-store-review": "^0.1.5", "react-native-swiper": "^1.5.14", "react-native-uuid": "^1.4.9", "react-native-vector-icons": "^6.6.0", "react-redux": "^7.1.0", "redux": "^4.0.4", "redux-persist": "^6.0.0", "redux-thunk": "^2.3.0", "reduxsauce": "^1.1.0", "reselect": "^4.0.0", "semver": "^6.3.0", "uuid": "^3.3.2", "wordwrap": "^1.0.0" }, "devDependencies": { "@babel/core": "^7.5.5", "@babel/runtime": "^7.5.5", "@react-native-community/eslint-config": "0.0.5", "babel-eslint": "^10.0.1", "babel-jest": "^24.8.0", "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-preset-flow": "^6.23.0", "eslint": "^6.1.0", "eslint-config-airbnb": "^17.1.0", "eslint-plugin-import": "^2.15.0", "eslint-plugin-jsx-a11y": "^6.1.2", "eslint-plugin-react": "^7.12.4", "jest": "^24.8.0", "jetifier": "^1.6.3", "metro-react-native-babel-preset": "^0.55.0", "react-addons-perf": "^15.4.2", "react-addons-test-utils": "16.0.0-alpha.3", "react-dom": "16.7.0", "react-test-renderer": "^16.8.6", "reactotron-react-native": "^2.1.4", "reactotron-redux": "^2.1.3", "redux-mock-store": "^1.5.3", "why-did-you-update": "^1.0.6" }, "resolutions": { "moment-timezone/moment": "2.24.0", "moment": "2.24.0" }, "jest": { "preset": "react-native", "setupFiles": [ "./jestSetup.js" ] } } ` # N/A ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ``` ### iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: `# Uncomment the next line to define a global platform for your project platform :ios, '9.0' target 'GalarmApp' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! pod 'Firebase/Core', '~> 6.3.0' pod 'Firebase/Storage', '~> 6.3.0' pod 'Firebase/Auth', '~> 6.3.0' pod 'RSKImageCropper' pod 'QBImagePickerController' pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '4.3.4' post_install do |installer| installer.pods_project.targets.each do |target| # The following is needed to ensure the "archive" step works in XCode. # It removes React & Yoga from the Pods project, as it is already included in the main project. # Without this, you'd see errors when you archive like: # "Multiple commands produce ... libReact.a" # "Multiple commands produce ... libyoga.a" targets_to_ignore = %w(RSKImageCropper) if targets_to_ignore.include? target.name target.remove_from_project end end # This fixes the problems with headers not found system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/") end target 'GalarmAppTests' do inherit! :search_paths # Pods for testing end end ` ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```

--- ### Android
Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```

--- ## Environment
Click To Expand

**`react-native info` output:** ``` System: OS: macOS 10.15.1 CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz Memory: 38.82 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node Yarn: 1.12.3 - /usr/local/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm Watchman: 4.5.0 - /usr/local/bin/watchman IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: /undefined - /usr/bin/xcodebuild npmPackages: react: ^16.8.6 => 16.8.6 react-native: ^0.60.4 => 0.60.4 npmGlobalPackages: react-native-fast-image: 7.0.2 react-native-git-upgrade: 0.2.7 ``` - **Platform that you're experiencing the issue on**: - [x ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `5.5.6` - **`Firebase` module(s) you're using that has the issue:** - `Auth` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`

--- Think `react-native-firebase` is great? Please consider supporting all of the project maintainers and contributors by donating via our [Open Collective](https://opencollective.com/react-native-firebase/donate) where all contributors can submit expenses. [[Learn More]](https://invertase.io/oss/react-native-firebase/contributing/donations-expenses) - 👉 Check out [`React Native Firebase`](https://twitter.com/rnfirebase) and [`Invertase`](https://twitter.com/invertaseio) on Twitter for updates on the library.
mikehardy commented 4 years ago

If you are experiencing inconsistent behavior, especially between debug and release builds on ios, check out the react-native-clean-project module and I highly recommend npx react-native-clean-project clean-project-auto

Secondly, there are just so many ways a project can be integrated incorrectly, I have terrible luck trying to pick them apart. Instead, I've build a script which will take a react-native project from a fresh init, to fully integrating a bunch of modules including the two you mention. You should try it, read the comments for each thing it's doing, and compare the output with your project - you might find the problem? https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

minuhariharan commented 4 years ago

I already tried the deep clean target that you mentioned in #2697 (comment) but no luck there as well

alex-mironov commented 4 years ago

Apparently I've got a similar issue on iOS:

[Unhandled promise rejection: Error: You attempted to use a firebase module that's not installed nati]ely on your iOS project by calling firebase.analytics().
- node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js:109:22 in initialiseNativeModule
- node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js:210:32 in getNativeModule

@mikehardy to your point about incorrect integration, following the documentation there are just a couple simple steps for RN 0.60+. I've basically done

yarn add @react-native-firebase/app
yarn add @react-native-firebase/analytics 
cd ios/ && pod install

updated AppDelegate.m

...
#import <Firebase.h>

...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  [Fabric with:@[[Crashlytics class]]];

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

and copied GoogleService-Info.plist into project folder.

Am I missing something?

mikehardy commented 4 years ago

@alex-mironov you have a different issue, because you're on react-native-firebase v6. The script for that one is https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh :-)

minuhariharan commented 4 years ago

@mikehardy Thanks will try the script

alex-mironov commented 4 years ago

@mikehardy I don't want to sound rude, but the script doesn't seem to be so much usable. If you really want people to use it, it could probably be split into chunks with proper steps instead of # 4. alter the target to 'both' instead of iPhone only. Also there is some unnecessary stuff there like rm -f ios/rnfbdemo.xcodeproj/project.pbxproj

mikehardy commented 4 years ago

PR it, I'll take any improvement. Open source my friend

It does actually work though, does not result in

[Unhandled promise rejection: Error: You attempted to use a firebase module that's not installed nati]ely on your iOS project by calling firebase.analytics().
- node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js:109:22 in initialiseNativeModule
- node_modules/@react-native-firebase/app/lib/internal/registry/nativeModule.js:210:32 in getNativeModule
mikehardy commented 4 years ago

BTW - the part you are examining particularly, that's a note for maintainers. You don't have to do that part. I was thinking through why you would be mentioning that then it struck me the instructions there weren't clear. They are more clear now I hope?

You really just need to clone the repo and run the script

https://github.com/mikehardy/rnfbdemo/commit/29c3d84a0b9e28e18698ed8f2705ec8340621f04

alex-mironov commented 4 years ago

@mikehardy thanks a lot. It makes sense now. I will check it out.

minuhariharan commented 4 years ago

@mikehardy Does this script create a new react native facebook project ? If so were you suggesting that I can use that as a reference project to compare my current project?

mikehardy commented 4 years ago

@minuhariharan I will assume you mean react-native-firebase, and yes - that is exactly what it does, from absolute scratch, so you can see exactly what steps are required for most modules (skipping messaging and notifications because they are crazy) but does the nearly all the rest

minuhariharan commented 4 years ago

@mikehardy I meant that thanks, will go over the comments in the script and set it up and then compare with my project

minuhariharan commented 4 years ago

@mikehardy I cloned the repo, created a firebase project with a demo app, copied over the config files for android ios to the root of the repo, then ran your script. However react-native run-ios or running the project by opening Xcode don't seem to work and I get this error :
Showing All Errors Only /Users/minuhariharan/rnfbdemo/rnfbdemo/ios/Pods/Target Support Files/Pods-rnfbdemoTests/Pods-rnfbdemoTests.debug.xcconfig: unable to open file (in target "rnfbdemoTests" in project "rnfbdemo")

The build script was successful, it did not show me any errors.

mikehardy commented 4 years ago

Hmm - that's unexpected, worked for me last time I updated it. I'll have to check it out but it's end of day here for me so I won't be back to work for a while then I'm traveling rest of week, I'm not sure how much help I'll be quickly, sorry

minuhariharanuic commented 4 years ago

@mikehardy No problem thanks, if I figure it out will update here

stale[bot] commented 4 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

Rawan-Eltobgy commented 4 years ago

Importing in this form:

import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';

solved it for me

cimpianRadu commented 4 years ago

for me too..but it was a bit unexpected 😄

TobinXu commented 3 years ago

Importing in this form:

import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';

solved it for me

me tooooo!

eramudeep commented 3 years ago

i am getting the same error but the above answer not worked for me. :(

carlosen14 commented 2 years ago

same problem, had to re-run npm run ios, to update the modules

patlux commented 2 years ago

For me it was the missing @react-native-firebase/analytics package. I only installed @react-native-firebase/app. It's not really clear from the instructions that this is required.

$ yarn add @react-native-firebase/analytics
mikehardy commented 2 years ago

@patlux that's not a general solution (installing specifically the analytics package*

The general solution is: if you want to use the APIs from one of the firebase modules, you need to install the app module here as well as the specific module