[英]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.