invertase/react-native-firebase

๐Ÿ”ฅ iOS 13 - Application crashed on launch

carloscuesta opened this issue ยท 20 comments

Issue

Hello!

I was testing a react-native application on iOS 13.0 with Xcode 11.0-beta-4. The build completed succesfully, but when the application launched on the simulator, instantly crashed. The Xcode shows me the following error:

Screenshot 2019-07-24 at 22 40 06

After that, in order to confirm that react-native-firebase was the source of the problem, I removed the [FIRApp configure]; from the AppDelegate.m file and the application started without any problems.

I have to say that we're running this application in production and we have no issues with iOS 12.

com.google.GoogleConfigService.FIRRemoteConfig (serial)
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)


Project Files

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Environment

Click To Expand

react-native info output:

info
  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
      Memory: 51.43 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
      Android SDK:
        API Levels: 23, 25, 26, 28
        Build Tools: 27.0.3, 28.0.2
        System Images: android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 10.3/10G8 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.10 => 0.59.10
    npmGlobalPackages:
      react-native-cli: 2.0.1
  • Platform that you're experiencing the issue on:
    • 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.4
  • Firebase module(s) you're using that has the issue:
    • Analytics
    • Performance Monitoring
  • Are you using TypeScript?
    • No
  • Firebase iOS SDK version


Solution

So while I was writing the issue I found out the problem, seems that on iOS 13 there's a an error with the native firebase-ios-sdk@6.3.0, here's the issue that points out the problem firebase/firebase-ios-sdk#3283 (comment).

So in order to fix this, I upgraded the native SDK to the version 6.5.0 and everything is working โค๏ธ

I'm leaving this here just in case could help anyone, thanks ๐Ÿ™

Maybe it's worth to mention this at the docs!

there is an edit link on all of the docs page if you want to leave a note there - I'm certain this information will help someone else - thanks for posting it

Sure @mikehardy Iโ€™ll find a place to put it, thanks

Just created the PR for adding this to the docs invertase/react-native-firebase-docs#206 @mikehardy

@edreyyo yes! Great catch! can you hit the edit button at the top right of that page and change it? They are on 6.15.0 right now and that's working for me, I'd just put that in there maybe with a link to the compatibility table and a note about ios13, or whatever seems right to you as you edit

@mikehardy Incoming PR: invertase/react-native-firebase-docs#244. I ended up using the same message which is already in the docs (albeit in a different location), hope that's OK?

Hello! i'm new to react native and i'm facing the same issue.
How do i update firebase-ios-sdk to version 6.5.0?

@hengvenchang depends. On react-native-firebase v5 branch you make entries in your Podfile like so (note that 6.15.0 is current right now) https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh#L153

On react-native-firebase v6 you do it like this specifying the version https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh#L30

@hengvenchang depends. On react-native-firebase v5 branch you make entries in your Podfile like so (note that 6.15.0 is current right now) https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh#L153

On react-native-firebase v6 you do it like this specifying the version https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh#L30

@mikehardy i have se same problem IOS crash with use this react-native-firebase v6 make-demo-v6.sh.
libc++abi.dylib: terminating with uncaught exception of type NSException

I will never believe someone that says they "have the same problem" unless they post all the details in the issue template. And even then I will verify. Version differences are critical. Make sure you're fully up to date if you're ever crashing any time for any reason, at minimum, if for no other reason that if the crash can still be reproduced you'll be able to then submit a useful upstream issue for a real fix. Issues submitted on old versions typically get the "upgrade" response because fixes are likely already baked in

@mikehardy, I have run this script for generate react native project and have build with xcode 10.1. First problem have occured in AppDelegate.m was not find firebase module, i have run pod install in directory /ios and generate new build, exuceted in Iphone simulator OS 12.1 (16B91) Model: iPhone Xs Max and have occured this error "libc++abi.dylib: terminating with uncaught exception of type NSException" in xcode.
I have this problem in my migration project from react native 0.59 to 0.60.5 and the firebase v5 to v6. When remove this code "if ([FIRApp defaultApp] == nil) { [FIRApp configure]; }" the build not have error.

There are so many ways for a project to go wrong. They are nearly impossible to troubleshoot.

Here's how to do it right though, start to finish with comments, for:

Study those to find the difference between your project and the generated example and that will be the reason your project isn't working

I've no idea why you'd want to continue using Xcode 10 when 11 is out. Using the most up to date Xcode toolchain is important, and they won't accept builds that aren't Xcode 11 after April 2020, not far away. react-native is at 0.61.5 even, using 0.60 seems pointless? As I said before, get current. That means actually current

@mikehardy. I have used this "react-native 0.60+ + react-native-firebase v6" for create and new react native project and have run in xcode 11.3.1 (11C504). This build was success and have run in simulator iphone 11 Pro Max (13.3), this build have open with splash screen and than have crashad in xcode with error "libc++abi.dylib: terminating with uncaught exception of type NSException".
i have comment this code "if ([FIRApp defaultApp] == nil) { [FIRApp configure]; }" the build not have error, have normal running.

@mikehardy
I sincerely apologize for my insistence of error, I was just running the project and had not noticed that I had not added the GoogleService-Info.list file to the IOS project.
I added the file and generated the build and it ran without errors on IOS.

Excuses.

Hi, so is it possible to make RNFirebase work with iOS 13 using RN 0.59 then?

@antoinerousseau there are scattered reports of success but I wouldn't even attempt it. I maintain quite a few modules and listen on with maintainers on others and there is exactly zero interest in supporting any RN59 scenarios, RN60+ is so much superior with auto-linking. And there are major revisions of all the tool chains and mobile operating systems between RN59 and RN60+ implying underlying breaking changes that can't be easily straddled. https://react-native-community.github.io/upgrade-helper/ - check that out and do the switch to RN60, then incrementally to 61 and 62 at least is what I'd advise

@mikehardy thanks for the feedback, unfortunately we are stuck with RN 0.59 due to our use of ViroReact, which is not compatible with RN 0.60+.
Anyway, I was just able to make a working version with react-native-firebase@5.5 and a Podfile that looks like this:

platform :ios, '9.3'

target 'artefac' do
  use_frameworks!

  rn_path = '../node_modules/react-native'

  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga"

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

  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

  pod 'ViroReact', :path => '../node_modules/react-viro/ios/'
  pod 'ViroKit', :path => '../node_modules/react-viro/ios/dist/ViroRenderer/'
  pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'

  # https://github.com/invertase/react-native-firebase/issues/2409
  pod 'Firebase/Core', '~> 6.5'
  pod 'Firebase/Messaging', '~> 6.5'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'

end

# Remove when updating RN to 0.60+
post_install do |installer|

  # https://v5.rnfirebase.io/docs/v5.x.x/installation/ios#Option-2:-Cocoapods
  rnfirebase = installer.pods_project.targets.find { |target| target.name == 'RNFirebase' }
  rnfirebase.build_configurations.each do |config|
    config.build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ${PODS_ROOT}/Headers/Public/**'
  end

  # https://github.com/facebook/react-native/issues/26255#issuecomment-528275747
  react_project = Xcodeproj::Project.open("../node_modules/react-native/React/React.xcodeproj")
  react_project.main_group["React/Views"].files.each do |file|
    if file.path.match(/^RCTWebView/)
      file.remove_from_project
    end
  end

  react_project.save
  puts "Ready for RN 0.59"
end

Hopefully it will hold up!

Last time I checked, it was still possible and you can even use much more up to date pods https://github.com/mikehardy/rnfbdemo/blob/c81c5a83bdf19bdf1158c9798df587dbf06378f3/make-demo-rn59.sh with RNFB 5.6.0

You might try the branch reference (or use the commit hash) of the tip of v5.x.x to make sure you have the last couple unpublished fixes before we ceased efforts there https://github.com/invertase/react-native-firebase/commits/v5.x.x

That said, you have to move on Viro - there are reports of success and it's open source now viromedia/viro#824 (comment) - no reason it can't move forward

ezy commented

This answer fixed it for me #1499 (comment)