Generating Signed IPA - iOS
在打包前,請確認 開發/發布 憑證已搞定
打包步驟
1.導出js bundle(create a bundle)
在project(專案目錄)/ 下指令
$ react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
2.設定Build Configuration為Release
(Xcode選單)Product → Scheme → Edit Scheme (cmd + <)
確保左側是選擇到 Run,如下圖

3.修改 AppDelegate.m 內的 jsCodeLocation
在AppDelegate.m內
註解下方這段
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
加上這段
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle”];
如下圖

4.Archive 4-1. 將選擇機器的部分選成 Generic iOS Device(如下圖)

4-2. (Xcode選單)Product > Archive (我習慣會先Clean)

5.成功後會跳出視窗,如下圖

6.匯出 .ipa
可點擊上一步驟視窗內右上角的 Export 即可
ps.
新增udid後,修改證書,並且下載證書後 左鍵雙擊該證書 匯入Xcode。 之後新增的udid還是無法安裝! 請依照以下步驟
到證書(Mac)存放位於 /Users/XXXXX/Library/MobileDevice/Provisioning Profiles 把證書刪光(會怕的話請先備份) > 左鍵雙擊證書 匯入Xcode > 重啟Xcode > 再次Archive即可 ps.不確定是否匯入證書後重啟Xcode ,是否就可行
或者也可寫成下方這樣
#ifdef DEBUG NSLog(@"........Debug For Developer(USB Connect)......."); jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; #else NSLog(@"........Rlease For Archive......."); jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif
參考
Last updated