由于错误,模块无法加载,并且未调用`AppRegistry.registerComponent`。[ios, xcode]

Har*_*ock 5 xcode ios react-native

我在 react native 中有 android 和 ios 应用程序,它们都使用 webview 将网页显示为应用程序。由于我不得不更改包名称以将其部署在 google play 上,因为第一个包名称已被占用。我更改了 app.json 文件和 android 文件夹中的所有名称,没关系。

现在我的问题是我需要在我的 ios 文件夹中更改什么才能让我的应用程序在 xcode 中工作。我有这个错误。

不变违规:“RestApp”尚未注册。在以下情况下可能会发生这种情况:

  • Metro(本地开发服务器)从错误的文件夹运行。检查 Metro 是否正在运行,将其停止并在当前项目中重新启动。
  • 模块因错误而AppRegistry.registerComponent无法加载且未被调用。

这是我的 app.json 文件

{
  "name": "restapphhopp",
  "displayName": "RestApphhopp"
}
Run Code Online (Sandbox Code Playgroud)

Index.js 文件

/**
 * @format
 */

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);
Run Code Online (Sandbox Code Playgroud)

小智 12

app.json 中的名称应与 package.json 中的名称相同


小智 11

这里的问题在于您为应用程序使用的名称

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.
Run Code Online (Sandbox Code Playgroud)

您的索引文件正在使用app.json名称字段中的appName来注册您的组件,在您的情况下为"name": "restapphhopp"

将ios AppDelegate.m 文件中的moduleName更改为restapphhopp

moduleName:@"restapphhopp"
Run Code Online (Sandbox Code Playgroud)

  • 世博会呢? (8认同)

小智 5

重新检查 app.json 和 strings.jsx 文件中的名称是否相同