現在想必大多數公司都開始進行持續集成(CI)了。畢竟手工打包,重復勞動真的是太累。業內有很多持續集成的工具,我們公司用的是 Jenkins。然而使用過程中遇到了一個問題,花了我很長時間去解決,記錄一下,也方便當別人遇到時,快速解決。
本來項目用的是靜態庫,即.a
文件,如下:
靜態庫
但考慮到要和 Swift 混編,而 Swift 只能用 Framework,所以在Podfile
文件加了use_frameworks!
這樣一行,改成了使用 Framework。然后測試妹子對我說,Jenkins 不能打包了,我看了下,報錯信息大致如下:
No valid signing identities (i.e. certificate and private key pair) matching...
大致意思是:CocoaPods 要對每一個 Framework 進行證書簽名,而每個 Framework 的 bundleID 都是不一樣的。那就要換成通配證書。但通配證書會讓極光推送,地圖等功能失效,只能找其它的解決方案,最后在 CocoaPods 的 issues 里找到了解決方案。
在 Podfile
中添加如下代碼:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
完成后的 Podfile
大致如下:
# Podfile
platform :ios, '8.0'
use_frameworks!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
target 'TargetName' do
pod 'AFNetworking'
pod 'SDWebImage'
end
EOF~