React-native-firebase: 馃敟 [v6] Cannot run ios after linking react-native-firebase/app

Created on 14 Jun 2019  路  7Comments  路  Source: invertase/react-native-firebase


Issue



I was able to run my app in both android and ios to the extent that I was able to verify my v6 firebase connection through the google console. However, once I ran react-native link @react-native-firebase/app and pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' was added to my Podfile, I encountered a number of errors.

First was that I had the duplicate react references, so I added

pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

to my Podfile. This fixes the react duplication issue, but now I get a variety of compile errors when I run react-native run-ios. It is usually only one error at a time, things like:

The following build commands failed:
    CompileC /Users/.../ios/build/tgs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTJavaScriptLoader.o /Users/.../node_modules/react-native/React/Base/RCTJavaScriptLoader.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

or

The following build commands failed:
    CompileC /Users/.../ios/build/tgs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTBlobManager.o /Users/.../node_modules/react-native/Libraries/Blob/RCTBlobManager.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

or

The following build commands failed:
    CompileC /Users/.../ios/build/tgs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFBApp.build/Objects-normal/x86_64/RCTConvert+FIROptions.o /Users/.../node_modules/@react-native-firebase/app/ios/RNFBApp/RCTConvert+FIROptions.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

These variations happen presumably because I keep tinkering with the Podfile, I've tried adding

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

instead of pod 'React', :path => '../node_modules/react-native', as well as specifying some React subspecs. Nothing has gotten me back to these compile errors. If I modify my Podfile to remove pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' then I'm able to run ios again and have it work.

I have gotten actual real authentication to work with android, but can't even get ios to run. I've also linked @react-native-firebase/auth, but since the issue seems to happen before I get to that step in ios I didn't go into it here.

These are my npm dependencies (and I have uninstalled, verified cache, and reinstalled many times)

    "@react-native-firebase/app": "^6.0.0-alpha.25",
    "@react-native-firebase/auth": "^6.0.0-alpha.25",
    "react": "^16.8.6",
    "react-native": "^0.59.9",
    "react-native-gesture-handler": "^1.3.0",
    "react-navigation": "^3.11.0"

I have tried:

  • Doing Product -> Clean , close Xcode, reinstall pods, Product -> Clean.
  • Setting my Workspace Settings -> Build System to Legacy Build System.
  • Many, many variations of the Podfile.
  • watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache - many times before different attempts to run.
  • Deleting the ios/build directory

I would really appreciate any help, thank you.


Project Files






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 'tgs' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for tgs
  pod 'Firebase/Core', '~> 5.20.2'
  pod 'Firebase/Auth', '~> 5.20.2'

  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'


end
#### `AppDelegate.m`:
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

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

@import Firebase;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"tgs"
                                            initialProperties:nil];

  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];
  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


Android

Click To Expand

#### `android/build.gradle`:

// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->


Environment

Click To Expand

**`react-native info` output:**

 React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
      Memory: 504.56 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.2.0 - ~/.nvm/versions/node/v12.2.0/bin/node
      npm: 6.9.0 - ~/.nvm/versions/node/v12.2.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.8.6 => 16.8.6
      react-native: ^0.59.9 => 0.59.9
    npmGlobalPackages:
      create-react-native-app: 2.0.2
      react-native-cli: 2.0.1
- **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 - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `N`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

iOS ApCore >= 6

Most helpful comment

I think the problem here might be that you're running link and also manually adding to pods.

Afaik linking in RN 59 is not pod based, so it's adding it to your header search paths. The docs are aimed at RN 60 as this is when pods become the default for RN. RN 59 works but just not through linking on iOS - I'll add a note to the docs sometime.

Could you remove any additions that linking has added to your xcodeproj and change your podfile to this:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
require_relative '../node_modules/@react-native-firebase/app/pod_config'

target 'tgs' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  react_native_path = "../node_modules/react-native"
  pod 'React', :path => "#{react_native_path}", :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTImage',
    'RCTWebSocket',
    # and any other React subspecs that you need
  ]

  pod "yoga", :path => "#{react_native_path}/ReactCommon/yoga"
  pod 'DoubleConversion', :podspec => "#{react_native_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{react_native_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{react_native_path}/third-party-podspecs/Folly.podspec"

  react_native_firebase!
end

The react_native_firebase! functionality will automatically detect any v6 packages that you've installed to node_modules and add in the pods for you when you pod install. So you won't need to modify your Podfile after this - at least not for React Native Firebase.

Also a side note, I noticed you added the Firebase iOS SDKs to your Podfile as well above; this is no longer needed, each RNFirebase podspec manages its own dependencies now to ensure they're always using supported versions.

All 7 comments

I don't have specific recommendations, but reproducibility is key - I recommend 'react-native-clean-project', which has a CLI plugin you can call as react-native clean-project-auto will nuke all known state reproducibly. Also, this is targeted at v5 but you can take the general idea of scripting a project build like https://github.com/mikehardy/rnfbdemo and the make-demo.sh script and at least know that each trial is a reproducible test. There are some other v6 issues right now that involve build breaks so you are not alone at least. You might take a look at the e2e tests on master as well, they can guide you towards a working project

I think the problem here might be that you're running link and also manually adding to pods.

Afaik linking in RN 59 is not pod based, so it's adding it to your header search paths. The docs are aimed at RN 60 as this is when pods become the default for RN. RN 59 works but just not through linking on iOS - I'll add a note to the docs sometime.

Could you remove any additions that linking has added to your xcodeproj and change your podfile to this:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
require_relative '../node_modules/@react-native-firebase/app/pod_config'

target 'tgs' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  react_native_path = "../node_modules/react-native"
  pod 'React', :path => "#{react_native_path}", :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTImage',
    'RCTWebSocket',
    # and any other React subspecs that you need
  ]

  pod "yoga", :path => "#{react_native_path}/ReactCommon/yoga"
  pod 'DoubleConversion', :podspec => "#{react_native_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{react_native_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{react_native_path}/third-party-podspecs/Folly.podspec"

  react_native_firebase!
end

The react_native_firebase! functionality will automatically detect any v6 packages that you've installed to node_modules and add in the pods for you when you pod install. So you won't need to modify your Podfile after this - at least not for React Native Firebase.

Also a side note, I noticed you added the Firebase iOS SDKs to your Podfile as well above; this is no longer needed, each RNFirebase podspec manages its own dependencies now to ensure they're always using supported versions.

Ah, interesting. I ended up following (making up) a mishmash of instructions between v6, v5, and the instructions in Firebase for setting up apps. The v6 guide doesn't mention running react-native link @react-native-firebase/app at all. When I was initially working on adding the apps to Firebase I was struggling to make them work so I started looking at the old docs thinking the new docs weren't complete yet. Now that I have spent a lot more time poking around all of this I think I will revert to an earlier version of my repo and upgrade to rn 60 and see if following your instructions gets me to the right place since I currently don't need any pods other than for Firebase.

If that doesn't work I will come back to this point and try your suggestions.

One other note, I had tried upgrading rn to 0.60.0-rc.1 but a bunch of stuff broke during a pod install so I reverted. Makes a lot more sense now though given what you said about the changes between 59 & 60.

Thank you!

@Salakar I have started over from scratch and am unable to get @react-native-firebase/app@alpha to work by following the exact instructions here: https://invertase.io/oss/react-native-firebase/quick-start/ios-firebase-credentials using RN 60. When I try to run-ios now I get

info /Users/.../ios/tgs/AppDelegate.m:14:9: fatal error: module 'Firebase' not found

info @import Firebase;
 ~~~~~~~^~~~~~~~

info 1 error generated.

To reproduce this:

react-native init RN060 --version react-native@next

add to package.json (known bug: https://github.com/react-native-community/releases/issues/116#issuecomment-501620226):

"resolutions": {
    "@react-native-community/cli": "2.0.0-rc.2"
  }
rm -rf node_modules
yarn install



md5-12688bd376f398cf41b6f760c7ead169



if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
}



md5-78a12d5278740e5f2585714f7fbc0ed1



react-native run-ios



md5-32f4ca5a4d36f62ac5e107d5c94ca335



platform :ios, '9.0'

target 'tgs' do
  # Pods for tgs
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

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

end

target 'tgs-tvOS' do
  # Pods for tgs-tvOS

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

end

Which I have not touched at all manually. I can see there is nothing for Firebase or RNFBApp, so it looks like linking is not quite working correctly for @react-native-firebase/app@alpha.

I will try some of the Podfile recommendations you mentioned earlier.

@spasecadet you need to add the require line and the react_native_firebase! that I mentioned above, regardless of which RN version.

The reason it's not working based on the docs is that RN 60 RC1 is currently missing the autolinking functionality - this will be added in a later RC afaik. We can get the docs updated in the meantime.

Am also curious as to why you're manually creating a new project then integrating when we have a flow for new projects that works out the box (it inits the same RN template for you with RNFirebase integrated): https://invertase.io/oss/react-native-firebase/quick-start/new-project

@Salakar yes, I tried that after writing earlier and it worked 馃憤. I still need to see about getting auth going. I did actually try bootstrapping a new project with your flow but it installs RN 59.8 instead of 60.

One last comment, I tried to implement auth again and it worked fine on Android, but on iOS when I tried to call auth().signInWithEmailAndPassword(email, password) I got an error message that said "You attempted to use a firebase module that's not installed natively on your iOS project by calling firebase.auth(). Ensure you have either linked the module or added it to your projects Podfile. See http://invertase.link/ios for full setup instructions."

My Podfile was not updated with anything that looks like auth, presumably due to the issue you mentioned earlier. I added pod 'RNFBAuth', :path => '../node_modules/@react-native-firebase/auth/ios to my Podfile as mentioned here: https://invertase.io/oss/react-native-firebase/v6/auth/ios, and it is now working.

Thanks for all the help!

Was this page helpful?
0 / 5 - 0 ratings