关于 setup-fastlane
为 iOS 项目配置 Fastlane 的技能,面向需要自动化测试及 App Store 发布的开发者。它检查项目配置并生成 Fastlane 文件,支持 TestFlight 和 App Store 流程。
主要功能
- 01检查 Xcode、Homebrew 和 Fastlane
- 02识别项目、工作区及应用标识
- 03创建 Appfile 和 Fastfile
- 04配置测试、Beta 和发布 lane
- 05下载 App Store 元数据与截图
适用场景
- 01为 iOS 项目配置 Fastlane
- 02运行测试并上传至 TestFlight
- 03准备 App Store 发布流程
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ greenstevester/ fastlane-skill --skill setup-fastlane安装后在 Claude Code 中输入/setup-fastlane确认已加载。
详细介绍
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. │
└─────────────────────────────────────────────────────────────────┘
环境检查
- 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"
你的项目
- 项目:!
find . -maxdepth 2 -name "*.xcodeproj" 2>/dev/null | head -1 || echo "None found" - 工作区:!
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"
目标:${ARGUMENTS:-current directory}
步骤 1:安装 Fastlane
brew install fastlane
为何使用 Homebrew? Bundler 4.x 破坏了 Fastlane 的 Ruby 依赖。Homebrew 可避免所有版本冲突。
步骤 2:创建配置文件
fastlane/Appfile
app_identifier("{{BUNDLE_ID}}") # Your bundle ID
apple_id("{{APPLE_ID}}") # Your Apple ID email
team_id("{{TEAM_ID}}") # Your team ID
fastlane/Fastfile
default_platform(:ios)
platform :ios do
desc "Run tests"
lane :test do
scan(scheme: "{{SCHEME}}")
end
desc "Upload to TestFlight (internal testers)"
lane :beta do |options|
increment_build_number unless options[:skip_build_increment]
gym(scheme: "{{SCHEME}}", export_method: "app-store")
pilot(skip_waiting_for_build_processing: true)
end
desc "Upload to TestFlight and distribute to external testers"
lane :beta_external do |options|
increment_build_number
gym(scheme: "{{SCHEME}}", export_method: "app-store")
pilot(
distribute_external: true,
groups: ["External Testers"],
changelog: options[:changelog] || "Bug fixes and improvements",
skip_waiting_for_build_processing: false
)
end
desc "Submit the latest TestFlight build for App Store review"
lane :release do
deliver(
build_number: latest_testflight_build_number.to_s,
submit_for_review: true,
automatic_release: false,
force: true,
skip_binary_upload: true,
skip_metadata: false,
skip_screenshots: false
)
end
desc "Build, upload, and submit a fresh build to the App Store"
lane :release_full do |options|
increment_version_number(version_number: options[:version]) if options[:version]
increment_build_number
gym(scheme: "{{SCHEME}}", export_method: "app-store")
deliver(
submit_for_review: true,
automatic_release: options[:auto_release] == true,
force: true
)
end
end
将 {{SCHEME}} 替换为你的 App scheme 名称(通常是 App 名称)。
步骤 3:设置元数据(可选)
下载你现有的 App Store 列表:
fastlane deliver download_metadata
fastlane deliver download_screenshots
这会创建 fastlane/metadata/,其中包含可编辑的文本文件,用于填写 App 描述、关键词等。
完成!
# Verify setup
fastlane lanes
# Run your first lane
fastlane ios test
快速参考
| 命令 | 功能 |
|---|---|
fastlane ios test | 运行测试 |
fastlane ios beta | 构建并上传到 TestFlight |
fastlane ios release | 构建并上传到 App Store |
fastlane deliver download_metadata | 获取 App Store 列表 |
后续步骤
- 遇到代码签名问题? 请询问:“设置 Match 以进行代码签名”
- 需要截图? 请询问:“自动生成我的 App Store 截图”
- 需要设置 CI/CD? 查看 Xcode Cloud 指南
评论
支持 Markdown