背景
公司使用Jenkins+Xcode integration插件構(gòu)建自動打包工具刁俭,在升級XCode9之后自動打包工具報錯橄仍。錯誤信息如下所示:
xcodebuild[10696:413621] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7fb3f664e8e0>: Error Domain=IDEDistributionSigningAssetStepErrorDomain Code=0 "Locating signing assets failed." UserInfo={NSLocalizedDescription=Locating signing assets failed., IDEDistributionSigningAssetStepUnderlyingErrors=(
"Error Domain=IDEProvisioningErrorDomain Code=9 \"\"NAME.app\" requires a provisioning profile with the Push Notifications feature.\" UserInfo={NSLocalizedDescription=\"NAME.app\" requires a provisioning profile with the Push Notifications feature., NSLocalizedRecoverySuggestion=Add a profile to the \"provisioningProfiles\" dictionary in your Export Options property list.}"
)}
error: exportArchive: "NAME.app" requires a provisioning profile with the Push Notifications feature.
Error Domain=IDEProvisioningErrorDomain Code=9 ""NAME.app" requires a provisioning profile with the Push Notifications feature." UserInfo={NSLocalizedDescription="NAME.app" requires a provisioning profile with the Push Notifications feature., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}
原因
引用onevcat 大神的一句話:XCode9將不會允許你訪問鑰匙串里的內(nèi)容,除非設置allowProvisioningUpdates
牍戚。原文在這里侮繁,感興趣的可以去閱讀。
解決方案
自己動手寫腳本替代插件(插件本質(zhì)是幫助我們生成打包腳本代碼)如孝。對xcodebuild
命令感興趣的可以在terminal中輸入man xcodebuild
命令查看詳細信息鼎天。
xcodebuild -archivePath "/Users/chaos/.jenkins/workspace/Project/output/debug/name.xcarchive" -workspace name.xcworkspace -sdk iphoneos -scheme "schemename" -configuration "Release" archive
xcodebuild -exportArchive -archivePath "/Users/chaos/.jenkins/workspace/Project/output/debug/name.xcarchive" -exportPath "/Users/chaos/.jenkins/workspace/Project/ipa/debug/" -exportOptionsPlist '/Users/chaos/.jenkins/workspace/Project/ipa/debug/ExportOptions.plist' -allowProvisioningUpdates
下面對腳本解釋下:"/Users/chaos/.jenkins/workspace/Project"
是本地代碼文件所在路徑(需要根據(jù)實際代碼存放位置靈活改變)"output/debug/name.xcarchive"
是存放archive生成的xcarchive類型文件的路徑(name自定義,建議和工程名一致)暑竟;-workspace name.xcworkspace -sdk iphoneos -scheme "schemename"
(name&&schemename需要根據(jù)工程文件來自定義)斋射;
exportArchive
就是上面xcarchive類型文件的存儲路徑;exportPath
就是導出的ipa包存放的路徑但荤;exportOptionsPlist
代表包含導出的ipa包的配置信息的文件存放路徑罗岖;allowProvisioningUpdates
就是獲取訪問鑰匙串權(quán)限的關(guān)鍵所在,設置了這個字段就會在打包過程彈框請求獲取鑰匙串內(nèi)容權(quán)限腹躁。
接著對ExportOptions.plist
文件展開說明:
com.xx.cc
代表Bundle ID桑包,緊接著ProfileName
代表對應描述文件的nameteamID
的值可以在鑰匙串中選中當前使用的證書查看。手動生成這樣的plist文件過于麻煩纺非,不如讓XCode幫我們生成哑了。使用XCode9打包并導出后的文件夾里就有這樣一份文件可以直接拿過來用。