【问题标题】:How to build and deploy a react-native app from command line?如何从命令行构建和部署 react-native 应用程序?
【发布时间】:2015-12-29 09:08:36
【问题描述】:

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

在提交应用之前,我通常会做以下事情:

  1. 我跑react-native bundle
  2. 我将架构中的构建配置切换为Release
  3. 我注释掉AppDelegate.m中与jsCodeLocation相关的代码

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

但我不知道如何访问构建配置设置。

【问题讨论】:

    标签: ios xcode react-native fastlane


    【解决方案1】:

    我解决了将AppDelegate.m 重写为

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

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

    【讨论】:

    • 只是说,应用程序是客户端,而不是服务器端,所以主机名0.0.0.0 会使调试版本不起作用。 (虽然您可以在应用程序的调试菜单中对其进行修改)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 2020-04-03
    • 2022-10-04
    相关资源
    最近更新 更多