React-native-firebase: Firebase database native sdk has not been included in your podfile only on device

Created on 19 Sep 2017  路  8Comments  路  Source: invertase/react-native-firebase

I'm trying to use react-native-firebase in my project and it's working just fine on Xcode simulator (tested on iPhone 6 and iPhone 7 - iOS 10.3). However, when I try to run the app on my device (iPhone 7 - iOS 10.3.3) it fails with a warning message

Firebase database native sdk has not been included in your podfile only on device - database methods have been disabled

I tried to reinstall everything, but it failed in the same issue.

Here's my Podfile

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

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

  # Pods for proj
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  pod 'Firebase/Auth'
  pod 'Firebase/AdMob'
  pod 'Firebase/Database'
  pod 'Firebase/Storage'

  pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    # Add any other subspecs you want to use in your project
  ]

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

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

end

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

  # Pods for proj-tvOS

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

end

Here's my podfile.lock

PODS:
  - Firebase/AdMob (4.1.1):
    - Firebase/Core
    - Google-Mobile-Ads-SDK (= 7.23.0)
  - Firebase/Auth (4.1.1):
    - Firebase/Core
    - FirebaseAuth (= 4.1.1)
  - Firebase/Core (4.1.1):
    - FirebaseAnalytics (= 4.0.3)
    - FirebaseCore (= 4.0.6)
  - Firebase/Database (4.1.1):
    - Firebase/Core
    - FirebaseDatabase (= 4.0.2)
  - Firebase/Storage (4.1.1):
    - Firebase/Core
    - FirebaseStorage (= 2.0.1)
  - FirebaseAnalytics (4.0.3):
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - nanopb (~> 0.3)
  - FirebaseAuth (4.1.1):
    - FirebaseAnalytics (~> 4.0)
    - GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)
    - GTMSessionFetcher/Core (~> 1.1)
  - FirebaseCore (4.0.6):
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - nanopb (~> 0.3)
  - FirebaseDatabase (4.0.2):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - leveldb-library (~> 1.18)
  - FirebaseInstanceID (2.0.2):
    - FirebaseCore (~> 4.0)
  - FirebaseStorage (2.0.1):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - GTMSessionFetcher/Core (~> 1.1)
  - Google-Mobile-Ads-SDK (7.23.0)
  - GoogleToolboxForMac/DebugUtils (2.1.1):
    - GoogleToolboxForMac/Defines (= 2.1.1)
  - GoogleToolboxForMac/Defines (2.1.1)
  - GoogleToolboxForMac/NSData+zlib (2.1.1):
    - GoogleToolboxForMac/Defines (= 2.1.1)
  - GoogleToolboxForMac/NSDictionary+URLArguments (2.1.1):
    - GoogleToolboxForMac/DebugUtils (= 2.1.1)
    - GoogleToolboxForMac/Defines (= 2.1.1)
    - GoogleToolboxForMac/NSString+URLArguments (= 2.1.1)
  - GoogleToolboxForMac/NSString+URLArguments (2.1.1)
  - GTMSessionFetcher/Core (1.1.11)
  - leveldb-library (1.18.3)
  - nanopb (0.3.8):
    - nanopb/decode (= 0.3.8)
    - nanopb/encode (= 0.3.8)
  - nanopb/decode (0.3.8)
  - nanopb/encode (0.3.8)
  - React (0.42.3):
    - React/Core (= 0.42.3)
  - React/Core (0.42.3):
    - React/cxxreact
    - Yoga (= 0.42.3.React)
  - React/cxxreact (0.42.3):
    - React/jschelpers
  - React/jschelpers (0.42.3)
  - RNFirebase (2.2.0):
    - React
  - Yoga (0.42.3.React)

DEPENDENCIES:
  - Firebase/AdMob
  - Firebase/Auth
  - Firebase/Core
  - Firebase/Database
  - Firebase/Storage
  - React/Core (from `../node_modules/react-native`)
  - RNFirebase (from `../node_modules/react-native-firebase`)
  - Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

EXTERNAL SOURCES:
  React:
    :path: ../node_modules/react-native
  RNFirebase:
    :path: ../node_modules/react-native-firebase
  Yoga:
    :path: ../node_modules/react-native/ReactCommon/yoga

SPEC CHECKSUMS:
  Firebase: 052c0de688fc87b414996eea13e223dd9fee3fa2
  FirebaseAnalytics: 76f754d37ca5b04f36856729b6af3ca0152d1069
  FirebaseAuth: f8b07aa83de60d606b4eadd81484b3ac2097ea3e
  FirebaseCore: 28def3c643989c97ea5a69ea5000f5fa9902b9fd
  FirebaseDatabase: 4d1a10639a42cae26e094296951b53c689e5e191
  FirebaseInstanceID: c4c7fca62c7b7330caee5da04f19a37ea37bb1c1
  FirebaseStorage: 661fc1f8d4131891d256b62e82a45ace8b3f0c3b
  Google-Mobile-Ads-SDK: a43dc8efdb566c74d00ac6934c781de969348d80
  GoogleToolboxForMac: 8e329f1b599f2512c6b10676d45736bcc2cbbeb0
  GTMSessionFetcher: 5ad62e8200fa00ed011fe5e08d27fef72c5b1429
  leveldb-library: 10fb39c39e243db4af1828441162405bbcec1404
  nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
  React: 35e039680feacd0563677d49ba410112d2748559
  RNFirebase: 67cf507f625e4584b630804fe1254ca34e0e8958
  Yoga: 86ce777665c8259b94ef8dbea76b84634237f4ea

PODFILE CHECKSUM: 1a1c5f1b9263d69871af7e5cb7937f3e6d58a008

COCOAPODS: 1.2.0

Here's my AppDelegate.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"proj"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  [FIRApp configure];

  return YES;
}

@end

My AppDelegate.h

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

My package.json

{
  "name": "proj",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "color": "0.11.3",
    "expo": "18.0.9",
    "firebase": "4.1.3",
    "firebase-functions": "0.6.1",
    "lodash": "4.13.1",
    "moment": "2.13.0",
    "native-base": "2.1.0-rc.2",
    "react": "~15.4.0",
    "react-native": "~0.42.3",
    "react-native-animatable": "0.6.1",
    "react-native-button": "1.6.0",
    "react-native-camera": "0.10.0",
    "react-native-easy-grid": "0.1.7",
    "react-native-fcm": "^9.1.0",
    "react-native-firebase": "^2.2.0",
    "react-native-gifted-spinner": "0.0.4",
    "react-native-i18n": "2.0.2",
    "react-native-lightbox": "0.6.0",
    "react-native-list-popover": "1.0.5",
    "react-native-modalbox": "1.3.4",
    "react-native-qrcode": "0.2.5",
    "react-native-qrcode-scanner": "0.0.14",
    "react-native-router-flux": "3.38.0",
    "react-native-scrollable-tab-view": "0.7.2",
    "react-native-search-bar": "3.0.0",
    "react-native-simple-modal": "3.0.4",
    "react-native-slide-down-panel": "1.0.6",
    "react-native-swiper": "1.5.4",
    "react-native-vector-icons": "4.2.0",
    "react-native-wkwebview-reborn": "1.7.0",
    "react-redux": "4.4.5",
    "redux": "3.5.2",
    "redux-persist": "3.2.2",
    "redux-thunk": "2.1.0",
    "remote-redux-devtools": "0.3.3",
    "remote-redux-devtools-on-debugger": "0.4.6"
  },
  "devDependencies": {
    "babel-eslint": "6.1.2",
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "2.1.0",
    "chai": "3.5.0",
    "eslint": "^4.6.1",
    "eslint-config-airbnb": "^15.1.0",
    "eslint-config-airbnb-base": "7.1.0",
    "eslint-config-prettier": "^2.4.0",
    "eslint-config-react": "^1.1.7",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-prettier": "^2.2.0",
    "eslint-plugin-react": "^7.3.0",
    "eslint-plugin-react-native": "2.0.0",
    "jest": "20.0.4",
    "jest-react-native": "16.0.0",
    "mocha": "2.5.3",
    "prettier": "^1.6.1",
    "react-native-scripts": "0.0.26",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "jest": {
    "preset": "react-native"
  }
}

My firebase.js

import RNFirebase from 'react-native-firebase';

const configurationOptions = {
  persistence: true,
  debug: true
};

const firebase = RNFirebase.initializeApp(configurationOptions);

export default firebase;

And I import this file in every component that uses firebase methods.

I'm using .xcworkspace to run it.

I still couldn't find out why it works on simulator but not on a real device.

Does anyone have any idea how to solve it, please?

Thanks in advance

Most helpful comment

After spending a lot of hours on this, I figure out a way to solve it by deleting my DerivedData project folder.

On Xcode:
File > Workspace Settings
or File > Project Settings

Then click on the grey arrow under Derived Data section (just after your path) and select your project folder to delete it.

Hope it helps someone else who struggles on this.

All 8 comments

After spending a lot of hours on this, I figure out a way to solve it by deleting my DerivedData project folder.

On Xcode:
File > Workspace Settings
or File > Project Settings

Then click on the grey arrow under Derived Data section (just after your path) and select your project folder to delete it.

Hope it helps someone else who struggles on this.

Thank you @soutot. You save me.

@soutot - Thanks for the solution.

After deleting the Derived Data section, did you have to reset cache of your React native project as well?

I am stuck with the same issue, but I can compile and run emulator via Xcode works. But I can't make it to work when I start my ios emulator via react native server.

Thanks in advance.

@sasindroid
After deleting the Derived Data section, I run pod update/install again. Hope my reply is useful

@sasindroid, to be honest, I don't remember needing to reset the cache.
As suggested by @thientnc-ibl , I would try to run pod install or pod update again. You can also try running npm start -- --reset-cache to check if is a cache matter.

Let me know if it works

Hi, i'm facing this problem right now, nothing seems to work. i tried your method of deleting the derived data. and pod install. But it still have the same error. Any idea?
@soutot

@kohchihao unfortunately, this was the only solution I found that worked for me.
You can try checking if any of these closed issues help you:
https://github.com/invertase/react-native-firebase/issues/354#issuecomment-324312296

https://github.com/invertase/react-native-firebase/issues/246#issuecomment-315043420

Hi @soutot , it finally worked. For my case, it was because I copied the react-native-maps config to my podfile and it caused the app to have different version of React . Removing the react-native-maps config solved my problem.

Was this page helpful?
0 / 5 - 0 ratings