如何为 iPhone 构建 React Native App?

How to build React Native App for iPhone?

在 iPhone 模拟器上一切正常。为 iPhone 构建应用程序时出现错误:

A bundleURL is required to create an RCTRootView

AppDelegate.m 中,我取消注释以下行;

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

并将预构建 main.jsbundle 下载到项目根目录中的 iOS 文件夹:

curl http://localhost:8081/index.ios.bundle -o main.jsbundle

我忘了将文件添加到项目中。

您需要右击项目名称和select"Add files to MyProject…"。然后选择main.jsbundle。构建项目,它应该可以工作。