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 (自動發(fā)布型配置)
4. ?? Manual setup - manually setup your project to automate your (需要手動配置內(nèi)容)
# 對fastlane不是很熟悉的請不要選4推沸,這里我選的是3
# 然后按照提示一步一步往下走
# 整個安裝和初始化流程到這就結(jié)束了糜工,中間不免會出現(xiàn)錯誤
# 遇到錯誤一步一步排查就好了添怔,也可以放在評論區(qū)瞳浦,大家一起看看
# 其中
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: "發(fā)版說明"
)
end
end
4.一鍵打包終端使用
# 打開shell 執(zhí)行以下命令
fastlane adhoc # 自動打包上傳至蒲公英
fastlane release #自動打包上傳至AppStore
5.錯誤說明
# 1.在執(zhí)行一鍵打包并上傳至蒲公英的時候,無法識別pgyer這個action.
# 這時候就需要安裝蒲公英的相關(guān)插件了蔓同,執(zhí)行以下命令即可
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