一. ios版
1.在React Native項目的根目錄下執(zhí)行(前提需在ios中創(chuàng)建)
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目錄下創(chuàng)建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