fastlane是一套ruby脚本工具, 用于实现iOS或Android的持续集成及自动化发布. fastlane的安装及更多相关介绍参见其Github:fastlane)).
本文使用的fastlane版本为2.47.0. 低版本可能会产生各种莫名其妙的问题. 配置fastlane时最好先翻墙,原因你懂的.
本文主要介绍使用fastlane命令行进行ipa打包及导出.
fastlane初始化
cd到项目目录, 执行命令:
fastlane init
按照提示输入AppleID, fastlane会自动与ITC(iTunes Connect)和ADP(Apple Developer Porta)同步项目信息, 并在项目目录下生成一个fastlane目录, 其结构如下:
ipa打包主要关注Fastfile
文件.
项目证书配置
项目中打开Automatically manage signing
, 使用Xcode自动管理证书. 否则, 之后在fastlane中还要进行证书相关的配置.
新建lane
在Fastfile
新建一个用于ipa打包的lane:
desc "ipa打包"
lane :createIpa do
# sigh(adhoc:true) #如果要使用ad-hoc打包, 则需打开此项配置
gym(scheme: "fastlane-ipa",
workspace: "fastlane-ipa.xcworkspace", # 可省略
configuration: "Release", # Debug or Release
clean: true, #清空上次打包信息
export_method:"development" # app-store, ad-hoc, package, enterprise, development, developer-id
)
#使用自动证书管理
enable_automatic_code_signing(path: "fastlane-ipa.xcodeproj")
end
参数说明:
- configuration: 指定编译方式为Debug 还是 Release, 默认为Release,
- export_method: 指定打包导出方式, 可以使用的值包括 app-store, ad-hoc, package, enterprise, development, developer-id
详细参数的参见文档: https://docs.fastlane.tools/actions/#building
执行lane
cd 到项目目录下, 执行命令:
fastlane createIpa
命令执行完成后, 可以在项目目录下找到自动生成的ipa文件,和dYSM的压缩包.