jenkins 自动打包环境搭建,大家可以自己去搜索。我这里只总结了两个问题。
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(钥匙串访问),检查左侧系统目录里是否包含你所使用的证书,如果没有,在登录目录里复制,并粘贴到系统目录
如果构建还是失败。
检查/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile 路径文件下是否包含你所需要的配置文件,如果没有,或者没有此路径,创建路径。并把/Users/xxx/Library/MobileDevice/Provisioning Profiles (xxx表示你自己的用户名)
路径下的文件复制到/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile 这个文件里。
2、Xcode9 打包时需要的ExportOptions.plist 里需要provisioningProfiles这个字段,这是一个字典。里面包含的参数key是APP的BundleID,value是provisioning profile 的name。
这个文件可以用Xcode9 手动导出包,里面就有需要的ExportOptions.plist文件,移动到你需要的路径即可
附上打包成功的脚本,上传到fir,用的是官方插件,这个也有很多教程,自行查找都可以。我的是Debug包
# 工程名
APP_NAME="XXX"
# 证书
CODE_SIGN_DISTRIBUTION="iPhone Developer: XXX"
#打包环境
CONFIGURSTION="Debug"
#工程文件路径 xxx略去中间路径,根据自己的补全
PROJECTPATH="/Users/Shared/Jenkins/Home/workspace/xxx"
# info.plist路径 xxx略去中间路径,根据自己的补全
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上,结果它太任性暂停业务了,最后改成插件上传到fir
自己摸索,试了好多次才成功,如果有什么问题,欢迎交流