1)检查index.js并确保yourAppName已注册,而不是main
:
app.json
根文件夹中的文件:
{
"name": "TestSvgJoy",
"displayName": "TestSvgJoy"
}
index.js
(从根文件夹,如果你没有它,你需要更新 Xcode 中的构建脚本,如下所示)
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
这是应用程序在 Xcode 中的外观:
2)
AppDelegate.m 应该有 2 行,如下所示
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
注意:如果您使用的是 Expo 并且应用程序未分离,您可以忽略此步骤。
3) 确保您的根文件夹包含index.js 或index.ios.js。
笔记:
如果您需要自定义路径entryFile
(index.js
or index.ios.js
) go to Xcode, project target, Build Phases, Bundle ReactNative code and images
并提供一个额外的参数,例如./src/index.ios.js
To test things quickly and get more info about the errors go to Xcode, Product, Scheme, Edit Scheme, Run, Build Configuration
and set it to Release
and run it on the simulator.