如何从命令行构建和部署react-native应用程序? [英] How to build and deploy a react-native app from command line?

查看:174
本文介绍了如何从命令行构建和部署react-native应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动化我的React-Native应用程序的构建+部署,例如提交TestFlight构建。

I'd like to automate the build + deploy of my React-Native app, for example to submit a TestFlight build.

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

Before submitting the app, I usually do the following:


  1. 我跑步 react-native bundle

  2. 我将构建配置切换为 Release schema

  3. 我在AppDelegate.m中注释掉相对于 jsCodeLocation 的代码

  1. I run react-native bundle
  2. I switch the build configuration to Release in the schema
  3. I comment out the code relative to jsCodeLocation in AppDelegate.m

是否可以从终端编写单个命令来执行这些步骤,以便我可以使用自动化工具部署它,例如使用 fastlane

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?

到目前为止,我只需要自动化第2步和第3步。

So far, I'd just need to automatize the 2nd and the 3rd step.

要更改 jsCodeLocation 我可以添加条件,例如

To change jsCodeLocation I could add a condition, e.g.

#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.

推荐答案

我解决了重写 AppDelegate.m as

#ifdef DEBUG
    jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
#else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

现在我可以使用fastlane进行部署而无需编辑文件。

now i can use fastlane to deploy without editing the file.

这篇关于如何从命令行构建和部署react-native应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆