<?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: Webspace Team</title>
    <description>The latest articles on DEV Community by Webspace Team (@webspaceteam).</description>
    <link>https://dev.to/webspaceteam</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%2F458156%2F33ea7cae-9ceb-4797-bdcd-0a0d9b8e28bf.jpeg</url>
      <title>DEV Community: Webspace Team</title>
      <link>https://dev.to/webspaceteam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/webspaceteam"/>
    <language>en</language>
    <item>
      <title>React Native &amp; Fastlane for iOS (TestFlight beta releases)</title>
      <dc:creator>Webspace Team</dc:creator>
      <pubDate>Tue, 25 Aug 2020 13:52:18 +0000</pubDate>
      <link>https://dev.to/webspaceteam/react-native-fastlane-for-ios-testflight-beta-releases-3pld</link>
      <guid>https://dev.to/webspaceteam/react-native-fastlane-for-ios-testflight-beta-releases-3pld</guid>
      <description>&lt;p&gt;When you build React Native applications, you have three options to automate the building process. From the official docs you can use Expo or do it via Xcode or Android Studio. Expo simplifies life a lot but has some disadvantages: you can use libs only supported by expo, you do not have webRTC, you can not change native code. But in case you do not need all, this is the best choice. Manual deployment. Well, it works. But you have to do everything manually! The third option is to use automation tools like Fastlane. You can wrap all the process in scripts and just watch! Actually, Expo uses Fastlane on their servers.&lt;/p&gt;

&lt;p&gt;In this guide we will set up Fastlane for a bare React Native project for iOS only to automate TestFlight deployments.&lt;/p&gt;

&lt;p&gt;Foremost - Fastlane should be installed locally. On MacOS run the following commands:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `xcode-select --install
        brew install ruby
        sudo gem install fastlane -NV`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After Fastlane successfully installed navigate into ios/ directory in your React native project and run&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `fastlane init`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You’ll be asked to answer some questions. For our purposes, please choose “Automate beta distribution to TestFlight” option. Next select Scheme. Provide your Apple ID and Password (in case you have two factors authentication enabled, generate “App-specific password”). If you did not set up your app on Appstore Connect, you’ll be asked if you want to create it.&lt;/p&gt;

&lt;p&gt;Initial setup is finished and everything should work “out of the box”. You can find configuration files at “ios/fastlane” folder. The only issue that everything will work locally. In case you have a team it would be hard to deal with certificates, provisioning profiles, etc.&lt;/p&gt;

&lt;p&gt;Fastlane provides a sign-in method called Match. The idea behind is that you have an additional repository for certificates and provisioning profiles, and everyone who has access to this repository can sign and distribute the app.&lt;/p&gt;

&lt;p&gt;To set up Match method you should run in iosit directory&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `Fastlane match init`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You’ll be asked to provide a link to GIT repository for certificates (any link, http or git). After that you need to run:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `fastlane match appstore`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To create certificates and profiles.&lt;br&gt;
During setup you’ll be asked for a passphrase for certificates. As a result, it will push your certificate to your GIT repo.&lt;/p&gt;

&lt;p&gt;To clear existing certificates you can run&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `fastline nuke distribution`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In case you provision profiles or entitlements will be updated you should run&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `fastline match appstore --force`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For force update of your remote repository&lt;/p&gt;

&lt;p&gt;Let's make some adjustments to the building process. In the ios/ folder run&lt;br&gt;
fastlane add_plugin load_json&lt;br&gt;
We need this plugin to read package.json file.&lt;/p&gt;

&lt;p&gt;Replace content of ios/fastlane/Fastfile with&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `default_platform(:ios)
    platform :ios do
    desc "Push a new beta build to TestFlight"
    lane :testflight do
        sync_code_signing(type: "appstore")
        package = load_json(json_path: "../package.json")
        increment_version_number(version_number: package["version"])
        increment_build_number(build_number: latest_testflight_build_number + 
    1, xcodeproj: "vidsig.xcodeproj")
        build_app(workspace: "vidsig.xcworkspace", scheme: "vidsig")
        upload_to_testflight
        slack(
            message: "App successfully uploaded to TestFlight.",
            success: true,
            slack_url: "WEBHOOK URL"
    )
 end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;end`&lt;/p&gt;

&lt;p&gt;Here we have a lane that will:&lt;br&gt;
–Sync code sign-in assets with your MacOS&lt;br&gt;
–Set up version number as provided in package.json&lt;br&gt;
–Increment build number based on the latest in Appstore Connect&lt;br&gt;
–Build and upload your app to Testflight&lt;br&gt;
–Send message in Slack channel&lt;/p&gt;

&lt;p&gt;To set up webhook URL use the following guide: &lt;a href="https://api.slack.com/messaging/webhooks"&gt;https://api.slack.com/messaging/webhooks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the last - in your package.json file add the following into ‘scripts’ section&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `"fastlane:ios:testflight": "cd ios/ &amp;amp;&amp;amp; fastlane testflight"`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That’s all! Now you can run&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        `npm run fastlane:ios:testflight`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and enjoy automation! After the build is processed you’ll get a notification into Slack channel.&lt;/p&gt;

&lt;p&gt;To run configured repository with Fastlane on another MacOS you need to take the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Fastlane locally&lt;/li&gt;
&lt;li&gt;Navigate into ios/ directory and run fastlane match appstore to sync certificates. Enter passphrase.&lt;/li&gt;
&lt;li&gt;Run npm run fastlane:ios:testflight in the root directory of the project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;p&gt;P.S. Need help - contact our &lt;a href="https://webspaceteam.com/react-native/"&gt;react native developers&lt;/a&gt; team.&lt;/p&gt;

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