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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:58:53  来源:igfitidea点击:

How to build and deploy a react-native app from command line?

iosxcodereact-nativefastlane

提问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:

在提交应用程序之前,我通常会执行以下操作:

  1. I run react-native bundle
  2. I switch the build configuration to Releasein the schema
  3. I comment out the code relative to jsCodeLocationin AppDelegate.m
  1. 我跑 react-native bundle
  2. 我将构建配置切换到Release架构中
  3. 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 jsCodeLocationI 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.mas

我解决了重写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 进行部署而无需编辑文件。