美文网首页
RN最新打离线包

RN最新打离线包

作者: 没技术的BUG开发攻城狮 | 来源:发表于2018-07-17 11:44 被阅读146次

1.打开终端 cd至项目根目录下

2.执行命令:

react-native bundle --entry-file index.js --bundle-output ~/temp/main.jsbundle --platform ios --assets-dest ~/temp --dev false

也可将此命令在package.json中设置:

"scripts": {    "iosbundle": "react-native bundle --entry-file index.js --bundle-output ~/temp/main.jsbundle --platform ios --assets-dest ~/temp --dev false ",} 

终端执行 npm run iosbundle 即可等同于👆

3.打开Xcode-右键Add Files To "项目名".   将生成的main.jsbundle导入至native中。

4.修改AppDelegate.m —> didFinishLaunchingWithOptions: 中代码

模拟器调试用

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

真机用👇

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

相关文章

网友评论

      本文标题:RN最新打离线包

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