Fastlane - 让部署和发布更简单
前言
fastlane 是一个能够方便iOS和Android开发者来自动化进行一些乏味工作的工具,
例如: 产生截图,处理配置证书,发布应用等。
安装
命令行安装: sudo gem install fastlane
安装完后 fastlane -v 查看一下版本号,如果能查看到则表示没问题。
源文件安装: https://download.fastlane.tools/
初始化
切换到你的工程目录下,输入
fastlane init
根据提示输入你的AppleID
它会以你的账号登录,并检测你的工程配置。(Apple ID , App Name, App Identifier, Workspace)
确定之后,会在当前目录创建fastlane文件夹
我们打印一下fastlane文件夹里面的内容,有 Appfile, Deliverfile, Fastfile还有一些切图存放文件夹和媒体数据等。
使用Gemfile
官方文档说 “建议你使用Gemfile来管理fastlane的依赖”。
- 安装 bundler
sudo gem install bundler
- 创建一个 ./Gemfile 文件,里面内容
source "https://rubygems.org"
gem "fastlane"
- 跑一下
bundler update,添加./Gemfile和./Gemfile.lock到版本控制中
这样基本的初始化工作也就完成了。
开始使用
1. 编译和导出ipa adhoc包
desc "编译和导出ipa adhoc包"
lane :export_adhoc_ipa do
increment_build_number
gym(
workspace: "CIExampleProject.xcworkspace",
configuration: "Release",
scheme: "CIExampleProject",
clean: true,
silent: true,
output_directory: "path/to/dir",
output_name: "my_app.ipa",
export_method: "ad-hoc",
codesigning_identity: "xxxxxx",
)
end
2.编译和上传adhoc到fir.im
desc "编译和上传adhoc到fir.im"
lane :upload_adhoc_ipa_firim do
increment_build_number
gym(
workspace: "CIExampleProject.xcworkspace",
configuration: "Release",
scheme: "CIExampleProject",
clean: true,
silent: true,
output_directory: "path/to/dir",
output_name: "my_app.ipa",
export_method: "ad-hoc",
codesigning_identity: "xxxxxx",
)
#上传到fir
firim(firim_api_token: "xxxxxx")
end
3.编译和上传到testflight
desc "编译和上传到testflight"
lane :upload_appstore_ipa_testflight do
increment_build_number
gym(
workspace: "CIExampleProject.xcworkspace",
configuration: "Release",
scheme: "CIExampleProject",
clean: true,
silent: true,
output_directory: "path/to/dir",
output_name: "my_app.ipa",
export_method: "app-store",
codesigning_identity: "xxxxxx",
export_options: {
"provisioningProfiles": {
"com.tdw.appid" => "xxxxxx"
}
}
)
#上传到fir
testflight
end