Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
like image 593
HardRock Avatar asked Oct 02 '20 06:10

HardRock


3 Answers

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"
like image 161
Hassan1319 Avatar answered Oct 17 '22 08:10

Hassan1319


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

like image 4
usmanjutt Avatar answered Oct 17 '22 08:10

usmanjutt


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

like image 3
Ahmed Raza Avatar answered Oct 17 '22 10:10

Ahmed Raza