In the previous blog, we explored how to integrate Fastlane for Android builds and Firebase App Distribution. Now, moving forward, let's shift gears and focus on the iOS side of automation—specifically, building your iOS app and uploading it to TestFlight using Fastlane.

This guide is perfect for React Native developers who want to streamline iOS releases and reduce manual efforts.

Why Fastlane for iOS?

Fastlane simplifies the complex process of iOS builds and deployments by:

  • Automating tedious tasks
  • Reducing human error
  • Saving hours of manual work
  • Providing consistent builds every time

🧰 Getting Started with Fastlane for iOS

✅ 1. Install Fastlane

First, install Fastlane using RubyGems:

sudo gem install fastlane -NV

The -NV flags ensure a verbose and non-documentation install, which is faster.

✅ 2. React Native Project Setup (iOS)

Navigate into your iOS directory:

cd ios
fastlane init

You’ll be prompted with the question:

"What would you like to use fastlane for?"

Refer to the screenshot below and select option 2:
👉 Automate beta distribution to TestFlight

During this initialization process, Fastlane will ask for your iOS bundle identifier (e.g., com.example.app). Once completed, a fastlane directory will be created inside the ios folder containing the

🔐 3. Set Up App-Specific Password for Fastlane

To upload builds to TestFlight, Apple requires an app-specific password. Here’s how to create one:

  1. Visit: Apple.com
  2. Sign in with your Apple Developer account.
  3. Go to Sign-In and Security > App-Specific Passwords
  4. Click Generate an app-specific password, name it (e.g., "fastlane"), and copy the password.

Then, create a .env file inside the ios/fastlane directory:
Paste the following line:

FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD=your_generated_password

This ensures that Fastlane can authenticate securely when uploading builds to TestFlight.

🔄 Fastlane Configuration (iOS)

Now that the environment is ready, here’s the Fastlane configuration for building your app and uploading it to TestFlight.

default_platform(:ios)

platform :ios do
  desc "Build and upload to TestFlight"
  lane :build_and_upload do

    # Configuration
    app_identifier = "com.xxxx.xxxx.xxx" # Replace with your actual bundle ID
    profile_name = "YOUR PROJECT NAME - Prod Distribution" # Found in Xcode > Signing & Capabilities

    build_ios_app(
      workspace: "YOUR_PROJECT.xcworkspace",
      scheme: "YOUR_SCHEME", # Typically the same as your project name
      export_method: "app-store",
      clean: true,
      export_options: {
        provisioningProfiles: {
          app_identifier => profile_name
        },
        method: "app-store"
      },
      output_directory: "./build",
      output_name: "YOURIPANAME.ipa"
    )

    upload_to_testflight(
      ipa: "./build/YOURIPANAME.ipa",
      skip_waiting_for_build_processing: true,
      changelog: File.read(File.expand_path("../../release_notes.txt", File.dirname(__FILE__)))
    )
  end
end

Make sure to replace the placeholders like:

  • YOUR_PROJECT.xcworkspace
  • YOUR_SCHEME
  • YOURIPANAME.ipa
  • app_identifier

📜 Creating release_notes.txt

Place this file in your root directory (above ios):

release_notes.txt

Example contents:

🚀 New Features
- Added support for voice recognition
- Improved video playback performance

🐞 Bug Fixes
- Fixed crash on iOS 17 during startup
- Resolved notification issues on background mode

This file is used by Fastlane to add release notes to the TestFlight build.

🚀 Run the Lane

From the project’s ios directory, trigger your automated build and upload:

fastlane build_and_upload

Fastlane will:

  • Build your iOS app.
  • Export the .ipa.
  • Upload it to TestFlight.
  • Attach your release notes.

💡 Final Tips

  • 🔐 Keep .env out of version control by adding it to .gitignore.
  • ⚙️ Automate the entire flow with CI/CD tools like GitHub Actions or Bitrise.
  • 🧼 Use Fastlane actions like clean_build_artifacts or clear_derived_data for a fresh build.
  • 🧪 Use --verbose flag for debugging when something goes wrong.

🎯 Wrapping Up

By automating your iOS builds and TestFlight uploads with Fastlane, you're saving time, reducing human error, and improving consistency across release cycles.

This setup is a great follow-up to the iOS Fastlane flow, making your entire React Native deployment process fully automated.

Amit KumarSource