How to Set Up Fastlane for iOS

 1. Prerequisites
Required Tools

macOS

Xcode (Install via the App Store or Apple Developer site)

CocoaPods (sudo gem install cocoapods)

Ruby (Pre-installed on macOS)

Node.js / npm

React Native CLI (npm install -g react-native-cli or simply use npx react-native)

 2. Installing Fastlane
1. Install Fastlane

Bash

sudo gem install fastlane -NV
The -NV flag provides detailed installation logs.

If you encounter issues, you can install it via Homebrew: brew install fastlane (Recommended: the Homebrew method keeps the installation isolated from your system).

📌 Note: When using brew install fastlane, Fastlane will use the Homebrew Ruby environment instead of the system Ruby.

2. Initialize Fastlane Navigate to your project's root or the ios/ directory and run:

Bash

cd ios
fastlane init
3. Select Initialization Options Fastlane will ask you the following question: "What would you like to use fastlane for?"

Options:

📦 Automate beta distribution to TestFlight

🚀 Automate App Store distribution

🧪 Manual setup (Typically, developers choose either TestFlight or App Store distribution.)

Enter Apple ID: Provide your Apple Developer account credentials.

Enter App Identifier: e.g., com.mycompany.myapp

Fastlane will then generate the following files inside the ios/fastlane/ directory:

Fastfile: Defines your tasks (lanes) like deployment or testing.

Appfile: Stores your app and account information.

 3. Basic Fastlane Configuration
Example Appfile

Ruby

app_identifier("com.mycompany.myapp")
apple_id("your@email.com")

team_id("XXXXXXXXXX") # Apple Developer Team ID
Example Fastfile (Basic Beta Deployment Lane)

Ruby

default_platform(:ios)

platform :ios do
  desc "Deploy to TestFlight"
  lane :beta do
    build_app(scheme: "MyApp")
    upload_to_testflight
  end
end
 4. Code Signing and Provisioning Profiles Setup
1. Initialize match (The official code signing tool)

Bash

fastlane match init
2. Set up a Git repository to store certificates/profiles

Bash

fastlane match development
fastlane match appstore
Note: When using match, your certificates and provisioning profiles are encrypted and securely stored in a private Git repository.

 5. Actual Deployment Examples
Deploy to TestFlight

Bash

fastlane beta
Deploy to the App Store (Including Review Submission)

Ruby

lane :release do
  capture_screenshots
  build_app(scheme: "MyApp")
  upload_to_app_store(
    skip_screenshots: true,
    skip_metadata: true
  )
end
Run the release lane using:


Bash

fastlane release

댓글

이 블로그의 인기 게시물

How to Open, Set, and Save Environment Variables (Windows, macOS, Linux)

My Experience Publishing a React Native App as an iOS Developer

Swift Basics: [Advanced - Functions] Default Parameters & Argument Labels