美文网首页RN iOS开发相关
[React Native]main.jsbundle生成方法

[React Native]main.jsbundle生成方法

作者: 共田君 | 来源:发表于2016-03-03 16:40 被阅读1388次

** KICCP Blog
原文 http://blog.kiccp.com/2152.html
主题 React Native

最近在玩React Native,刚开始是在模拟器里运行,后想把它装到真机上,这时localhost上的jsbundle就无法访问了。
这种情况下可以使用main.jsbundle。
步骤:

1.在React Native项目根目录下运行 npm start
2.使用curl命令生成 main.jsbundle
curl http://localhost:8081/index.ios.bundle -o main.jsbundle
3.在AppDelegate.m中选择使用main.jsbundle注释掉
jsCodeLocation = [NSURL URLWithString: @"http://localhost:8081/index.ios.bundle?platform=ios&dev=true "];
取消注释下面这一行
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
4.将真机联上电脑,选择信任,然后在Xcode中选择使用其进行调试,等待编译完成即可运行!

相关文章

网友评论

本文标题:[React Native]main.jsbundle生成方法

本文链接:https://www.haomeiwen.com/subject/qqfokttx.html