在每次添加udid时,都需要手动去开发者网站更新PP文件,下载配置到Xcode和更新PP文件到jenkins所有工程。是一个很耗时的操作。
使用fastlane match可在小组成员之间更方便的统一管理证书和PP文件。
分步指南
-
安装fastlane:
① Make sure you have the latest version of the Xcode command line tools installed:xcode-select --install
②Choose your installation method:
Installer ScriptRubygemsmacOS macOS macOS or Linux with Ruby 2.0.0 or above brew cask install fastlane
Download the zip file. Then double click on the install
script (or run it in a terminal window).sudo gem install fastlane -NV
若brew cask install fastlane安装不成功,可使用sudo gem install fastlane -NV。
对每个工程配置fastlane(先拉取仓库代码,看同事对某个工程是否已配置好了fastlane,若已配置,只需要执行fastlane pps同步证书和pp文件即可),同步证书和PP文件到证书仓库用命令行进入需要配置的工程目录,执行fastlane init,根据提示输入公司开发者账号dev@xx.com,和密码(注意:请检查Xcode登录的账号是否是
platform :ios do
before_all do
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
#cocoapods #注意,此处必须手动修正:在最左边加#注释掉,否则更新pods可能导致多工程时编译失败。
end
,注意:只需要修改appID为新项目的appIDs(一个工程多个target有不同id的话用中括号括起来,英文逗号分隔)。
在续费账号或每次添加udid时:
管理员在自己电脑上更新证书和pp时;更新方法是进入具体工程目录,然后执行
fastlane pps,成功后可在Xcode上手动指定PP文件。
desc "update profile of appstore,adhoc,dev when udid added or renew dev account"
lane :pps do
match(git_url: "ssh://gitxx/ioscertificates.git",type: "appstore")
match(git_url: "ssh://gitxx/ioscertificates.git",type: "development",app_identifier: ["com.xx"
#,"tools.fastlane.app.today_widget" #Handle multiple targets
],force_for_new_devices: true)
match(git_url: "ssh://git@git.xx/ioscertificates.git",type: "adhoc",force_for_new_devices: true)
end
desc "sync profile of appstore,dev when admin has update cert and pps"
lane :syn do
match(git_url: "ssh://git@git.xx/ioscertificates.git",type: "appstore",readonly: true)
match(git_url: "ssh://git@git.xx/ioscertificates.git",readonly: true)
end
2.切到每个具体的子工程目录,用命令行执行:fastlane syn
选做:为了再以后执行 fastlane pps 或 fastlane match development/adhoc/appstor时不再手动输入证书仓库,执行一次
fastlane match init
指定仓库 ssh://xx.git,会自动生成本地文件Matchfile到fastlane文件夹中,以后执行fastlane match xx 就不会提示输入证书仓库了,也便于以后jenkins相关自动化流程改进。
执行fastlane pps时如果还让指定证书库地址,指定如下:
[14:51:50]: To not be asked about this value,you can specify it using 'git_url'
URL to the git repo containing all the certificates: ssh://xx/ioscertificates.git
如果提示输入passphase时,根据提示,两次输入123456(这是第一次创建证书仓库时输入的加密密码,为何创建详见 https://codesigning.guide),会提示成功解密证书仓库。然后会自动创建或导入证书和创建或导入或更新PP文件,
最后会提示成功,信息如下:
fastlane.tools just saved you 11 minutes!
此时dev,adhoc,appstore版本的PP文件都已在开发者网站更新并且自动下载到本地和上传到证书仓库了!
https://github.com/fastlane/fastlane/tree/master/match
可能遇到的问题:
1.执行fastlane init时提示: Connection reset by peer - SSL_connect
A:解决办法:
[11:43:54]: - download fastlane at https://download.fastlane.tools
[11:43:54]: -----------------------------------------------------------
[11:43:54]: - extract the archive and double click the `install`
A:导致的原因是:生成证书的电脑使用的开发者证书和新机器的开发者证书不同,导致此问题。