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"];








网友评论