setup-fastlane

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fastlane Setup (One-Time)

Fastlane 一次性配置

┌─────────────────────────────────────────────────────────────────┐
│  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.                   │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│  ONE-TIME SETUP                                                 │
│  ══════════════                                                 │
│  配置完成后,你将拥有以下功能:                                       │
│                                                                 │
│    fastlane ios test    → 运行测试                             │
│    fastlane ios beta    → 上传至TestFlight                  │
│    fastlane ios release → 提交至App Store                   │
│                                                                 │
│  每个项目只需配置一次,耗时约10分钟。                   │
└─────────────────────────────────────────────────────────────────┘

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"
  • Xcode CLI: !
    xcode-select -p 2>/dev/null && echo "✓" || echo "✗ 执行:xcode-select --install"
  • Homebrew: !
    brew --version 2>/dev/null | head -1 || echo "✗ 执行:/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 "✗ 执行: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"
  • 项目文件: !
    find . -maxdepth 2 -name "*.xcodeproj" 2>/dev/null | head -1 || echo "未找到"
  • 工作区文件: !
    find . -maxdepth 2 -name "*.xcworkspace" ! -path "*/.build/*" ! -path "*/xcodeproj/*" 2>/dev/null | head -1 || echo "未找到"
  • Bundle ID: !
    grep -r "PRODUCT_BUNDLE_IDENTIFIER" --include="*.pbxproj" . 2>/dev/null | head -1 | sed 's/.*= //' | tr -d '";' || echo "未找到"
  • 团队ID: !
    grep -r "DEVELOPMENT_TEAM" --include="*.pbxproj" . 2>/dev/null | head -1 | sed 's/.*= //' | tr -d '";' || echo "未找到"

Target: ${ARGUMENTS:-current directory}

目标路径: ${ARGUMENTS:-当前目录}



Step 1: Install Fastlane

步骤1:安装Fastlane

bash
brew install fastlane
Why Homebrew? Bundler 4.x broke Fastlane's Ruby dependencies. Homebrew avoids all version conflicts.

bash
brew install fastlane
为什么选择Homebrew? Bundler 4.x 破坏了Fastlane的Ruby依赖,Homebrew可以避免所有版本冲突。

Step 2: Create Configuration Files

步骤2:创建配置文件

fastlane/Appfile

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
ruby
app_identifier("{{BUNDLE_ID}}")  # 你的Bundle ID
apple_id("{{APPLE_ID}}")         # 你的Apple ID邮箱
team_id("{{TEAM_ID}}")           # 你的团队ID

fastlane/Fastfile

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).

ruby
default_platform(:ios)

platform :ios do
  desc "运行测试"
  lane :test do
    scan(scheme: "{{SCHEME}}")
  end

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

  desc "提交至App Store"
  lane :release do
    increment_build_number
    gym(scheme: "{{SCHEME}}", export_method: "app-store")
    deliver(submit_for_review: false, force: true)
  end
end
{{SCHEME}}
替换为你的应用Scheme名称(通常是应用名称)。

Step 3: Set Up Metadata (Optional)

步骤3:配置元数据(可选)

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.

下载你已有的App Store应用信息:
bash
fastlane deliver download_metadata
fastlane deliver download_screenshots
这会创建
fastlane/metadata/
目录,其中包含可编辑的文本文件,用于存储应用描述、关键词等信息。

You're Done!

配置完成!

bash
undefined
bash
undefined

Verify setup

验证配置

fastlane lanes
fastlane lanes

Run your first lane

运行第一条lane

fastlane ios test
undefined
fastlane ios test
undefined

Quick Reference

快速参考

CommandWhat 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

命令功能
fastlane ios test
运行测试
fastlane ios beta
构建并上传至TestFlight
fastlane ios release
构建并提交至App Store
fastlane deliver download_metadata
获取App Store应用信息

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
  • 代码签名问题? 请查看:“配置Match进行代码签名”
  • 需要截图? 请查看:“自动化生成App Store截图”
  • CI/CD配置? 查看Xcode Cloud 指南