Sal*_*Sal 1 reactjs reactjs-native
在尝试构建ios客户端时react-native,我修改了部分AppDelegate.m文件,如下所示(即,用选项2替换选项1):
// OPTION 1
// Load from development server. Start the server from the repository root:
//
// $ npm start
//
// To run on device, change `localhost` to the IP address of your computer, and make sure your computer and
// iOS device are on the same Wi-Fi network.
//jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
// OPTION 2
// Load from pre-bundled file on disk. To re-generate the static bundle, run
//
// $ curl http://localhost:8081/index.ios.bundle -o main.jsbundle
//
// and uncomment the next following line
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Run Code Online (Sandbox Code Playgroud)
我下载main.jsbundle到iOS文件夹所在的AppDelegate.m位置.
$ ls iOS
AppDelegate.h Base.lproj Info.plist main.m
AppDelegate.m Images.xcassets main.jsbundle
Run Code Online (Sandbox Code Playgroud)
但是,如果我在XCode中再次进行构建并运行它ios simulator,它会暂停main.m以下错误:
2015-03-31 12:46:28.877 AwesomeProject [26849:1320518] *断言失败 - [RCTRootView initWithBundleURL:moduleName:launchOptions:],/ Users/yourname/scripts/code/startup/reactnative/AwesomeProject/node_modules/react- native/React/Base/RCTRootView.m:82 2015-03-31 12:46:28.883 AwesomeProject [26849:1320518]*由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'创建RCTRootView需要一个bundleURL'
所以,它似乎在抱怨bundleURL.我将非常感谢帮助确定问题所在.
您需要将该文件添加到项目中.为此,您需要右键单击项目名称并选择"将文件添加到MyProject ...".然后选择main.jsbundle.
然后构建您的项目,它应该工作.
请参阅:如何为iPhone构建React Native App?