如何从命令行构build和部署反应原生应用程序?

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

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

  1. 我运行react-native bundle
  2. 我将构buildconfiguration切换到架构中的Release
  3. 我注释掉了与AppDelegate.m中的jsCodeLocation相关的代码

是否可以从terminal写一个单一的命令来完成这些步骤,以便我可以使用自动化工具(例如fastlane来部署它?

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

要改变jsCodeLocation我可以添加一个条件,例如

 #if "<build configuration is release>" jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; #else jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #end 

但我不知道如何达到构buildconfiguration设置。

我解决了重写AppDelegate.m

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

现在我可以使用fastlane在不编辑文件的情况下进行部署。

Interesting Posts