1.安装fastlane
# 以下方式二选一
sudo gem install fastlane
brew cask install fastlane
# 安装成功后,使用以下命令校验
fastlane -v
2.初始化fastlane
# 定位到项目的根目录
cd yourProjectRootPath
# 初始化
fastlane init
# 初始化的时候会提示以下四个选项:
1. 📸 Automate screenshots
2. 👩✈️ Automate beta distribution to TestFlight (自动testfilght型配置)
3. 🚀 Automate App Store distribution (自动发布型配置)
4. 🛠 Manual setup - manually setup your project to automate your (需要手动配置内容)
# 对fastlane不是很熟悉的请不要选4,这里我选的是3
# 然后按照提示一步一步往下走
# 整个安装和初始化流程到这就结束了,中间不免会出现错误
# 遇到错误一步一步排查就好了,也可以放在评论区,大家一起看看
# 其中
3.Fastfile文件配置
#以下是我的Fastfile的简单配置
default_platform(:ios)
platform :ios do
desc "自动打包上传至蒲公英或者AppStore"
# 自动打包上传至AppStore
lane :release do
build_app(
export_method: "app-store",
workspace: "ProjectName.xcworkspace",
scheme: "SchemeName",
output_directory: "../Packages"
)
upload_to_app_store(
skip_metadata: true,
skip_screenshots: true
)
end
# 自动打包上传至蒲公英
lane :adhoc do
build_app(
export_method: "ad-hoc",
workspace: "ProjectName.xcworkspace",
scheme: "SchemeName",
output_directory: "../Packages"
)
pgyer(
api_key: "your pgyer api key",
user_key: "your pgyer user key",
update_description: "发版说明"
)
end
end
4.一键打包终端使用
# 打开shell 执行以下命令
fastlane adhoc # 自动打包上传至蒲公英
fastlane release #自动打包上传至AppStore
5.错误说明
# 1.在执行一键打包并上传至蒲公英的时候,无法识别pgyer这个action.
# 这时候就需要安装蒲公英的相关插件了,执行以下命令即可
fastlane add_plugin pgyer
fastlane官方文档
fastlane详细介绍
Learn more about how to automatically generate localized App Store screenshots
Learn more about distribution to beta testing services
Learn more about how to automate the App Store release process
Learn more about how to setup code signing with fastlane