A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.[ios, xcode]

19,748

Solution 1

The issue here is with the name you are using for your app

Invariant Violation: "RestApp" has not been registered. This can happen if:

    Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
    A module failed to load due to an error and AppRegistry.registerComponent wasn't called.

your index file is using the appName from app.json name field to register your component, which in your case is "name": "restapphhopp"

change your moduleName in ios AppDelegate.m file to restapphhopp

moduleName:@"restapphhopp"

Solution 2

recheck your name is same in app.json and in strings.jsx file

Solution 3

Name in the app.json should be the same as the name in package.json

Share:
19,748
HardRock
Author by

HardRock

Hello

Updated on July 11, 2022

Comments

  • HardRock
    HardRock almost 2 years

    I have android and ios app in react native which both uses webview to show webpage as application. Since I had to change package name to deploy it on google play since first one package name was occupied. I changed app.json file and all names in android folder and that's ok.

    Now my question is what I need to change in my ios folder in order to my app work in xcode. I have this error.

    Invariant Violation: "RestApp" has not been registered. This can happen if:

    • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
    • A module failed to load due to an error and AppRegistry.registerComponent wasn't called.

    This is my app.json file

    {
      "name": "restapphhopp",
      "displayName": "RestApphhopp"
    }
    

    Index.js file

    /**
     * @format
     */
    
    import {AppRegistry} from 'react-native';
    import App from './App';
    import {name as appName} from './app.json';
    
    AppRegistry.registerComponent(appName, () => App);