React-native-navigation: [V2][iOS] App crashes in release mode on or around launch: Application has not been registered

Created on 17 Oct 2018  ·  17Comments  ·  Source: wix/react-native-navigation

Issue Description

Attempting to run an iOS build in release mode results in app crashing due to unhandled JS exception (see below) on or around app launch. Builds in debug mode intermittently have this error, but can be resolved by reloading the JS bundle, which can't be done in release mode.

Error suggestion to kill redundant packager instances were tried and did not solve issue, which leads me to believe it's due to the other reasons listed (a require() error during initialization or failure to call AppRegistry.registerComponent).

Error

Fatal Exception: RCTFatalException: Unhandled JS Exception: Application [Name] has not been registered. Hint: This error often happens when you're running the packager (local dev server) from a wrong folder. For example you have multiple apps and the packager is still running for the app you were working on before. If this is the case, simply kill the old packager instance (e.g. close the packager terminal window) and start the packager in the correct app folder (e.g. cd into app folder and run 'npm start'). This error can also happen due to a require() error during initialization or failure to call AppRegistry.registerComponent.

Steps to Reproduce / Code Snippets / Screenshots

/index.js:

import { Navigation } from 'react-native-navigation'
import TestScreen from './src/screens/TestScreen'

Navigation.registerComponent('hoot.testScreen', () => TestScreen);

Navigation.events().registerAppLaunchedListener(async ()=> {
  Navigation.setRoot({
    root: {
      component: {
        name: 'hoot.testScreen'
      }
    }
  });
})

/src/screens/TestScreen.js

import React, { Component } from 'react'
import { View, Text } from 'react-native'

export class TestScreen extends Component {
  render() {
    return(
      <View>
        <Text>Test Screen!</Text>
      </View>
    )
  }
}

export default TestScreen

Environment

[email protected]
[email protected]
iOS only, building in release mode only
Failed on Devices iPhone SE, iPhone 6S (12.0)
Failed on Simulator iPhone X (12.0)
Xcode version 10.0

more info needed

Most helpful comment

Found this issue! When installing RNN I hadn't removed the extra code in AppDelegate.m in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... }

Removing the original React Native code and only keeping the code specified in your docs did the trick. I think at the time it was unclear from the docs whether to simply add the extra code or to entirely replace it.

Thank you for all your hard work on this great and much-needed tool.

All 17 comments

I am having the same problem. =(

We've never encountered this error, perhaps it's specific to RN 0.55, which we don't use at Wix. If you upgrade the playground app to RN 0.55 and run e2e, does it reproduce?

@guyca I'm new to your e2e framework, Detox. I followed the instructions for getting the detox cli tools and tried running npm test test-e2e-ios from root, but it looks like the tests are failing because it can't run detox build-framework-cache successfully. This may be an environment issue on my part. Could you provide more specific instructions on how to run your e2e tests?

Perhaps you need to update some xcode related tools. Try to open xcode and see if an update message pops up. If that doesn't work please open a stack overflow question and I'll ask one of the developers to assist.

@echappen did you find a solution for this one?

Guys I think the solution is to PR a failing/flaky detox test. Without some form of reproduction there's not much we can do. Furthermore, when reporting crashes - a crash log would help a lot.

@guyca Thanks for checking in. I had updated everything in xcode and followed these instructions but when running npm run test-e2e-ios all of the tests fail with the follow error:

/Users/eleni/Library/Detox/ios/d21e7a1ba19c8a97d6b6e01180c2a22e3727c460/Detox.framework could not be found, this means either you changed a version of Xcode or Detox postinstall script was unsuccessful.
          To attempt a fix try running 'detox clean-framework-cache && detox build-framework-cache'

I am not able to run detox build-framework-cache successfully and get this error log when I run it:

Error: Command failed: /Users/eleni/react-native-navigation/node_modules/detox/scripts/build_framework.ios.sh
    at checkExecSyncError (child_process.js:601:13)
    at Object.execSync (child_process.js:641:13)
    at Object.<anonymous> (/Users/eleni/react-native-navigation/node_modules/detox/local-cli/detox-build-framework-cache.js:6:4)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)

Is npm run test-e2e-ios the script I should be running?

Yes, npm run test-e2e-ios is what you should run. @LeoNatan can you please assist us with Detox setup?

@echappen Could you please post the log output from running detox build-framework-cache?

Before running, delete the ~/Library/Detox folder. Then run detox build-framework-cache.

@LeoNatan deleted ~/Library/Detox then ran:

$> detox build-framework-cache
+++ dirname /Users/eleni/react-native-navigation/node_modules/detox/scripts/build_framework.ios.sh
++ dirname /Users/eleni/react-native-navigation/node_modules/detox/scripts
+ detoxRootPath=/Users/eleni/react-native-navigation/node_modules/detox
++ node -p 'require('\''/Users/eleni/react-native-navigation/node_modules/detox/package.json'\'').version'
+ detoxVersion=8.1.6
++ echo 8.1.6
++ xcodebuild -version
++ shasum
++ awk '{print $1}'
+ sha1=d21e7a1ba19c8a97d6b6e01180c2a22e3727c460
+ detoxFrameworkDirPath=/Users/eleni/Library/Detox/ios/d21e7a1ba19c8a97d6b6e01180c2a22e3727c460
+ detoxFrameworkPath=/Users/eleni/Library/Detox/ios/d21e7a1ba19c8a97d6b6e01180c2a22e3727c460/Detox.framework
+ main
+ '[' -d /Users/eleni/Library/Detox/ios/d21e7a1ba19c8a97d6b6e01180c2a22e3727c460 ']'
+ prepareAndBuildFramework
+ '[' -d /Users/eleni/react-native-navigation/node_modules/detox/ios ']'
+ detoxSourcePath=/Users/eleni/react-native-navigation/node_modules/detox/ios_src
+ extractSources /Users/eleni/react-native-navigation/node_modules/detox/ios_src
+ detoxSourcePath=/Users/eleni/react-native-navigation/node_modules/detox/ios_src
+ echo 'Extracting Detox sources...'
+ mkdir -p /Users/eleni/react-native-navigation/node_modules/detox/ios_src
Extracting Detox sources...
+ tar -xjf /Users/eleni/react-native-navigation/node_modules/detox/Detox-ios-src.tbz -C /Users/eleni/react-native-navigation/node_modules/detox/ios_src
+ buildFramework /Users/eleni/react-native-navigation/node_modules/detox/ios_src
+ detoxSourcePath=/Users/eleni/react-native-navigation/node_modules/detox/ios_src
+ echo 'Building Detox.framework from /Users/eleni/react-native-navigation/node_modules/detox/ios_src...'
Building Detox.framework from /Users/eleni/react-native-navigation/node_modules/detox/ios_src...
+ mkdir -p /Users/eleni/Library/Detox/ios/d21e7a1ba19c8a97d6b6e01180c2a22e3727c460
+ /Users/eleni/react-native-navigation/node_modules/detox/scripts/build_universal_framework.sh /Users/eleni/react-native-navigation/node_modules/detox/ios_src/Detox.xcodeproj /Users/eleni/Library/Detox/ios/d21e7a1ba19c8a97d6b6e01180c2a22e3727c460/DetoxBuild
child_process.js:644
    throw err;
    ^

Error: Command failed: /Users/eleni/react-native-navigation/node_modules/detox/scripts/build_framework.ios.sh
    at checkExecSyncError (child_process.js:601:13)
    at Object.execSync (child_process.js:641:13)
    at Object.<anonymous> (/Users/eleni/react-native-navigation/node_modules/detox/local-cli/detox-build-framework-cache.js:6:4)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)

@echappen Under ~/Library/Detox/ there should be a folder with random letters (only one), and inside, there should be detox_ios.log. Please post the output in that file here.

@LeoNatan The detox_ios.log file was quite large so I put it in a public GistL https://gist.github.com/echappen/a33ca8e0915b027c8d25f5c41b4b8782

@echappen This is not the full log. Please reupload the file fully.

Hmm, I see you are using Xcode 10, but at this time RNN uses a very old version of Detox. Three is little I can do to help here. @guyca Please update Detox to a modern version, where Xcode 10 is supported. In the meantime, @echappen you can use Xcode 9.

Found this issue! When installing RNN I hadn't removed the extra code in AppDelegate.m in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... }

Removing the original React Native code and only keeping the code specified in your docs did the trick. I think at the time it was unclear from the docs whether to simply add the extra code or to entirely replace it.

Thank you for all your hard work on this great and much-needed tool.

Glad you managed to sort it out 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Chipped1 picture Chipped1  ·  3Comments

edcs picture edcs  ·  3Comments

charlesluo2014 picture charlesluo2014  ·  3Comments

yedidyak picture yedidyak  ·  3Comments

kiroukou picture kiroukou  ·  3Comments