Continuous Delivery with Fastlane. Sign, Build and Distribute your React Native App

Hello guys! Today I’m going to write about how you can use Fastlane for your continuous delivery pipeline and apply that for your React Native set up. For this post, we will focus on how to do for iOS platform, and in a second post, we will have a look at Android.

Setting Up Fastlane

For React Native, as you can have both Apps in one single repo, go to ios directory and run the following snippet, so you can set up the fastlane directory:

$fastlane init

Code signing and Matchfile sample

Create a private repository to keep certificates, then, you can create your Matchfile:

$fastlane match init
$fastlane match adhoc

Inside the Match file, set up accordingly, for git_url, place your private repo, for storage_mode, place git, for type, adhoc.

Here is a sample:

git_url("git@github.com:you/certificates.git")
storage_mode("git")
type("adhoc") # The default type, can be: appstore, adhoc, enterprise or development

adhoc is one of the types that allows us to distribute through Firebase.

Build iOS App

For iOS, you can use build_ios_app. Here is a sample:

    build_ios_app(
      scheme: "YourScheme", 
      export_options: {
        method: "ad-hoc"
      }
    )

Using Firebase for App distribution

Install firebase CLI and log in:

$curl -sL firebase.tools | bash
$firebase login

Keep firebase CLI path because you need it for next setting up a lane.

Add firebase plugin:

$fastlane add_plugin firebase_app_distribution

In the lane, add a firebase_app_distribution block:

      firebase_app_distribution(
      app: "You can find the App ID in the Firebase console",
      testers: "you@email.com",
      release_notes: "test release note!",
      firebase_cli_path: "normally /usr/local/bin/firebase"
  )

Note: if you get “error: Provisioning profile doesn’t include signing certificate”, when running it, you might have to recreate the certificates in your private repository. One of the workarounds, you could go to Apple developer console and delete the certificate, so it can recreate in the private git repo.

In the next post, we are going to explore how to run this for Android, and then how to run it in Circle CI. So, keep following us so you can get those updates!

Hope that helps!
See you!

Leave a comment