如何从命令行构建和部署react-native应用程序?

gpb*_*pbl 9 xcode ios react-native fastlane

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

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

  1. 我跑 react-native bundle
  2. 我将构建配置切换到Release架构中
  3. jsCodeLocation在AppDelegate.m中注释掉了相对于代码的代码

是否可以从终端编写单个命令来执行这些步骤,以便我可以使用自动化工具部署它,例如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
Run Code Online (Sandbox Code Playgroud)

但我不知道如何达到构建配置设置.

gpb*_*pbl 16

我解决了重写AppDelegate.m

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

现在我可以使用fastlane来部署而无需编辑文件.