`

生成jsbundle文件,打本地包

 
阅读更多
初始化react-native项目
react-native init <project name>
 
运行bundle服务
react-native start
 
生成bundle文件 - ios
react-native bundle --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios --assets-dest ./ios --dev false
 生成bundle文件 - android
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ 

 

android:

进行代码和资源文件打包,生成的带有签名的apk还是在上面的目录中。

cd android && ./gradlew assembleRelease
运行下而后命令,安装apk
cd android && ./gradlew installRelease
 
 
ios项目,修改AppDelegate.m文件(使用main...jsbundle这句,注释掉localhost:8081.....这句):

//  jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

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

 

 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics