美文网首页
React Native打包

React Native打包

作者: wg刚 | 来源:发表于2019-07-18 16:13 被阅读0次

iOS打包

1、在项目的ios目录下新建bundle文件夹
2、将打包命令配置在package.json中:在scripts下添加bundle-ios命令

例如:

"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"bundle-ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle"
},

3、cd到项目根目录。运行npm run bundle-ios
4、会在ios目录下bundle文件夹下生成离线资源

例如


5、添加bundle添加到xcode中
6、修改Appdelegate.m文件,(在新版本上,这一步已经配置好了)

//debug
[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
//release
[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

7、通过xcode直接正常打包即可

相关文章

网友评论

      本文标题:React Native打包

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