React-Native 打包iOS HOC

打包步驟以下: 1.打開terminal終端->cd 項目更目錄 2.項目根目錄/ios/手動建立(bundle)文件 3.在終端輸入以下命令:react

(index.ios.jsbundle能夠自行修改)

     react-native bundle --entry-file index.js --bundle-output ./ios/bundle/index.ios.jsbundle --platform ios --assets-dest ./ios/bundle --dev false

參考地址: https://www.jianshu.com/p/5a71437c3678

完成後以下圖:
複製代碼

4.在xcode項目中引入bundle文件 一、將assets 和 index.ios.jsbundl 文件引入到xcode工.以下圖:

注意: assets 目錄導入工程中時,要選擇 Create folder references,由於這是圖片素材

5.修改Appdelegate中的配置代碼
   
    #if DEBUG
        jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
    #else
         jsCodeLocation = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"index.ios.jsbundle" ofType:nil]];
    #endif
複製代碼

六、選擇Xcode設置導航,配置證書;如圖:ios

hoc證書參考: www.jb51.net/article/101…

注意react-native

build 選擇Edit Scheme時選擇debug/release版本進行測試打包xcode

遇到的問題: 1. ide

解決方案:Xcode->file->WorkSpace settings...在彈出框中選擇Legacy Build System,最後選擇Done便可測試

二、錯誤2. ui

解決方案以下: 將項目/ios/build文件夾刪除便可

自此發佈測試包,正式包,只需修改證書就好。spa

相關文章
相關標籤/搜索