iOS自动打包 - fastlane
2020-06-24 本文已影响0人
只会ctrl_c_v
- 安装xcode命令行工具
xcode-select --install
,如果没有安装,会弹出对话框,点击安装。如果提示xcode-select: error: command line tools are already installed, use "Software Update" to install updates表示已经安装
一、安装(ruby和Xcode 命令行工具存在的前提)
sudo gem install fastlane
二、fastlane初始化
- cd到你的项目目录
- 终端执行以下命名
fastlane init
image.png
这个地方会要你选择。
1.自动截屏。
2.自动发布beta版本用于TestFlight
3.App Store自动发布包
4.手动配置
自行选择就好,如果选了3
- 然后按要求把自己的 开发者账号 和 密码、二次验证等信息对应写入
do you want fastlane tocreate the app id for you on the apple developer protal?(y/n)
--这里是,是否在Apple Develper创建应用 -- 写入n
Would you like fastlane to create the app on itunes connect for your?(y/n)
-- 是否在itunes connect创建应用 -- 写入n
- Installing dependencies for you ...
bundle update ---- 一直卡在这,不知道啥原因。我直接关闭了。fastlane 能正常使用
二、找到项目目录,会有个fastlane文件夹
- Appfile: 存放App的app_id team_id app_identifier等信息
- Deliverfile: 发布的配置信息
- Fastfile: fastlane的配置文件
default_platform(:ios) platform :ios do desc "发布到蒲公英" lane :pgyBuild do gym( clean:true, scheme:"项目名称", export_method:"development", configuration: "Debug",#环境 output_directory:"./build", ) pgyer( api_key: "xxxxxxxxxxxx", #在蒲公英申请的 user_key: "xxxxxxxxxxxx", #在蒲公英申请的 update_description: "fix something" ) end desc "上传到 App Store" lane :release do gym( clean:true, scheme:"项目名称", export_method:"app-store", export_xcargs: "-allowProvisioningUpdates", output_directory:"./build", ) deliver( submit_for_review: false # 提交审核 ) end end
- clean:是否清空以前的编译信息
- scheme:自己项目名称
- export_method:就是我们手动打包时要选择的那四种(app-store,ad-hoc,enterprise,development)
- configuration:环境(Debug、Release)
- output_directory:打包后的 ipa 文件存放的目录
- export_xcargs:访问钥匙串
- submit_for_review:是否提交审核,true表示立马提交审核
- api_key、user_key:蒲公英信息
常用action管理
#下载证书
fastlane sigh #生产环境
fastlane sigh --adhoc #发布测试环境
fastlane run register_device #新增测试手机UDID
// input name
// input device uiid
fastlane sigh --development --force #新增测试手机id后,更新证书
#以上所有 lane 可以写成 lane action 按自己配置
#打包 hoc-ipa
lane :adhoc do
#build_app 是gym的别名,可以换成gym
build_app(
scheme: "Demo", #工程下要打包的项目,如果一个工程有多个项目则用[项目1,项目2]
export_method: "ad-hoc",
#output_directory: './build', #指定ipa最后输出的目录 - 可省略默认项目目录下
)
end
调用方式
fastlane adhoc #在项目目录下执行 `adhoc` --是每个 lane 的 action name如上 lane :adhoc do