iOS Jenkins打包遇到的坑

使用的打包命令:

xcodebuild archive -workspace $project_name.xcworkspace -scheme $project_name -configuration Release -archivePath archive/$project_name.xcarchive CODE_SIGN_IDENTITY="iPhone Developer: xxxxxx (xxxxxxx)" PROVISIONING_PROFILE_SPECIFIER="development_orange"

echo "第五步,執(zhí)行編譯生成.ipa命令"

xcodebuild -exportArchive -exportOptionsPlist archieveOpt.plist -archivePath archive/$project_name.xcarchive -exportPath ./ -configuration Release

打包命令在這里不多做解釋,主要說一下遇到的兩個坑.

參考文章:

第三方庫使用 Framework,用 Jenkins 打包時報錯

iOS 命令打包

坑一:Podfile 文件中使用了 use_frameworks!造成的坑

如果Podfile 文件中使用了 use_frameworks,那么Jenkins打包時出現(xiàn)以下錯誤

Check dependencies

Code Signing Error: AFNetworking does not support provisioning profiles. AFNetworking does not support provisioning profiles, but provisioning profile development_orange has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.

這是因為使用了 use_frameworks后,CocoaPods 要對每一個 Framework 進(jìn)行證書簽名,而每個 Framework 的 bundleID 都是不一樣的

解決方案:

在 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文件如下:

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 'QingPu' do

? ? pod 'MBProgressHUD'

? ? pod 'MJExtension','~> 3.0.13'

? ? pod 'MJRefresh'

? ? pod 'ReactiveObjC'

? ? pod 'FMDB', '~> 2.7.2'

end

坑二:Archive成功,export ipa文件時失敗,報以下錯誤:error: exportArchive: The data couldn’t be read because it isn’t in the correct format?

Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/7p/06ytfm5n5f35z9d4byf0q1_c00007x/T/ipatool-json-filepath-lgeLRm}

第五步,執(zhí)行編譯生成.ipa命令

2018-05-18 15:22:27.811 xcodebuild[32828:2936854] [MT] IDEDistribution: Step failed: : Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/7p/06ytfm5n5f35z9d4byf0q1_c00007x/T/ipatool-json-filepath-lgeLRm}

error: exportArchive: The data couldn’t be read because it isn’t in the correct format.

Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/7p/06ytfm5n5f35z9d4byf0q1_c00007x/T/ipatool-json-filepath-lgeLRm}

** EXPORT FAILED **

這是因為配置文件archieveOpt.plist中compileBitcode選項沒有配置,默認(rèn)compileBitcode為YES,要設(shè)置成NO就可以了,archieveOpt.plist配置后的樣式如下:

再次打包就可以了

坑三:jenkins 自動構(gòu)建 IOS 包簽名遇到問題 ??app: errSecInternalComponent?Command /usr/bin/codesign failed with exit code 1

解決辦法:

?編譯之前添加 security unlock-keychain -p "你的密碼" "path to keychain/login.keychain"


根本原因是Jenkins,ssh方式到slave機(jī)上,默認(rèn)是沒有賬戶的,但是訪問鑰匙串要求必須有用戶身份,所以添加一步輸入密碼解鎖鑰匙串,可以給Jenkins一個用戶身份。 build步驟前添加一步解鎖鑰匙串。?security unlock-keychain -p "login pwd" ~/Library/Keychains/login.keychain

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容