问题
使用 Jenkins 来做 iOS 项目的持续集成,升级 Xcode 9 之后,编译完成之后打包会一直报如下所示的错误:
error: exportArchive: "APPNAME.app" requires a provisioning profile with the Push Notifications feature.Error Domain=IDEProvisioningErrorDomain Code=9 ""APPNAME.app" requires a provisioning profile with the Push Notifications feature." UserInfo={NSLocalizedDescription="APPNAME.app" requires a provisioning profile with the Push Notifications feature., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}** EXPORT FAILED **Failed to build /Users/Tolecen/.jenkins/workspace/APPNAME/build/APPNAME_release.ipaBuild step 'Xcode' marked build as failureFinished: FAILURE
原因
因为 Xcode 9 默认不允许访问钥匙串的内容,必须要设置 allowProvisioningUpdates 才会允许,但是由于 Xcode integration 插件封闭,并不能对其进行修改加上这个属性,所以决定使用 Shell 脚本代替插件
解决方案
将 Jenkins 项目里的 Xcode integration 构建步骤去掉,使用下面所示的命令: 如果是 project 的项目,那就将下面第一段的命令中 -workspace ${PROJECT_NAME}.xcworkspace 修改为 -workspace ${PROJECT_NAME}.xcodeproj 即可。
# cleanecho "================= Clean一下 ================="xcodebuild clean -workspace ${PROJECT_NAME}.xcworkspace \ -configuration ${CONFIGURATION} \ -target ${CURRENT_SHEME} \#-alltargetsecho "================= Clean一下 Over ================="# archiveecho "============== archive =================="xcodebuild archive -workspace ${PROJECT_NAME}.xcworkspace \ -scheme ${CURRENT_SHEME} \ -configuration ${CONFIGURATION} \ CFBundleVersion=${BOUNDLE_VERSION} \ -destination generic/platform=ios \ -archivePath build/${CURRENT_SHEME}.xcarchive \ CODE_SIGN_IDENTITY="${__signingIdentity}"# export ipaecho "+++++++++++++++++ exportArchive +++++++++++++++++"xcodebuild -exportArchive -archivePath build/${CURRENT_SHEME}.xcarchive \ -exportPath build/${CURRENT_SHEME}\ -destination generic/platform=ios\ -exportOptionsPlist ${ExportOptionsPlistPath}\ -allowProvisioningUpdates
注意ExportOptions.plist配置,这个文件如下所示:
compileBitcode method enterprise provisioningProfiles com.houmanager.enterprise.test com.houmanager.enterprise.test signingCertificate iPhone Distribution signingStyle manual stripSwiftSymbols teamID 5XXXXXXXXXXXHM thinning
如果不知道怎么填写,手动用Xcode9打包,导出文件中会有ExportOptions.plist
直接复制到指定路径或者手动copy即可。