[英]How to build .ipa for React Native?
首先,您需要以這種方式創建一個包:
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
然后,您必須在 AppDelegate.m 中注釋此行:
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
並取消注釋這個:
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
然后你必須在 Xcode 中選擇 Product -> Archive 並根據你想要的版本按照步驟操作
您必須將 Scheme 設置為 Release。
從文檔中,您有兩種方法。
為此,請轉到 Product → Scheme → Edit Scheme (cmd + <),確保您位於側面的 Run 選項卡中,並將 Build Configuration 下拉列表設置為 Release。
或者
您還可以使用 React Native CLI 使用選項 --configuration 和 Release 值來執行此操作(例如 react-native run-ios --configuration Release)。
然后你可以像往常一樣生成你的檔案。
https://facebook.github.io/react-native/docs/running-on-device.html#building-your-app-for-production
我無法對上述答案發表評論,這是正確的,但您需要從以下命令開始才能使其正常工作:
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
區別在於“ios”而不是“iOS”
如果不是,它會給出以下錯誤:
ProjectPath/node_modules/promise/lib/done.js:10
throw err;
^
IOS
使用根文件夾中的以下簡單命令,使用 Xcode 打開 iOS 項目。
xed ./ios
現在將以下命令粘貼到終端中
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
像這樣從 Xcode 編輯方案:
產品 -> 方案 -> 編輯方案
編輯方案發布
現在您有了一個獨立的 Xcode 項目,並准備像原生 Xcode 項目一樣構建/發布。
來自: https : //medium.com/better-programming/create-ipa-and-apk-from-react-native-72fe53c6a8db
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.