代码之家  ›  专栏  ›  技术社区  ›  sonlexqt

将react native config与fastlane一起使用

  •  0
  • sonlexqt  · 技术社区  · 7 年前

    fastlane : beta production react-native-config 对于不同的环境配置(存储在2个文件中: .env.beta .env.production ). 我怎样才能让 快车道

    2 回复  |  直到 7 年前
        1
  •  3
  •   Lyndsey Ferguson    7 年前

    如果在调用命令生成应用程序之前询问如何设置环境变量,可以在 Fastfile . 在你的 fastlane 要构建应用程序,请设置 ENV['ENVFILE'] 变量来指向 .env.X 文件。看到了吗 react-native-config docs on environments .

    lane :build_beta do
       ENV['ENVFILE'] = '.env.beta'
       build_ios_app(...) # you may be using `gym` instead.
    end
    lane :build_production do
       ENV['ENVFILE'] = '.env.production'
       build_ios_app(...) # you may be using `gym` instead.
    end
    

    # call me from the command line like: `fastlane build_sonlexqts_app config:beta`
    lane :build_sonlexqts_app |options|
       config = options[:config]
       unless %w(beta production).include?(config)
         UI.user_error!("#{config} is invalid. Please pass either 'beta' or 'production'")
       end
       ENV['ENVFILE'] = ".env.#{config}"
       build_ios_app(...) # you may be using `gym` instead.
    end
    
        2
  •  1
  •   sonlexqt    7 年前

    我设法得到了 react-native-config 使用提供的环境变量功能获取正确的配置文件 fastlane 通过使用 fastlane [lane] --env [beta|production] .

    推荐文章