fastlane match 根據(jù)p12文件手動生成Match管理需要的證書。
最近項(xiàng)目的情況是,由于公司產(chǎn)品發(fā)布的appstore賬戶的切換后,該appstore上已經(jīng)存在了3個(gè)賬戶,已經(jīng)無法生成match管理的證書了。只發(fā)了一個(gè)p12的正式的證書。
下面的根據(jù)上面的情況,做的流程。
注意:因?yàn)檫€有一個(gè)包含fastlane上傳appstore的記錄在本文中,所以看上去會有點(diǎn)亂。
Fastlane 配置上傳至AppStore相關(guān)
生成appstore證書
fastlane match appstore
工具集說明如下:
1. scan
自動運(yùn)行測試工具,并且可以生成HTML文檔報(bào)告
2. cert
自動創(chuàng)建和管理iOS簽名證書(Certificates)
3. sigh
創(chuàng)建、更新、下載、修復(fù)Provisioning Profiles的工具
4. pem
自動生成、更新推送配置文件
5. snapshot
使用Xcode7的UITest功能實(shí)現(xiàn)自動化截圖
6. frameit
把截取的圖片套上一層外邊框
7.gym
自動化編譯工具,用來打包ipa或者pkg文件
8.deliver
自動上傳截圖、App的元數(shù)據(jù)、二進(jìn)制(ipa)文件到iTunes Connect
9.produce
在iTunes Connect或者Apple Developer Center上創(chuàng)建新的iOS應(yīng)用程序
上傳至AppStore 需要創(chuàng)建:deliver
安裝方法:
sudo gem install deliver
初始化:deliver
fastlane deliver
報(bào)錯(cuò)信息:
[!] The request could not be completed because:
Could not set team ID to 'XXX', only found the following available teams:
- 1********* (Mo**** ****** ***** (****) Co., Ltd.)
- 1********* (Si**** ****** ***** ***** Co., Ltd.)
原因是:team ID to 'XXX'不對
修改id后成功,生成:metadata獲取appconnect上面填寫的基本信息, screenshots文件夾,是截屏的圖片保存
這里有個(gè)小問題,iTC和ADC中的Team ID是不一樣的,在fastlane init中只會自動在Appfile里寫入ADC的team_id,所以在這個(gè)過程中會不停的問你iTC的Team ID,所以在創(chuàng)建完Appfile后,手動在里面添加itc_team_id。
app_identifier "com.**.**" # The bundle identifier of your app
username "njafei@163.com" # your Apple ID user
force true #don’t show me the preview html
submit_for_review false # 這個(gè)開關(guān)就是控制是否要展示的
根據(jù)p12證書生成match需要的證書
根據(jù)p12證書生成match需要的證書
p12證書的密碼:123456
1. 拿到你想要復(fù)用證書的ID
關(guān)于這個(gè)證書ID,從鑰匙串和openssl工具庫中沒有找到方法來取到,但是可以通過spaceship這個(gè)庫來實(shí)現(xiàn),下面是相關(guān)腳本:
這個(gè)腳本為fastlane里面的,需要單獨(dú)創(chuàng)建;
命令:
fastlane spaceship
報(bào)錯(cuò)提示:Could not find gem 'pry'
安裝:
sudo gem install pry
這是一個(gè)ruby腳本,需要創(chuàng)建ruby腳本,然后在運(yùn)行這個(gè)腳本:
require 'spaceship'
Spaceship.login('38****@qq.com') #自己的AppID賬號
Spaceship.select_team
Spaceship.certificate.all.each do |cert|
cert_type = Spaceship::Portal::Certificate::CERTIFICATE_TYPE_IDS[cert.type_display_id].to_s.split("::")[-1]
puts "Cert id: #{cert.id}, name: #{cert.name}, expires: #{cert.expires.strftime("%Y-%m-%d")}, type: #{cert_type}"
end
執(zhí)行上面代碼,會輸出所有證書的相應(yīng)信息,你可以從中找到你想復(fù)用的那個(gè)證書的ID。
? 推送證書相關(guān) touch get_cer_id.rb
? 推送證書相關(guān) open .
? 推送證書相關(guān) ruby get_cer_id.rb
Multiple teams found on the Developer Portal, please enter the number of the team you want to use:
1) 247W*****8R "M****n ***** **** (****) Co., Ltd." (Company/Organization)
2) 68Y******86 "S****** C****y **** Technology Co., Ltd." (Company/Organization)
1
Cert id: 3********, name: iOS Development, expires: 2019-05-18, type: Development
Cert id: D*******, name: iOS Distribution, expires: 2019-05-18, type: Production
Cert id: 2*******, name: iOS Development, expires: 2019-08-31, type: Development
Cert id: 4********, name: iOS Development, expires: 2019-09-04, type: Development
Cert id: X*********, name: APNs Development iOS, expires: 2019-09-04, type: DevelopmentPush
Cert id: T*********, name: Apple Push Services, expires: 2019-10-04, type: ProductionPush
Cert id: 9*******, name: iOS Distribution, expires: 2019-09-04, type: Production
Cert id: 2*******, name: iOS Development, expires: 2019-09-19, type: Development
Cert id: X********, name: iOS Distribution, expires: 2019-12-27, type: Production
Cert id: Y********, name: APNs Development iOS, expires: 2020-05-06, type: DevelopmentPush
Cert id: R*******, name: Apple Push Services, expires: 2020-06-05, type: ProductionPush
Cert id: Y******, name: iOS Development, expires: 2020-05-06, type: Development
? 推送證書相關(guān)
生成加密的證書:
從Apple Developer中下載現(xiàn)有的證書及mobileprovision文件,將證書導(dǎo)入到鑰匙中,并生成p12文件。得到的證書和配置文件還不能被match識別,需要通過加密命令加密后才符合match的驗(yàn)證要求,其中使用到的命令有:
備注: bundleid 的綁定是根據(jù)match文件里面的bundleid來匹配的
1、 生成key.pem文件;加密證書
執(zhí)行生成.pem文件,p12證書為想使用的p12證書,如果在哪個(gè)路徑下面在執(zhí)行這個(gè),會在當(dāng)面目錄下生成pem的文件
openssl pkcs12 -nocerts -nodes -out dev_key.pem -in dev.p12
2、生成最后需要的證書
2.1 生成:cret_id.p12文件
2.2 生成:certificate.cer文件
openssl aes-256-cbc -k <your_password> -in dev_key.pem -out <cert_id>.p12 -a
openssl aes-256-cbc -k <your_password> -in dev.cer -out <cert_id>.cer -a
pem.key 的密碼是:123456
dev: 123456
dis: 123456
到此配置基本結(jié)束,但是還有工作沒有完成,很重要需要:
fastlane match nuke development
fastlane match nuke distribution
fastlane match nuke appstore
如果這里遇到問題,刪除不了的話,就只有手動去開發(fā)網(wǎng)站刪除。后再次創(chuàng)建描述文件就可以了:
fastlane match adhoc
fastlane match development
fastlane match appstore
總結(jié):
- 最大的問題是因?yàn)閷atch的證書的反制作過程不了解原理
- 根據(jù)p12文件,安裝到本地的keychain中,然后對其進(jìn)行導(dǎo)出一個(gè)dis.cer文件,因存在dis.p12文件而不用再次導(dǎo)出。
- 因?yàn)閐ev的證書是直接從appstore中下載的,所以需要導(dǎo)出一個(gè)dev.cer文件,一個(gè)dev.p12文件
- 關(guān)于沒個(gè)創(chuàng)建證書的時(shí)候會填寫的creat_id是根據(jù)那個(gè)ruby腳本獲取到的信息里找到到期時(shí)間匹配的id
文章寫的有點(diǎn)亂,可能有錯(cuò)誤的地方,因時(shí)間關(guān)系,沒有做仔細(xì)的校驗(yàn)工作。
如有問題請issue me