home / skills / greenstevester / fastlane-skill / setup-fastlane

setup-fastlane skill

/skills/setup-fastlane

This skill guides you through a one-time Fastlane setup to automate iOS builds, tests, and App Store releases.

npx playbooks add skill greenstevester/fastlane-skill --skill setup-fastlane

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.1 KB
---
name: setup-fastlane
description: Set up Fastlane for iOS/macOS app automation
argument-hint: [project-path]
allowed-tools: Bash, Read, Write, Edit, Glob
---

## Fastlane Setup (One-Time)

```
┌─────────────────────────────────────────────────────────────────┐
│  ONE-TIME SETUP                                                 │
│  ══════════════                                                 │
│  After this, you'll have:                                       │
│                                                                 │
│    fastlane ios test    → Run tests                             │
│    fastlane ios beta    → Upload to TestFlight                  │
│    fastlane ios release → Submit to App Store                   │
│                                                                 │
│  Do this once per project. Takes ~10 minutes.                   │
└─────────────────────────────────────────────────────────────────┘
```

### Environment Check
- Xcode CLI: !`xcode-select -p 2>/dev/null && echo "✓" || echo "✗ Run: xcode-select --install"`
- Homebrew: !`brew --version 2>/dev/null | head -1 || echo "✗ Run: /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""`
- Fastlane: !`fastlane --version 2>/dev/null | grep -o "fastlane [0-9.]*" | head -1 || echo "✗ Run: brew install fastlane"`

### Your Project
- Project: !`find . -maxdepth 2 -name "*.xcodeproj" 2>/dev/null | head -1 || echo "None found"`
- Workspace: !`find . -maxdepth 2 -name "*.xcworkspace" ! -path "*/.build/*" ! -path "*/xcodeproj/*" 2>/dev/null | head -1 || echo "None"`
- Bundle ID: !`grep -r "PRODUCT_BUNDLE_IDENTIFIER" --include="*.pbxproj" . 2>/dev/null | head -1 | sed 's/.*= //' | tr -d '";' || echo "Not found"`
- Team ID: !`grep -r "DEVELOPMENT_TEAM" --include="*.pbxproj" . 2>/dev/null | head -1 | sed 's/.*= //' | tr -d '";' || echo "Not found"`

### Target: ${ARGUMENTS:-current directory}

---

## Step 1: Install Fastlane

```bash
brew install fastlane
```

> **Why Homebrew?** Bundler 4.x broke Fastlane's Ruby dependencies. Homebrew avoids all version conflicts.

---

## Step 2: Create Configuration Files

### `fastlane/Appfile`
```ruby
app_identifier("{{BUNDLE_ID}}")  # Your bundle ID
apple_id("{{APPLE_ID}}")         # Your Apple ID email
team_id("{{TEAM_ID}}")           # Your team ID
```

### `fastlane/Fastfile`
```ruby
default_platform(:ios)

platform :ios do
  desc "Run tests"
  lane :test do
    scan(scheme: "{{SCHEME}}")
  end

  desc "Upload to TestFlight"
  lane :beta do
    increment_build_number
    gym(scheme: "{{SCHEME}}", export_method: "app-store")
    pilot(skip_waiting_for_build_processing: true)
  end

  desc "Submit to App Store"
  lane :release do
    increment_build_number
    gym(scheme: "{{SCHEME}}", export_method: "app-store")
    deliver(submit_for_review: false, force: true)
  end
end
```

Replace `{{SCHEME}}` with your app's scheme name (usually the app name).

---

## Step 3: Set Up Metadata (Optional)

Download your existing App Store listing:
```bash
fastlane deliver download_metadata
fastlane deliver download_screenshots
```

This creates `fastlane/metadata/` with editable text files for your app description, keywords, etc.

---

## You're Done!

```bash
# Verify setup
fastlane lanes

# Run your first lane
fastlane ios test
```

### Quick Reference
| Command | What it does |
|---------|--------------|
| `fastlane ios test` | Run tests |
| `fastlane ios beta` | Build + TestFlight |
| `fastlane ios release` | Build + App Store |
| `fastlane deliver download_metadata` | Fetch App Store listing |

---

## Next Steps

- **Code signing issues?** Ask: "Set up Match for code signing"
- **Need screenshots?** Ask: "Automate my App Store screenshots"
- **CI/CD setup?** See [Xcode Cloud guide](../../docs/xcode-cloud.md)

Overview

This skill sets up Fastlane to automate building, testing, and releasing iOS and macOS apps. It provides a one-time project configuration that yields ready-to-run lanes for test, beta (TestFlight), and release (App Store) workflows. The setup includes environment checks, Homebrew-based Fastlane installation, and sample Appfile/Fastfile templates tailored to your project.

How this skill works

The skill inspects your project for Xcode project/workspace files, bundle ID, and team ID, then generates fastlane/Appfile and fastlane/Fastfile with lanes for test, beta, and release. It validates required tools (Xcode CLI, Homebrew, fastlane) and guides you to install missing components. Optional steps fetch existing App Store metadata and screenshots into fastlane/metadata for local editing.

When to use it

  • You want repeatable, scriptable iOS/macOS build and release flows.
  • You need a simple way to run tests, upload to TestFlight, or submit to the App Store.
  • You are scripting CI/CD pipelines and require deterministic build steps.
  • You want to manage App Store metadata and screenshots in source control.
  • You need to quickly onboard a project to Fastlane with minimal configuration.

Best practices

  • Install Fastlane via Homebrew to avoid Ruby dependency conflicts from Bundler.
  • Confirm project scheme name and replace {{SCHEME}} in Fastfile before running lanes.
  • Store fastlane configuration and metadata in your repository for traceability.
  • Use increment_build_number and explicit export_method in lanes to ensure reproducible builds.
  • If you hit code signing issues, enable or configure match (Fastlane’s code signing helper) rather than manual fixes.

Example use cases

  • Local developer runs fastlane ios test to validate changes before pushing.
  • Release manager runs fastlane ios beta to upload a new build to TestFlight for QA.
  • Automation pipeline invokes fastlane ios release to build and deliver a submission to the App Store.
  • Team stores app descriptions and screenshots in fastlane/metadata and updates them before release.
  • CI job runs fastlane lanes after successful unit tests to automate deployment.

FAQ

What do I need installed before using this skill?

Ensure Xcode command line tools, Homebrew, and fastlane are installed. The setup script checks each and gives commands to install missing tools.

How do I set the app scheme and identifiers?

Replace placeholders in fastlane/Appfile and fastlane/Fastfile: set app_identifier, apple_id, team_id, and update the scheme name ({{SCHEME}}) to your app’s scheme.

Can I fetch my current App Store metadata?

Yes. Run fastlane deliver download_metadata and fastlane deliver download_screenshots to populate fastlane/metadata for editing and version control.