React-native-firebase: πŸ”₯ iOS app crashes only release build, in using Dynamic Links.

Created on 19 Jun 2019  Β·  20Comments  Β·  Source: invertase/react-native-firebase


Issue



I tried to use Dynamic Links in React Native Firebase, but in the release build of the iOS app only the app crashes immediately after launching.
I tried on a project that just used React Native Firebase just in case, but unfortunately I reproduced it as well.

Here is the minimal configuration reproduction repository I prepared.

Since I did not get information even after Google search, please tell me what's wrong. Thank you.
(Google Translation)


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

  # Pods for rnfirebasetest
  pod 'Firebase/Core', '~> 5.20.2'
  pod 'Firebase/DynamicLinks', '~> 5.20.2'

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

end

post_install do |installer|
  # This fixes the problems with headers not found
  system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")
end
The last line is here to help you fix the problem of missing header files at build time. #### `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 <Firebase.h>
#import "RNFirebaseLinks.h"

#import "AppDelegate.h"

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

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIROptions defaultOptions].deepLinkURLScheme = @"rnfirebasetest";
  [FIRApp configure];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"rnfirebasetest"
                                            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
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<NSString *, id> *)options {
  NSLog(@"hoge1: %s %@ %@", __PRETTY_FUNCTION__, url, options);
  return [[RNFirebaseLinks instance] application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application
continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler: (nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler {
  NSLog(@"hoge2: %s %@ %@", __PRETTY_FUNCTION__, userActivity, restorationHandler);
  return [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}

@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.5
      CPU: (4) x64 Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz
      Memory: 1.14 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.0 - ~/.nodebrew/current/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.9.0 - ~/.nodebrew/current/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: 28
        Build Tools: 28.0.3
        System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5314842
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.9 => 0.59.9 
- **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [x] **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:** - `Dynamic Links` - **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]

Crash iOS Links Stale

All 20 comments

You can use Console.app on the mac to watch the logs of a device running the build in release mode if you want, or I think you can run release mode on a simulator as well. There should be a stack trace. You should be careful on your repo posting your google firebase plist/json files as well, hopefully those are on the free plan and semi-disposable...

If you find the stack trace running it under xcode on sim or via console form a usb-connected device paste it in - that will be the fastest thing

hi @mikehardy
Oops, GoogleService-Info.plist has deleted its contents. (Fortunately, that account is a free plan.)
And thank you. Later I get the log and paste it here.

The stack trace of the application executed on iPhone 8 was acquired in Console.app. A screenshot of the lower part of this app's process and the last two lines of logs.
Please let me know if you have any other information you need.

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2019-06-19 14 34 10

+[RNFirebaseLinks instance]: unrecognized selector sent to class 0x1009e1360

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[RNFirebaseLinks instance]: unrecognized selector sent to class 0x1009e1360'
*** First throw call stack:
(0x18d06d27c 0x18c2479f8 0x18cf8eb04 0x18d072ac4 0x18d07475c 0x100743f24 0x100a36dac 0x1007640b4 0x100764228 0x10075e288 0x10075dbc0 0x18caaca38 0x18caad7d4 0x18ca8d9e4 0x18cffec1c 0x18cff9b54 0x18cff90b0 0x18f1f979c 0x1b9973978 0x1007440f0 0x18cabe8e0)

It's crashing in your AppDelegate.m - that's odd. Are you certain you have followed all the other steps (all the apple registration, plist stuff)? Also, I think based only on the sample code https://rnfirebase.io/docs/v5.x.x/links/ios about deeplinks that you need to use react-native linking for deeplinks? I apologize I don't have more experience in the area - I haven't implemented it yet in my app so I'm learning with you.

Yes, I did the installation following the steps in React Native Firebase. The app crashes for an unknown reason, so about 3 times from the beginning!

Note: When I checked the Firebase Pod module yesterday, it was v5.20.2.

  1. $ react-native init rnfirebasetest
  2. https://rnfirebase.io/docs/v5.x.x/installation/initial-setup

    • $ yarn add react-native-firebase

    • create Firebase project in web console



      • However, my app has not been published to the store yet.



  3. https://rnfirebase.io/docs/v5.x.x/installation/ios

    • Download and add GoogleService-Info.plist to Xcode project.

    • Append #import <Firebase.h> and [FIRApp configure]; to AppDelegate.m

    • $ pod init and edit Podfile, and then $ pod install

    • open *.xcworkspace

    • $ react-native link react-native-firebase

  4. https://rnfirebase.io/docs/v5.x.x/links/ios

    • Add pod 'Firebase/DynamicLinks', '~> 5.20.0' to Podfile, and then $ pod update
    • Enter "Associated Domains" in "Capabilities" tab, "Identifier" field in "Info" tab of Xcode.

      • Of course, I am using a certificate with "Associated Domains" enabled.

    • Add these codes to the appropriate place in AppDelegate.m.
    #import "RNFirebaseLinks.h"
    

    ```
    [FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;

    
    
  5. build and run, then app is crash.

Is there anything missing from this procedure? Should I try it with v6.2.0 modules?

re: versions, yes I just released v5.5.0 with fully up to date iOS SDK support. It's a breaking change but not a hard one to deal with if you look at the notes. You can try with v6.2.0 but I will be shocked if it alters your results, I don't believe anything much changed in DynamicLinks. I would not change it, though if you do make sure to clean out ios/build after the pod install

you may also need to change the app plist to register the rnfirebasetest URL scheme I think? And in firebase console register it, and in apple entitlements etc etc. Have you tried it with react-native links? there was a code snippet in the docs that tried react-native links first then fell back to firebase?

Thank you. I will not try v6.2.0 for the time being.

Sadly, I am not familiar with iOS development and Firebase, and I am not good at English. 😒
Let me ask you questions one by one.

  • plist and firebase console

    • Do you mean by these screen shots?
      γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2019-06-19 16 27 33

      γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2019-06-19 16 27 41

  • apple entitlements

    • What does this mean? Do I need to do anything from the Apple Developer Program website?
  • react-native links

    • Does this point to the react-native link react-native-firebase command? Or is it React Native Linking?
      If the latter, I have already tried by typing the URL directly into the safari URL bar.

@cat12079801 , @mikehardy
I am facing the same issue. Our iOS app get crashed in release mode, and works fine in debug mode. So any workaround for this?

I'm still facing this problem...
Anyone have a solution?

I'm still facing this problem...
Anyone have a solution?

No, @cat12079801 . I am also facing the same. Having the tread over here.

In some cases, commenting out the Podfile use_frameworks! May prevent the app from crashing even in a release build.
I will check back later.

I have other libraries in pod file as well, which requires use_frameworks!. So I can't comment it out.

@cat12079801 ,

I have changed implementation of 2 AppDelegate methods and now I am not having crash.
I changed to the...

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

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
  return [RCTLinkingManager application:application
                   continueUserActivity:userActivity
                     restorationHandler:restorationHandler];
}

Which was before

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  BOOL handled = [[RNFirebaseLinks instance]
                  application:application
                  openURL:url
                  options:options
                  ] || [RCTLinkingManager
                        application:application
                        openURL:url
                        options:options
                        ];

  return handled;
  }

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  BOOL handled = [RCTLinkingManager
                  application:application
                  openURL:url
                  sourceApplication:sourceApplication
                  annotation:annotation
                  ];
  return handled;
}

Looks like you just removed the react native firebase functionality and are using the react native only functionality? I could see that avoiding a crash but it seems like a temporary solution only unless I misunderstood

Looks like you just removed the react native firebase functionality and are using the react native only functionality? I could see that avoiding a crash but it seems like a temporary solution only unless I misunderstood

Oh, Actually I tried to click on the link and it's opening properly. As it was giving exception on [RNFirebaseLinks instance]: unrecognized selector sent to class 0x1009e1360

@mikehardy , Do you suggest any other alternative?

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.

same here.

Wow! Thanks a lot! XD

Was this page helpful?
0 / 5 - 0 ratings