<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Calin Tamas</title>
    <description>The latest articles on DEV Community by Calin Tamas (@calintamas).</description>
    <link>https://dev.to/calintamas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F135266%2Fef965bed-9fed-4db7-a0c8-ce513b54ad35.jpeg</url>
      <title>DEV Community: Calin Tamas</title>
      <link>https://dev.to/calintamas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/calintamas"/>
    <language>en</language>
    <item>
      <title>Add header to Header Search Paths via cocoapods</title>
      <dc:creator>Calin Tamas</dc:creator>
      <pubDate>Sun, 19 Jan 2020 12:32:46 +0000</pubDate>
      <link>https://dev.to/calintamas/add-header-to-header-search-paths-via-cocoapods-3jdd</link>
      <guid>https://dev.to/calintamas/add-header-to-header-search-paths-via-cocoapods-3jdd</guid>
      <description>&lt;p&gt;If at some point - for some weird reason - you need to append some new headers to your current Header Search Paths, you can write something along these lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;append_header_search_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build_configurations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="n"&gt;xcconfig_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;base_configuration_reference&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;real_path&lt;/span&gt;

        &lt;span class="c1"&gt;# a positive lookbehind regular expression (?&amp;lt;=)&lt;/span&gt;
        &lt;span class="c1"&gt;# to keep the delimiter at the end of each string:&lt;/span&gt;
        &lt;span class="n"&gt;file_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xcconfig_path&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/(?&amp;lt;=[\S])\n/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Copy current headers&lt;/span&gt;
        &lt;span class="n"&gt;header_search_paths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
        &lt;span class="n"&gt;header_search_paths_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kp"&gt;nil&lt;/span&gt;
        &lt;span class="n"&gt;file_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with_index&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
          &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sr"&gt;/HEADER_SEARCH_PATHS/&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
            &lt;span class="n"&gt;header_search_paths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
            &lt;span class="n"&gt;header_search_paths_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;
          &lt;span class="k"&gt;end&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;

        &lt;span class="c1"&gt;# Append the new header&lt;/span&gt;
        &lt;span class="n"&gt;new_header_search_paths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;header_search_paths&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;" &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
        &lt;span class="n"&gt;file_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;header_search_paths_index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_header_search_paths&lt;/span&gt;

        &lt;span class="c1"&gt;# Write it back to the file&lt;/span&gt;
        &lt;span class="n"&gt;file_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;file_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xcconfig_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, you can use it in a &lt;code&gt;post-install&lt;/code&gt; action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;post_install&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;installer&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;installer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pods_project&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"AnyProject"&lt;/span&gt;
          &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Updating &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; HEADER_SEARCH_PATHS"&lt;/span&gt;
          &lt;span class="n"&gt;append_header_search_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"${PODS_ROOT}/../new_header"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>ios</category>
      <category>cocoapods</category>
      <category>headersearchpaths</category>
    </item>
    <item>
      <title>How to manage staging and production environments in React Native </title>
      <dc:creator>Calin Tamas</dc:creator>
      <pubDate>Tue, 19 Feb 2019 19:24:56 +0000</pubDate>
      <link>https://dev.to/calintamas/how-to-manage-staging-and-production-environments-in-a-react-native-app-4naa</link>
      <guid>https://dev.to/calintamas/how-to-manage-staging-and-production-environments-in-a-react-native-app-4naa</guid>
      <description>&lt;p&gt;Your life as a React Native developer is just about to get easier. At least mine did, as soon as I learned &lt;strong&gt;how to manage staging and production environments in React Native&lt;/strong&gt;. It doesn't change the way your React Native app looks, feels or sells. But it saves you a great deal of developer hustle. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;I originally posted this on &lt;a href="https://around25.com/blog/manage-staging-and-production-environments-for-react-native-app/" rel="noopener noreferrer"&gt;around25's blog&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It's a breeze to &lt;strong&gt;change a config&lt;/strong&gt; when there's only one or two changes to be done. You switch the &lt;code&gt;API host&lt;/code&gt; to the production one and bam, you're done. Things only get harder and much more error-prone when you have to change the &lt;code&gt;API host&lt;/code&gt;, put the payment gateway &lt;code&gt;key&lt;/code&gt;, payment gateway &lt;code&gt;host&lt;/code&gt;, set the notifications &lt;code&gt;.plist&lt;/code&gt; file, update the crashlytics &lt;code&gt;key&lt;/code&gt; and update the analytics &lt;code&gt;key&lt;/code&gt;. Do this by hand every time you make a build and at some point I guarantee you're going to miss something.&lt;/p&gt;

&lt;p&gt;So to avoid headaches, we're going to use environment variables.&lt;/p&gt;

&lt;p&gt;To expose env variables to &lt;code&gt;react-native&lt;/code&gt;, I'm going to use the &lt;a href="https://github.com/luggit/react-native-config" rel="noopener noreferrer"&gt;react-native-config&lt;/a&gt; library. By doing so, I am keeping the config variables away from the code. It's most likely that those vars are going to be different across environments, while the code is not.&lt;/p&gt;

&lt;p&gt;First of all, I'm going to add the library to the project. As I'm writing this, the latest version for &lt;code&gt;react-native-config&lt;/code&gt; is &lt;code&gt;0.11.7&lt;/code&gt;. Then, I have to create 3 env files in the &lt;code&gt;root&lt;/code&gt; of the project: one for the local environment, simply called &lt;code&gt;.env&lt;/code&gt;, and another two called &lt;code&gt;.env.staging&lt;/code&gt; and &lt;code&gt;.env.production&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

// .env
IS_PRODUCTION=false
API_HOST=https://api.staging.foobar.com

// .env.staging
IS_PRODUCTION=false
API_HOST=https://api.staging.foobar.com

// .env.production
IS_PRODUCTION=true
API_HOST=https://api.foobar.com


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For now, I'm only keeping the &lt;code&gt;API host&lt;/code&gt; in the config, alongside with an &lt;code&gt;IS_PRODUCTION&lt;/code&gt; flag. We'll use that later. Obviously, both &lt;code&gt;https://api.staging.foobar.com&lt;/code&gt; and &lt;code&gt;https://api.foobar.com&lt;/code&gt; are fictional 🙂.&lt;/p&gt;

&lt;p&gt;Now, to put those vars to use for my React Native app, here's how my config file usually looks like:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="c1"&gt;// src/config/index.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native-config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;API_HOST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20000&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_HOST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;API_HOST&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's all. By default, &lt;code&gt;react-native-config&lt;/code&gt; reads from the &lt;code&gt;.env&lt;/code&gt; file, but reading from any file &amp;amp; running the project is possible via the following command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ ENVFILE=.env.staging react-native run-ios  


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;All good so far, but I want my build process to be as automated as possible. So manually specifying the &lt;code&gt;.env&lt;/code&gt; file is not acceptable. Avoiding this is what we're going to do next.&lt;/p&gt;

&lt;h2&gt;
  
  
  iOS setup
&lt;/h2&gt;

&lt;p&gt;On iOS, I'm going to take advantage of the concept of &lt;strong&gt;schemes&lt;/strong&gt;. An Xcode scheme defines a collection of targets to build &amp;amp; a configuration to use when building. The default one can be found in Xcode's menu bar:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Product -&amp;gt; Scheme -&amp;gt; FooBar


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;where &lt;em&gt;FooBar&lt;/em&gt; is the name of my app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F1.png" alt="show ios product scheme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What I'm going to do is duplicate that default scheme and create two new schemes: one for &lt;strong&gt;staging&lt;/strong&gt; and one for &lt;strong&gt;production&lt;/strong&gt;. We're going to use the default one for the &lt;strong&gt;local&lt;/strong&gt; environment. You can do it by going to:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Product -&amp;gt; Scheme -&amp;gt; Edit Scheme -&amp;gt; Duplicate Scheme


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F2.png" alt="xcode 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm going to call them &lt;code&gt;FooBar.staging&lt;/code&gt; and &lt;code&gt;FooBar.production&lt;/code&gt;. Naming is going to be important when we write the automated build script later.&lt;/p&gt;

&lt;p&gt;I'm going to select &lt;code&gt;FooBar.staging&lt;/code&gt; and go back to &lt;code&gt;Edit Scheme&lt;/code&gt;, to make sure my scheme loads up the &lt;code&gt;.env&lt;/code&gt; file I want. Here, on &lt;code&gt;Build -&amp;gt; Pre-actions&lt;/code&gt; I'm adding a script that does that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F3.png" alt="add pre build script"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F4.png" alt="add pre build script part 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm going through exactly the same process for &lt;code&gt;FooBar.production&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, I got everything set up for iOS. Whenever I'm building the app, by selecting a scheme, I get the right env vars loaded in. Kudos, let's go to Android.&lt;/p&gt;

&lt;h2&gt;
  
  
  Android setup
&lt;/h2&gt;

&lt;p&gt;For Android, we have &lt;a href="https://developer.android.com/studio/build/build-variants?utm_source=android-studio#build-types" rel="noopener noreferrer"&gt;build types&lt;/a&gt;. In &lt;code&gt;android/app/build.gradle&lt;/code&gt;, under &lt;code&gt;buildTypes&lt;/code&gt; we have the two default build types, &lt;strong&gt;release&lt;/strong&gt; and &lt;strong&gt;debug&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;

&lt;span class="n"&gt;buildTypes&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;release&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;minifyEnabled&lt;/span&gt; &lt;span class="n"&gt;enableProguardInReleaseBuilds&lt;/span&gt;
        &lt;span class="n"&gt;proguardFiles&lt;/span&gt; &lt;span class="nf"&gt;getDefaultProguardFile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"proguard-android.txt"&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;"proguard-rules.pro"&lt;/span&gt;
        &lt;span class="n"&gt;signingConfig&lt;/span&gt; &lt;span class="n"&gt;signingConfigs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;release&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;debug&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;debuggable&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Same as before, the default is going to use the local env vars. &lt;/p&gt;

&lt;p&gt;For the new build types, add these lines:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;

&lt;span class="n"&gt;stagingrelease&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;initWith&lt;/span&gt; &lt;span class="n"&gt;release&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;productionrelease&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;initWith&lt;/span&gt; &lt;span class="n"&gt;release&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Each of those is going to be used for making a &lt;em&gt;release-type&lt;/em&gt; build, so make sure to &lt;a href="https://facebook.github.io/react-native/docs/signed-apk-android" rel="noopener noreferrer"&gt;generate a signing key&lt;/a&gt; before proceeding. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Naming is very important at this step&lt;/strong&gt;. First, you must have the token &lt;em&gt;release&lt;/em&gt; in the build variant name for regular release build behavior to apply, see more &lt;a href="https://chase-seibert.github.io/blog/2016/12/09/react-native-android-staging-variant.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Second, I had issues when I initially set up the names to &lt;em&gt;releaseStaging&lt;/em&gt; and &lt;em&gt;releaseProduction&lt;/em&gt;, as the correct &lt;code&gt;.env&lt;/code&gt; file was not loading. I googled it up and found the issue &amp;amp; solution &lt;a href="https://github.com/luggit/react-native-config/issues/175#issuecomment-343004822" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, at the very top of the same &lt;code&gt;android/app/build.gradle&lt;/code&gt; file, add this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;

&lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ext&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;envConfigFiles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;
        &lt;span class="nl"&gt;debug:&lt;/span&gt; &lt;span class="s2"&gt;".env"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;release:&lt;/span&gt; &lt;span class="s2"&gt;".env"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;stagingrelease:&lt;/span&gt; &lt;span class="s2"&gt;".env.staging"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;productionrelease:&lt;/span&gt; &lt;span class="s2"&gt;".env.production"&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You might encounter problems with Proguard for release builds. The solution is &lt;a href="https://github.com/luggit/react-native-config#problems-with-proguard" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To run the app using one of the build types defined above, go to &lt;code&gt;View -&amp;gt; Tool Windows -&amp;gt; Build Variants&lt;/code&gt; and select the variant (in the newly exposed window) before building:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faround25.com%2Fblog%2Fcontent%2Fimages%2F2019%2F02%2F5.png" alt="android build variants window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it for Android too. Next, we're going to automate our build process even more, by creating &lt;code&gt;fastlane&lt;/code&gt; scripts. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;My aim is to have a one-liner build script for each of the two platforms.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Bonus: fastlane scripts
&lt;/h2&gt;

&lt;p&gt;First, we are going to &lt;a href="https://docs.fastlane.tools/#getting-started" rel="noopener noreferrer"&gt;install fastlane&lt;/a&gt; and go through the setup. &lt;code&gt;fastlane init&lt;/code&gt; has to be run inside an iOS or Android project, so we're going to do it inside the ios folder and then move the whole &lt;code&gt;fastlane&lt;/code&gt; folder to the root of the project.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;fastlane/Fastfile&lt;/code&gt;, I'm creating a lane under the ios platform to upload a build to TestFlight. Fastlane automatically loads the .env file we are passing when running the script. If we do:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ fastlane ios beta --env=production


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;it will load the &lt;code&gt;.env.production&lt;/code&gt; file. So we are all set. To test this, I am going to add a few lines that only print out the environment vars and the file that was loaded.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;

&lt;span class="sr"&gt;//&lt;/span&gt; &lt;span class="n"&gt;fastlane&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="no"&gt;Fastfile&lt;/span&gt;

&lt;span class="n"&gt;platform&lt;/span&gt; &lt;span class="ss"&gt;:ios&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s2"&gt;"Submit a new build to TestFlight"&lt;/span&gt;
  &lt;span class="n"&gt;lane&lt;/span&gt; &lt;span class="ss"&gt;:beta&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;app_identifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"com.app.identifier"&lt;/span&gt;

    &lt;span class="n"&gt;api_environment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"staging"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"IS_PRODUCTION"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"true"&lt;/span&gt;
      &lt;span class="n"&gt;api_environment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"production"&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ENVFILE"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;".env.&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;api_environment&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"API_HOST: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'API_HOST'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"IS_PRODUCTION: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'IS_PRODUCTION'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"ENVFILE: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ENVFILE'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If everything is right, we should see this printed out:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[18:16:52]: Loading from './/../.env.production'
[18:16:52]: Driving the lane 'ios beta' 🚀
[18:16:52]: API_HOST: https://api.foobar.com
[18:16:52]: IS_PRODUCTION: true
[18:16:52]: ENVFILE: .env.production


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Before making a new build, we may want to increment the build number and/or build version. Add these lines to the file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;

&lt;span class="n"&gt;increment_version_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="ss"&gt;xcodeproj: &lt;/span&gt;&lt;span class="s1"&gt;'./ios/FooBar.xcodeproj'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;bump_type: &lt;/span&gt;&lt;span class="s2"&gt;"patch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;# bump_type: "minor",&lt;/span&gt;
    &lt;span class="c1"&gt;# bump_type: "major",&lt;/span&gt;
    &lt;span class="c1"&gt;# version_number: "1.0.0"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;increment_build_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="ss"&gt;xcodeproj: &lt;/span&gt;&lt;span class="s1"&gt;'./ios/FooBar.xcodeproj'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;# build_number: '74'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, to create a build, add the following lines. Remember that at the beginning of the article I mentioned that the naming of the &lt;strong&gt;schemes&lt;/strong&gt; will be important later. Well, this is why:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;

&lt;span class="n"&gt;gym&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="ss"&gt;xcodeproj: &lt;/span&gt;&lt;span class="s1"&gt;'./ios/FooBar.xcodeproj'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;scheme: &lt;/span&gt;&lt;span class="s2"&gt;"FooBar.&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;api_environment&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Finally, I'd like my script to also upload the build to &lt;code&gt;TestFlight&lt;/code&gt;, so I do this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;

&lt;span class="n"&gt;pilot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="ss"&gt;app_identifier: &lt;/span&gt;&lt;span class="n"&gt;app_identifier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;email: &lt;/span&gt;&lt;span class="s2"&gt;"itunesconnect_email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;first_name: &lt;/span&gt;&lt;span class="s2"&gt;"itunesconnect_first_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;last_name: &lt;/span&gt;&lt;span class="s2"&gt;"itunesconnect_last_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;ipa: &lt;/span&gt;&lt;span class="s2"&gt;"./FooBar.ipa"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;distribute_external: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;skip_submission: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;skip_waiting_for_build_processing: &lt;/span&gt;&lt;span class="kp"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It's almost the same process for Android, but instead of the &lt;code&gt;gym&lt;/code&gt; and &lt;code&gt;pilot&lt;/code&gt; actions, we are using &lt;code&gt;gradle&lt;/code&gt; and &lt;code&gt;supply&lt;/code&gt;. The lane looks something like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;

&lt;span class="n"&gt;platform&lt;/span&gt; &lt;span class="ss"&gt;:android&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s2"&gt;"Submit a new build to Google Play Console"&lt;/span&gt;

  &lt;span class="n"&gt;lane&lt;/span&gt; &lt;span class="ss"&gt;:beta&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;app_identifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"com.app.identifier"&lt;/span&gt;

    &lt;span class="n"&gt;api_environment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"staging"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"IS_PRODUCTION"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"true"&lt;/span&gt;
      &lt;span class="n"&gt;api_environment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"production"&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ENVFILE"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;".env.&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;api_environment&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"API_HOST: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'API_HOST'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"IS_PRODUCTION: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'IS_PRODUCTION'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"ENVFILE: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ENVFILE'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="n"&gt;gradle_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"./android/app/build.gradle"&lt;/span&gt;

    &lt;span class="n"&gt;android_set_version_name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="ss"&gt;version_name: &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;gradle_file: &lt;/span&gt;&lt;span class="n"&gt;gradle_file&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;android_set_version_code&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="ss"&gt;gradle_file: &lt;/span&gt;&lt;span class="n"&gt;gradle_file&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;gradle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="ss"&gt;project_dir: &lt;/span&gt;&lt;span class="s1"&gt;'./android'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;task: &lt;/span&gt;&lt;span class="s1"&gt;'assemble'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;build_type: &lt;/span&gt;&lt;span class="s1"&gt;'release'&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;supply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="ss"&gt;json_key: &lt;/span&gt;&lt;span class="s1"&gt;'google_play_console_key'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;track: &lt;/span&gt;&lt;span class="s1"&gt;'beta'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;apk: &lt;/span&gt;&lt;span class="s1"&gt;'./android/app/build/outputs/apk/release/app-release.apk'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;package_name: &lt;/span&gt;&lt;span class="n"&gt;app_identifier&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Final thoughts on Staging and Production Environments in a React Native App
&lt;/h2&gt;

&lt;p&gt;Before I leave you, I'd like to express my thoughts on what I believe it would be best practice regarding source control. &lt;/p&gt;

&lt;p&gt;I suggest committing real values to &lt;code&gt;.env&lt;/code&gt; (the local environment), but keeping &lt;code&gt;.env.staging&lt;/code&gt; and &lt;code&gt;.env.production&lt;/code&gt; with dummy/non-sensitive values that are replaced on the build machine only at build time. &lt;/p&gt;

&lt;p&gt;So the three files would look something like this in the repo:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

// .env
IS_PRODUCTION=false
API_HOST=https://api.staging.foobar.com

// .env.staging
IS_PRODUCTION=false
API_HOST=api_host

// .env.production
IS_PRODUCTION=true
API_HOST=api_host


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The complete source code can be found on &lt;a href="https://github.com/calintamas/react-native-envs-poc" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to tell me what you think or if you have any suggestions for the solutions I advanced above.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>mobile</category>
      <category>app</category>
      <category>fastlane</category>
    </item>
  </channel>
</rss>
