Skip to content

🔥[iOS] _reactNativeFirebase.default.crashlytics().log is not a function #2544

@svenlombaert

Description

@svenlombaert

Issue

I'm upgrading Crashlytics to the latest version. Everything works fine on Android, so that's good. On iOS I get logs that Crashlytics is initialising and I can set the userIdentifier without any problems.

default	11:49:50.702436 +0200	Delta	[Crashlytics] Version 3.13.2 (141)
default	11:49:50.734957 +0200	Delta	[C1 settings.crashlytics.com:443 tcp, url hash: c18792fa, tls] start
default	11:49:51.348568 +0200	Delta	[C1 settings.crashlytics.com:443 tcp, url hash: c18792fa, tls] cancel
default	11:49:51.348777 +0200	Delta	[C1 settings.crashlytics.com:443 tcp, url hash: c18792fa, tls] cancelled
	[C1.1 1F0EB24A-B9F4-425B-AFE3-6DBEFB697E3A 192.168.0.183:56926<->54.243.225.100:443]
	Connected Path: satisfied (Path is satisfied), interface: en0
	Duration: 0.613s, DNS @0.002s took 0.020s, TCP @0.025s took 0.212s, TLS took 0.253s
	bytes in/out: 6520/1599, packets in/out: 8/3, rtt: 0.101s, retransmitted packets: 0, out-of-order packets: 0
default	11:49:51.348832 +0200	Delta	0.000s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] path:start
default	11:49:51.348872 +0200	Delta	0.000s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] path:satisfied
default	11:49:51.348908 +0200	Delta	0.002s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] resolver:start_dns
default	11:49:51.348942 +0200	Delta	0.022s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] resolver:receive_dns
default	11:49:51.349954 +0200	Delta	0.237s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] flow:finish_transport
default	11:49:51.350471 +0200	Delta	0.490s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] flow:finish_connect
default	11:49:51.350948 +0200	Delta	0.490s [C1 96679564-9808-469D-8D49-95B18D48CABD settings.crashlytics.com:443 resolver] flow:changed_viability

When I try to log something though, I run into this error:

_reactNativeFirebase.default.crashlytics().log is not a function. (In '_reactNativeFirebase.default.crashlytics().log("We're about to force a crash")', '_reactNativeFirebase.default.crashlytics().log' is an instance of Object)

So, next thing I did was logging the crashlytics().log function, and this, weirdly enough, showed that log() is an object with 4 functions inside:

'crashlytics().log: ', { debug: [Function: debug],
  info: [Function: info],
  warn: [Function: warn],
  error: [Function: error] }

I then started logging other functions like recordError and recordCustomError, but they all seem to be fine.


Project Files

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • 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'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

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

  # Pods for Delta
  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-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-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
  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'

  pod 'RNRootViewBackground', :path => '../node_modules/react-native-root-view-background'

  pod 'Fabric', '1.10.2'
  pod 'Crashlytics', '3.13.2'

  pod 'FBSDKCoreKit', '4.31.1'
  pod 'FBSDKLoginKit', '4.31.1'
  pod 'FBSDKShareKit', '4.31.1'

  pod 'Firebase/Core', '~> 6.7.0'
  pod 'Firebase/Analytics', '~> 6.7.0'
  pod 'Firebase/Messaging', '~> 6.7.0'
  pod 'Firebase/Performance', '~> 6.7.0'

  use_native_modules!
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 <CodePush/CodePush.h>

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#if __has_include(<React/RNSentry.h>)
#import <React/RNSentry.h> // This is used for versions of react >= 0.40
#else
#import "RNSentry.h" // This is used for versions of react < 0.40
#endif
#import <Firebase.h>
#import <RNFirebaseNotifications.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <Orientation.h>
#import "RNSplashScreen.h"

@implementation AppDelegate

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
  return [Orientation getOrientation];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURLCache.sharedURLCache = [[NSURLCache alloc] initWithMemoryCapacity: 8 * 1024 * 1024 diskCapacity: 60 * 1024 * 1024 diskPath: nil];

#if defined(DEBUG) && DEBUG
  NSString *firebaseConfig = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-Debug" ofType:@"plist"];
#else
  // This file is generated by a script
  NSString *firebaseConfig = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
#endif

  FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebaseConfig];

  if (options == nil) {
    [FIRApp configure];
  } else {
    [FIRApp configureWithOptions:options];
  }

  [RNFirebaseNotifications configure];

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                               moduleName:@"Delta"
                                               initialProperties:nil];

  // Default root view color
  rootView.backgroundColor = [UIColor colorWithRed:0.20 green:0.25 blue:0.33 alpha:1.0];

  [RNSentry installWithRootView:rootView];

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

  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];

  [RNSplashScreen show];
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
  #if DEBUG
    // jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  #else
    // jsCodeLocation = [CodePush bundleURL];
    return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:application openURL:url options:options];
}

// For iOS 8.0 or older
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}

//You can skip this method if you don't want to use local notification
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

@end


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:

// 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:

System:
    OS: macOS 10.14.4
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 1.30 GB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.12.0 - /usr/local/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.11.2 - /usr/local/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
    Android SDK:
      API Levels: 23, 25, 26, 28
      Build Tools: 23.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3
  IDEs:
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: ^0.60.5 => 0.60.5
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native-reanimated: 1.0.0
    react-native-sensors: 4.0.0
    react-native-store-review: 0.1.5
  • 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.6
  • Firebase module(s) you're using that has the issue:
    • Crashlytics
  • 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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions