一. ios版
1.在React Native项目的根目录下执行(前提需在ios中创建)
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle
2.配置APPDelegate
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"bundle/index.ios" withExtension:@"jsbundle"];
#endif
2.使用xcode打包
二, android 版
1.在android目录下创建bundle文件,将打包的文件放在bundle中
// 生成android 打包命令
react-native bundle --entry-file index.js --bundle-output ./android/bundle/index.android.jsbundle --platform android --assets-dest ./android/bundle --dev false