Jenkins 打包遇到的問題及解決

jenkins 自動打包環(huán)境搭建,大家可以自己去搜索。我這里只總結(jié)了兩個問題。

1、Check dependencies
Code Signing Error: No certificate for team 'XXX' matching 'iPhone Developer: XXX' found:  Select a different signing certificate for CODE_SIGN_IDENTITY, a team that matches your selected certificate, or switch to automatic provisioning.
Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.1'

如果遇到類似的錯誤 解決辦法:
打開keychain keys(鑰匙串訪問),檢查左側(cè)系統(tǒng)目錄里是否包含你所使用的證書,如果沒有,在登錄目錄里復制,并粘貼到系統(tǒng)目錄

如果構(gòu)建還是失敗。

檢查/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile 路徑文件下是否包含你所需要的配置文件,如果沒有,或者沒有此路徑,創(chuàng)建路徑。并把/Users/xxx/Library/MobileDevice/Provisioning Profiles (xxx表示你自己的用戶名)
路徑下的文件復制到/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile 這個文件里。

2、Xcode9 打包時需要的ExportOptions.plist 里需要provisioningProfiles這個字段,這是一個字典。里面包含的參數(shù)key是APP的BundleID,value是provisioning profile 的name。
這個文件可以用Xcode9 手動導出包,里面就有需要的ExportOptions.plist文件,移動到你需要的路徑即可

附上打包成功的腳本,上傳到fir,用的是官方插件,這個也有很多教程,自行查找都可以。我的是Debug包

# 工程名
APP_NAME="XXX"

# 證書
CODE_SIGN_DISTRIBUTION="iPhone Developer: XXX"

#打包環(huán)境
CONFIGURSTION="Debug"

#工程文件路徑 xxx略去中間路徑,根據(jù)自己的補全
PROJECTPATH="/Users/Shared/Jenkins/Home/workspace/xxx"

# info.plist路徑 xxx略去中間路徑,根據(jù)自己的補全
 project_infoplist_path="/Users/Shared/Jenkins/Home/workspace/xxx/Info.plist"


echo "${project_infoplist_path}"
if [ ! -f "$project_infoplist_path" ]
then
echo "*************************************"
echo "***       plist文件路徑錯誤!    ****"
echo "*************************************"
exit
fi


#取版本號
bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${project_infoplist_path}")

echo "=================bundleShortVersion================="
#取版本號
bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${project_infoplist_path}")

echo "=================bundleVersion================="
#取build值
bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" "${project_infoplist_path}")

DATE="$(date +%Y%m%d)"
echo "=================DATE================="

IPANAME="${APP_NAME}_V${bundleShortVersion}_${DATE}.ipa"

#要上傳的ipa文件路徑
IPA_PATH="$HOME/${IPANAME}"
echo ${IPA_PATH}
echo "${IPA_PATH}">> text.txt

echo "=================clean================="
xcodebuild -workspace "${PROJECTPATH}/${APP_NAME}.xcworkspace" -scheme "${APP_NAME}" -configuration $CONFIGURSTION clean

# $security unlock-keychain -p "mypassword" /Users/qiaoyan/Library/Keychains/login.keychain

echo "+++++++++++++++++build+++++++++++++++++"
xcodebuild -workspace "${PROJECTPATH}/${APP_NAME}.xcworkspace" -scheme "SwiftShop" -sdk iphoneos -configuration $CONFIGURSTION SYMROOT='$(PWD)'


echo "=================生成 .xcarchive================="
xcodebuild archive -workspace "${PROJECTPATH}/${APP_NAME}.xcworkspace" -scheme ${APP_NAME} -configuration '$CONFIGURSTION CODE_SIGN_IDENTITY="${CODE_SIGN_DISTRIBUTION}" -archivePath "${WORKSPACE}/build/${APP_NAME}.xcarchive"

echo "=================導出.ipa================="
xcodebuild -exportArchive -archivePath "${WORKSPACE}/build/${APP_NAME}.xcarchive"  -exportPath "${IPA_PATH}" -exportOptionsPlist "/Users/Shared/Jenkins/Home/jobs/xxx/ExportOptions.plist" -allowProvisioningUpdates

# APP_ID="xxx"

# APP_KEY="xxx"

#要上傳的ipa文件路徑IPA_PATH="/Users/xxkj/.jenkins/workspace/c-ios-Debug/Build/${IPANAME}"

# curl --insecure -X "PUT" -F "file=@${IPA_PATH}/SwiftShop.ipa" -F "app_id=${APP_ID}" -F "title=${IPANAME}" https://api.bugly.qq.com/beta/apiv1/exp?app_key=${APP_KEY}
#本來想上傳到bugly上,結(jié)果它太任性暫停業(yè)務(wù)了,最后改成插件上傳到fir
1.jpg

自己摸索,試了好多次才成功,如果有什么問題,歡迎交流

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容