xcode 如何从命令行构建和部署 react-native 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32885433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to build and deploy a react-native app from command line?
提问by gpbl
I'd like to automate the build + deploy of my React-Native app, for example to submit a TestFlight build.
我想自动化我的 React-Native 应用程序的构建 + 部署,例如提交一个 TestFlight 构建。
Before submitting the app, I usually do the following:
在提交应用程序之前,我通常会执行以下操作:
- I run
react-native bundle
- I switch the build configuration to
Release
in the schema - I comment out the code relative to
jsCodeLocation
in AppDelegate.m
- 我跑
react-native bundle
- 我将构建配置切换到
Release
架构中 - 我
jsCodeLocation
在 AppDelegate.m 中注释掉了相关的代码
Is it possible to write a single command from the Terminal for doing those steps, so that I can then deploy it with an automatization tool, e.g. with fastlane
?
是否可以从终端编写单个命令来执行这些步骤,以便我可以使用自动化工具部署它,例如使用fastlane
?
So far, I'd just need to automatize the 2nd and the 3rd step.
到目前为止,我只需要自动化第二步和第三步。
To change jsCodeLocation
I could add a condition, e.g.
要改变jsCodeLocation
我可以添加一个条件,例如
#if "<build configuration is release>"
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#end
but i don't know how to reach the build configuration setting.
但我不知道如何达到构建配置设置。
回答by gpbl
I solved rewriting AppDelegate.m
as
我解决了重写AppDelegate.m
为
#ifdef DEBUG
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
now i can use fastlane to deploy without editing the file.
现在我可以使用 fastlane 进行部署而无需编辑文件。