I come to React Native development without previous experience of iOS development. I want to build release .IPA file - ideally from command line but the official documentation Running On Device is very brief.
我在没有iOS开发经验的情况下进行本地开发。我想要构建release . ipa文件——理想情况下是命令行,但是在设备上运行的官方文档非常简短。
I was able to deploy application on my iPhone manually via XCode but still I can't find any "release IPA" file. I have updated my code with #ifdef DEBUG
directives to make it more generic.
我可以通过XCode在iPhone上手动部署应用程序,但仍然找不到任何“发布IPA”文件。我用#ifdef调试指令更新了我的代码,使它更通用。
Is there a way to build application in release mode only via commandline? If no, what is "the official" way to generate RN application?
是否有一种方法可以只通过命令行在发布模式中构建应用程序?如果没有,生成RN应用程序的“官方”方法是什么?
I am currently using RN 0.20.
我现在用的是RN 0。20。
3 个解决方案
#1
42
First, you need to create a bundle this way :
首先,您需要这样创建一个包:
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
Then, you have to comment this line in AppDelegate.m :
然后,必须在AppDelegate中注释这一行。m:
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
and uncomment this one :
不要评论这个:
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Then you have to go for Product -> Archive in Xcode and follow the steps based on your desired release
然后,您必须使用Xcode中的Product ->归档文件,并根据需要的版本执行这些步骤
#2
17
You have to set Scheme to Release.
你必须设置Scheme来释放。
From docs you have two ways.
从文档中你有两种方法。
To do this, go to Product → Scheme → Edit Scheme (cmd + <), make sure you're in the Run tab from the side, and set the Build Configuration dropdown to Release.
要做到这一点,去产品→编辑→计划方案(cmd + <),确保你在选项卡从侧面,并设置构建配置下拉。
or
或
You can also use the React Native CLI to perform this operation using the option --configuration with the value Release (e.g. react-native run-ios --configuration Release).
您还可以使用React Native CLI来执行此操作,使用带有值释放的选项——配置(例如,response - Native - run-ios——configuration版本)。
Then you can generate your archive as usual.
然后可以像往常一样生成归档文件。
https://facebook.github.io/react-native/docs/running-on-device.html#building-your-app-for-production
https://facebook.github.io/react-native/docs/running-on-device.html building-your-app-for-production
#3
13
i cannot comment on the above answer, it is correct but you need to start with the following command in order for it to work:
我无法对上面的答案进行评论,它是正确的,但是你需要从下面的命令开始,这样它才能工作:
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
the difference is 'ios' instead of 'iOS'
不同的是ios而不是ios
if not it will give the following error:
否则会出现以下错误:
ProjectPath/node_modules/promise/lib/done.js:10
throw err;
^
#1
42
First, you need to create a bundle this way :
首先,您需要这样创建一个包:
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
Then, you have to comment this line in AppDelegate.m :
然后,必须在AppDelegate中注释这一行。m:
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
and uncomment this one :
不要评论这个:
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Then you have to go for Product -> Archive in Xcode and follow the steps based on your desired release
然后,您必须使用Xcode中的Product ->归档文件,并根据需要的版本执行这些步骤
#2
17
You have to set Scheme to Release.
你必须设置Scheme来释放。
From docs you have two ways.
从文档中你有两种方法。
To do this, go to Product → Scheme → Edit Scheme (cmd + <), make sure you're in the Run tab from the side, and set the Build Configuration dropdown to Release.
要做到这一点,去产品→编辑→计划方案(cmd + <),确保你在选项卡从侧面,并设置构建配置下拉。
or
或
You can also use the React Native CLI to perform this operation using the option --configuration with the value Release (e.g. react-native run-ios --configuration Release).
您还可以使用React Native CLI来执行此操作,使用带有值释放的选项——配置(例如,response - Native - run-ios——configuration版本)。
Then you can generate your archive as usual.
然后可以像往常一样生成归档文件。
https://facebook.github.io/react-native/docs/running-on-device.html#building-your-app-for-production
https://facebook.github.io/react-native/docs/running-on-device.html building-your-app-for-production
#3
13
i cannot comment on the above answer, it is correct but you need to start with the following command in order for it to work:
我无法对上面的答案进行评论,它是正确的,但是你需要从下面的命令开始,这样它才能工作:
react-native bundle --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle --platform ios
the difference is 'ios' instead of 'iOS'
不同的是ios而不是ios
if not it will give the following error:
否则会出现以下错误:
ProjectPath/node_modules/promise/lib/done.js:10
throw err;
^