This issue is a specific case of one of the startup crashes reported in #313 . When running the app from Xcode for the first time after a clean, the app crashes. This happens when running from Xcode after a clean and on every archive build.
https://github.com/bartolkaruza/rnfirebase-1893 contains a minimal reproduction of this issue.
The minimal repro is a react-native init
project with the recommended options from https://rnfirebase.io/docs/v5.x.x/installation/ios applied.
Additionally a package.json
postinstall script for fixing https://github.com/facebook/react-native/pull/23274/files and post_install
hook in the Podfile
for fixing https://github.com/invertase/react-native-firebase/issues/198 have been added.
The Podfile contains all React Native dependencies as well as !use_frameworks which is required for other dependencies that are not in this minimal repro.
The crash trace is:
2019-02-10 19:03:48.392880+0800 rnfirebaserepro[60231:385522] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[RNFirebaseNotifications configure]: unrecognized selector sent to class 0x103bb81a0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107c371bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000106320735 objc_exception_throw + 48
2 CoreFoundation 0x0000000107c55e44 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000107c3bed6 ___forwarding___ + 1446
4 CoreFoundation 0x0000000107c3dda8 _CF_forwarding_prep_0 + 120
5 rnfirebaserepro 0x00000001037f902f -[AppDelegate application:didFinishLaunchingWithOptions:] + 127
6 UIKitCore 0x000000010bb39bde -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 280
7 UIKitCore 0x000000010bb3b5cb -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3979
8 UIKitCore 0x000000010bb40c2f -[UIApplication _runWithMainScene:transitionContext:completion:] + 1623
9 UIKitCore 0x000000010b35f4e9 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 866
10 UIKitCore 0x000000010b36829c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
11 UIKitCore 0x000000010b35f126 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 233
12 UIKitCore 0x000000010b35fae0 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1085
13 UIKitCore 0x000000010b35dcb5 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 795
14 UIKitCore 0x000000010b35d95f -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 435
15 UIKitCore 0x000000010b362a90 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 584
16 UIKitCore 0x000000010b36380e _performActionsWithDelayForTransitionContext + 100
17 UIKitCore 0x000000010b3627ef -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 221
18 UIKitCore 0x000000010b36793a -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
19 UIKitCore 0x000000010bb3f44e -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 515
20 UIKitCore 0x000000010b6e3d09 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 357
21 FrontBoardServices 0x000000011257b2da -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
22 FrontBoardServices 0x0000000112586443 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 271
23 FrontBoardServices 0x0000000112585b3a __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
24 libdispatch.dylib 0x0000000109ec1602 _dispatch_client_callout + 8
25 libdispatch.dylib 0x0000000109ec4b78 _dispatch_block_invoke_direct + 301
26 FrontBoardServices 0x00000001125baba8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
27 FrontBoardServices 0x00000001125ba860 -[FBSSerialQueue _performNext] + 457
28 FrontBoardServices 0x00000001125bae40 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
29 CoreFoundation 0x0000000107b9c721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
30 CoreFoundation 0x0000000107b9bf93 __CFRunLoopDoSources0 + 243
31 CoreFoundation 0x0000000107b9663f __CFRunLoopRun + 1263
32 CoreFoundation 0x0000000107b95e11 CFRunLoopRunSpecific + 625
33 GraphicsServices 0x00000001102e91dd GSEventRunModal + 62
34 UIKitCore 0x000000010bb4281d UIApplicationMain + 140
35 rnfirebaserepro 0x00000001037f9490 main + 112
36 libdyld.dylib 0x0000000109f37575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
ios/Podfile
:# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'rnfirebaserepro' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
# Third party deps podspec link
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'
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # Needed for debugging
'RCTAnimation', # Needed for FlatList and animations running on native UI thread
'RCTActionSheet',
'RCTBlob',
'RCTGeolocation',
'RCTImage',
'RCTVibration',
'RCTSettings',
'RCTLinkingIOS',
'RCTPushNotification'
]
# Pods for rnfirebaserepro
pod 'Firebase/Core', '~> 5.15.0'
pod 'Firebase/Messaging', '~> 5.15.0'
pod 'GoogleAppMeasurement', '~> 5.4.0'
end
post_install do |installer|
system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")
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/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import "RNFirebaseNotifications.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
[FIRApp configure];
[RNFirebaseNotifications configure];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"rnfirebaserepro"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [UIColor blackColor];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
N/A
N/A
N/A
Version 10.1 (10B61)
e.g. Xcode 10, Android Studio 3.2React Native
version:0.58.4
React Native Firebase
library version:5.2.2
Firebase
module(s) you're using that has the issue:TypeScript
?N/A
ExpoKit
?ExpoKit
N/A
Think react-native-firebase
is great? Please consider supporting the project with any of the below:
React Native Firebase
and Invertase
on TwitterThis issue is directly related to use_frameworks!
. After removing that line, running pod update
and clean + build the crash does not occur anymore.
I resolved it on my end by reworking the other dependencies to modular_headers and no longer using use_frameworks!
.
Closing this use_frameworks!
just doesn't work for RNFirebase as far as I can tell. The only mention of that in the docs' is on a optional installation path that I didn't use:
``2) Don't have the use_frameworks! flag enabled```
https://rnfirebase.io/docs/v5.x.x/installation/ios
When following the recommended path for both Firebase and RNFirebase, you do not run into that piece of documentation. Maybe you could add it to the recommended path as well @Salakar ?
I've had the same issue when using the library along with Cocoapod dependencies which require the use_frameworks!
flag. Unfortunately I didn't have the possibility to fix build issues in the other dependencies when use_frameworks!
was disabled.
I was however able to fix this issue by copying the public headers from the FirebaseMessaging
pod to the Pods/Headers/Public
directory, along with the public headers for FirebaseCore
. So my Podfile
contains the following:
post_install do |installer|
require 'fileutils'
$podsDir = __dir__ + '/Pods'
$publicHeadersDir = $podsDir + '/Headers/Public'
FileUtils.cp_r(
$podsDir + '/FirebaseCore/Firebase/Core/Public',
$publicHeadersDir + '/FirebaseCore'
)
FileUtils.cp_r(
$podsDir + '/FirebaseMessaging/Firebase/Messaging/Public',
$publicHeadersDir + '/FirebaseMessaging'
)
end
Here I use a Ruby port of the script suggested in https://github.com/invertase/react-native-firebase/issues/1764#issuecomment-452178852 which works better when pod
is run outside of the ios/
directory, for example by running pod install --project-directory=ios/
.
This issue, and fix, seems to be related to how the RNFirebase
library is checking for available headers when deciding what to build into the library. Specifically, how RNFirebaseNotifications configure
is defined within an #if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
macro.
I've had the same issue when using the library along with Cocoapod dependencies which require the
use_frameworks!
flag. Unfortunately I didn't have the possibility to fix build issues in the other dependencies whenuse_frameworks!
was disabled.I was however able to fix this issue by copying the public headers from the
FirebaseMessaging
pod to thePods/Headers/Public
directory, along with the public headers forFirebaseCore
. So myPodfile
contains the following:post_install do |installer| require 'fileutils' $podsDir = __dir__ + '/Pods' $publicHeadersDir = $podsDir + '/Headers/Public' FileUtils.cp_r( $podsDir + '/FirebaseCore/Firebase/Core/Public', $publicHeadersDir + '/FirebaseCore' ) FileUtils.cp_r( $podsDir + '/FirebaseMessaging/Firebase/Messaging/Public', $publicHeadersDir + '/FirebaseMessaging' ) end
Here I use a Ruby port of the script suggested in #1764 (comment) which works better when
pod
is run outside of theios/
directory, for example by runningpod install --project-directory=ios/
.This issue, and fix, seems to be related to how the
RNFirebase
library is checking for available headers when deciding what to build into the library. Specifically, howRNFirebaseNotifications configure
is defined within an#if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
macro.
This answer works for me. Thanks so much, you saved my whole day.
Possibly worth noting that v5.x.x has a fix for use_frameworks so it should work now (will be released as 5.5.4, and in combination with this should get you working? https://github.com/mikehardy/rnfbdemo/blob/master/Podfile#L93
Possibly worth noting that v5.x.x has a fix for use_frameworks so it should work now (will be released as 5.5.4, and in combination with this should get you working? https://github.com/mikehardy/rnfbdemo/blob/master/Podfile#L93
Hi, thanks for the work for 5.5.4, but for me, simply adding this is not enough:
post_install do |installer|
system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")
end
I was able to run it on debug and release mode. But when I archived the app and installed it on physical devices, the app just crashed when I opened it. And via Console.app I got following error message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[RNFirebaseNotifications configure]: unrecognized selector sent to class 0x1007efe30'
*** First throw call stack:
(0x1b9d7a3a8 0x1b8f7fd00 0x1b9c97dc4 0x1b9d7fd54 0x1b9d81b50 0x100402f60 0x1e7043574 0x1e7044d44 0x1e704a764 0x1e68dce4c 0x1e68e5828 0x1e68dcab4 0x1e68dd3d0 0x1e68db618 0x1e68db2d4 0x1e68e0004 0x1e68e0e5c 0x1e68dfeb8 0x1e68e4ea8 0x1e7048ca0 0x1e6c2b408 0x1bc73bfd0 0x1bc74631c 0x1bc745a6c 0x1b9789884 0x1b978ce5c 0x1bc77918c 0x1bc778e08 0x1bc779404 0x1b9d0a444 0x1b9d0a3c0 0x1b9d09c7c 0x1b9d04950 0x1b9d04254 0x1bbf43d8c 0x1e704c4c0 0x100405bfc 0x1b97c0fd8)
@aeirola answer works for me. Weird.
Are you certain you tried from the unreleased version, that has a patch in the podspec for use_frameworks #2235
Are you certain you tried from the unreleased version, that has a patch in the podspec for use_frameworks #2235
Oh, sorry, I am using the 5.5.3
.
released 5.5.4 with use_frameworks support today!
Have been battling through the exact same issue as @Lohins all weekend, release and debug work fine but immediate crash on adhoc/distributed ipa's. @aeirola 's fix was the only thing that solved this, thank you so much!
Have replicated this on 5.5.5.
The fix Was reverted for 555 per the changelog so the workaround is needed again yed
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.
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.
I am still getting the same error and the fixes mentioned above does not work 馃槥
If you need use_frameworks support I think you must move to react-native 0.61 release candidates, react-native 0.60 doesn't work with it from what I understand
I do not have an use_frameworks in my pod file but I still get the same error
Hmm so I solved this by switching to new build system in xcode. Seems like building with legacy build system does not work.
@dusan-dragon how you did that?
I'm facing the same issue
EDIT: I can confirm that switching to the new build system in Xcode works
I'm having an issue right now with RNFirebaseNotifications it's throwing
No known class method for selector 'configure'
In the following line, within AppDelegate.m.
[RNFirebaseNotifications configure];
I'm using react-native-firebase 5.5.6
Then on pods, it's installing:
Installing Firebase 6.11.0 (was 6.7.0)
Installing FirebaseAnalytics 6.1.3 (was 6.1.1)
Installing FirebaseCore 6.3.2 (was 6.2.1)
Installing FirebaseCoreDiagnostics 1.1.1 (was 1.0.1)
Using FirebaseCoreDiagnosticsInterop (1.0.0)
Installing FirebaseInstanceID 4.2.6 (was 4.2.3)
I'm not using use_frameworks!
within my Podfile otherwise react-native-navigation fails on build.
I'm only using use_native_modules!
Any idea on how can I fix this?
Closed issue so I'm not sure. Those versions should work, but any time I see "No known class method for selector asdfasdf" I suspect corrupt Xcode caching and suggest npx react-native-clean-project
to clear things out followed by a rebuild to test. If it persists, open a new issue following the full template and we can look
I'm having an issue right now with RNFirebaseNotifications it's throwing
No known class method for selector 'configure'
In the following line, within AppDelegate.m.
[RNFirebaseNotifications configure];
I'm using react-native-firebase 5.5.6
Then on pods, it's installing:
Installing Firebase 6.11.0 (was 6.7.0) Installing FirebaseAnalytics 6.1.3 (was 6.1.1) Installing FirebaseCore 6.3.2 (was 6.2.1) Installing FirebaseCoreDiagnostics 1.1.1 (was 1.0.1) Using FirebaseCoreDiagnosticsInterop (1.0.0) Installing FirebaseInstanceID 4.2.6 (was 4.2.3)
I'm not using
use_frameworks!
within my Podfile otherwise react-native-navigation fails on build.
I'm only usinguse_native_modules!
Any idea on how can I fix this?
Did you find a solution? I'm stuck here as well when updating from react-native v0.59.* to v0.60.6
Most helpful comment
I've had the same issue when using the library along with Cocoapod dependencies which require the
use_frameworks!
flag. Unfortunately I didn't have the possibility to fix build issues in the other dependencies whenuse_frameworks!
was disabled.I was however able to fix this issue by copying the public headers from the
FirebaseMessaging
pod to thePods/Headers/Public
directory, along with the public headers forFirebaseCore
. So myPodfile
contains the following:Here I use a Ruby port of the script suggested in https://github.com/invertase/react-native-firebase/issues/1764#issuecomment-452178852 which works better when
pod
is run outside of theios/
directory, for example by runningpod install --project-directory=ios/
.This issue, and fix, seems to be related to how the
RNFirebase
library is checking for available headers when deciding what to build into the library. Specifically, howRNFirebaseNotifications configure
is defined within an#if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
macro.