react-native ios打包教程
阿新 • • 發佈:2019-01-25
1.找到專案裡的ios資料夾,在此資料夾下新建一個資料夾取名bundle
2.開啟終端,cd到專案的根目錄
3.執行命令,react-native bundle --entry-file ./index.ios.js --bundle-output ./ios/bundle/index.ios.jsbundle --platform ios --assets-dest ./ios/bundle --dev false
4.
執行完成後,開啟第一步建立的bundle資料夾,可以看到
5.
用Xcode開啟專案,選中跟專案同名的那個資料夾,右鍵,選中‘Add Files to ..’選項,然後選擇新建的那個bundle資料夾
6.在AppDelegate.m中的寫上載入包的方式
#ifdef DEBUG
//開發包
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
//離線包
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"bundle/index.ios" withExtension:@"jsbundle"];
#endif
7.通過Xcode-->Product-->Scheme-->Edit Scheme.的步驟,改成release的狀態
8.剩下的步驟就和打包原生iOS一樣了,可百度