fastlane
作者:Felix Krause
开源:fastlane
准备知识:command line, code signing and iTunes Connect
ps: 如果这些不会,可以阅读教程
Getting Started
- 下载开始项目
- 修改Bundle Identifier
- 环境要求:
- OS X 10.9 (Mavericks) or newer
- Ruby 2.0 or newer
- Xcode Command Line Tools (CLT)
- Paid Apple Developer Account
OS X 10.9 (Mavericks) or newer 自带Ruby 2.0
命令行输入查看:
ruby -v
验证Xcode CLT是否安装:
xcode-select --install
如果已经安装,出现command line tools are already installed, use "Software Update" to install updates.
如果没有安装,则提示安装。
- 安装fastlane
命令行输入:sudo gem install -n /usr/local/bin fastlane --verbose
fastlane 安装位置为什么是
/usr/local/bin
,请阅读About System Integrity Protection on your Mac
The fastlane Toolchain
fastlane包含了下列工具集:
-
produce
在iTunes Connect 和 Apple Developer Portal创建新的iOS apps -
cert
自动创建和维护 iOS code signing certificates -
sigh
创建,更新,下载和修复provisioning profiles -
snapshot
自动拍摄iOS app 在每一个设备的 localized screenshots -
frameit
将screenshots放入正确的设备窗口中 -
gym
编译和打包iOS app -
deliver
上传screenshots, metadata 和 apps 到 App Store -
pem
自动生成和更新push notification profiles -
spaceship
是一个Ruby 库,能够使用 Apple Developer Center 和 iTunes Connect 的APIs -
pilot
自动部署TestFlight并管理 beta testers -
boarding
邀请 beta testers -
match
使用Git同步certificates 和 provisioning profiles -
scan
运行tests
Setting up fastlane
命令行依次输入:
- 进入mZone 项目:
cd 项目位置
- 创建fastlane:
fastlane init
如果得到
permission denied
错误,请在命令前加入sudo
- 输入Apple ID 和 密码
如果出现
Connection reset by peer - SSL_Connect
错误
按照提示更新ruby版本,命令行依次输入:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update && brew install ruby
-
sudo gem install fastlane --verbose
如果出现
This app identifier doesn't exist on iTunes Connect yet, it will be created for you This app identifier doesn't exist on the Apple Developer Portal yet, it will be created for you Please confirm the above values (y/n)
则输入y
确认
如果出现
It looks like that mZone Poker has already been taken by someone else, please enter an alternative App Name:
则为app 输入一个名字
- 相关文件
- Appfile 储存app identifier 和 your Apple ID
- Fastfile 管理lanes包含的actions
- Deliverfile 添加提交到App Store 的metadata
1.在metadata文件夹只有en-US
,如需配置另一种语言,需要复制一份并重新命名,比如fr-FR
2.其他文件根据项目填写
3.创建名为itunes_rating_config.json
的json
文件,让iTunes Connect 知道rating criteria,内容为:
{
"CARTOON_FANTASY_VIOLENCE": 0,
"REALISTIC_VIOLENCE": 0,
"PROLONGED_GRAPHIC_SADISTIC_REALISTIC_VIOLENCE": 0,
"PROFANITY_CRUDE_HUMOR": 0,
"MATURE_SUGGESTIVE": 0,
"HORROR": 0,
"MEDICAL_TREATMENT_INFO": 0,
"ALCOHOL_TOBACCO_DRUGS": 0,
"GAMBLING": 2,
"SEXUAL_CONTENT_NUDITY": 0,
"GRAPHIC_SEXUAL_CONTENT_NUDITY": 0,
"UNRESTRICTED_WEB_ACCESS": 0,
"GAMBLING_CONTESTS": 0
}
4.向metadata目录添加AppIcon
的图片
5.其他fastlane设置 键列表
Creating Certificates and Provisioning Profiles
- 修改Fastfile,内容为:
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.6.0"
default_platform :ios
platform :ios do
# 1 lane 的描述
desc "Creating a code signing certificate and provisioning profile"
# 2 命名这个lane为provision
lane :provision do
# 3 在iTunes Connect 和 the Developer Portal 创建app
produce(
app_name: 'YOUR_UNIQUE_APP_NAME',
language: 'English',
app_version: '1.0',
sku: '123abc'
)
# 4 创建私有密钥和签名请求,下载并安装产生的证书,导入在keychain生成的文件
cert
# 5 生成 provisioning profile,force: true表示每次运行都创建provisioning profile,默认为distribution profile。使用sigh(adhoc: true) 创建ad hoc profile, 使用sigh(development: true) 创建 development profile
sigh(force: true)
end
error do |lane, exception|
# This block is called if there was an error running a lane.
end
end
- 保存文件,命令行输入:
fastlane provision
- 登录 iTunes Connect,可以看到刚才创建的app
- 在Xcode 中使用创建的 provisioning profile
1.在Target\Build Settings\Code Signing
设置provisioning profile为新创建的
2.在Target\General
关闭Automatically manage signing,在Signing (Debug) 和 Signing (Release) 选择与刚才相同的 provisioning profile
Screenshots Made Easy
- 命令行输入:
fastlane snapshot init
- 生成名为Snapfile的文件,修改内容为:
# A list of devices you want to take the screenshots from
devices([
"iPhone 5",
"iPhone 6",
"iPhone 6 Plus"
])
# A list of supported languages
languages([
'en-US',
'fr-FR'
])
# Where should the resulting screenshots be stored?
output_directory "./fastlane/screenshots"
# Clears previous screenshots
clear_previous_screenshots true
# Latest version of iOS
ios_version '10.1'
为什么没有 iPhone 7 和 iPhone 7 Plus 呢?
因为与 iPhone 6 and iPhone 6 Plus 相同
- 保存并关闭文件,回到终端,按照提示依次:
- 添加一个新的 UI Test target
- 将 SnapshotHelper.swift 文件拖入 UI Test target
- 打开mZone_PokerUITests.swift文件,删除 setUp 和 tearDown 方法,在
testExample
方法添加以下代码:
// 1
let app = XCUIApplication()
setupSnapshot(app)
app.launch()
// 2
let chipCountTextField = app.textFields["chip count"]
chipCountTextField.tap()
chipCountTextField.typeText("10")
// 3
let bigBlindTextField = app.textFields["big blind"]
bigBlindTextField.tap()
bigBlindTextField.typeText("100")
// 4
snapshot("01UserEntries")
// 5
app.buttons["what should i do"].tap()
snapshot("02Suggestion")
- 在Fastfile添加:
desc "Take screenshots"
lane :screenshot do
snapshot
end
- 保存并退出,打开终端输入:
fastlane screenshot
- 完成后,自动打开screenshots.html文件查看
Creating the IPA file
- 在Fastfile文件添加:
desc "Create ipa"
lane :build do
increment_build_number
gym
end
- 保存并退出,打开终端输入:
fastlane build
Seamless Delivery
- 在Fastfile文件添加:
desc "Upload to App Store"
lane :upload do
deliver
end
- 保存并退出,打开终端输入:
fastlane upload
- 预览 HTML,“Does the Preview on path ‘./Preview.html’ look okay for you? (y/n)”,没问题了就选y
- 登录iTunes Connect查看,点击Submit for Review
直接上传:
- 修改lane
desc "Upload to App Store and submit for review"
lane :upload do
deliver(
submit_for_review: true
)
end
- 修改Deliverfile文件内容为:
# 1 免费app
price_tier 0
# 2 review 信息
app_review_information(
first_name: "YOUR_FIRST_NAME",
last_name: "YOUR_LAST_NAME",
phone_number: "YOUR_PHONE_NUMBER",
email_address: "YOUR_EMAIL_ADDRESS",
demo_user: "N/A",
demo_password: "N/A",
notes: "No demo account needed"
)
# 3 提交信息
submission_information({
export_compliance_encryption_updated: false,
export_compliance_uses_encryption: false,
content_rights_contains_third_party_content: false,
add_id_info_uses_idfa: false
})
# 4 审核通过后手动release
automatic_release false
# 5 提供app icon 文件
app_icon './fastlane/metadata/AppIcon.png'
# 6 提供 iTunes Rating Configuration 文件
app_rating_config_path "./fastlane/metadata/itunes_rating_config.json"
- 命令行输入:
fastlane upload
Putting it All Together
- Fastfile文件添加内容:
desc "Provision, take screenshots, build and upload to App Store"
lane :do_everything do
provision
screenshot
build
upload
end
- 命令行输入:
fastlane do_everything