Jenkins + Xcode9 打包报错: requires a provisioning profile with the Push Notifications feature.

问题详情

《Jenkins + Xcode9 打包报错: requires a provisioning profile with the Push Notifications feature.》 图片.png

因为 Xcode 9 默认不允许访问钥匙串的内容,必须要设置 allowProvisioningUpdates 才会允许,Jenkins的Xcode插件目前无法支持此项完成打包流程。

解决方案:将 Jenkins 项目里的 Xcode integration 构建步骤去掉,选择脚本构建步骤,配合ExportOptions.plist进行打包:

《Jenkins + Xcode9 打包报错: requires a provisioning profile with the Push Notifications feature.》 QQ20180409-104527.png

plist文件配置

1.可以参照下面步骤2的格式创建一个,或者先使用xcode9手动打包一次(一次就够了,只要获得这个文件即可)然后在导出的文件夹中找到以下文件:ExportOptions.plist

《Jenkins + Xcode9 打包报错: requires a provisioning profile with the Push Notifications feature.》 图片.png

  1. ExportOptions.plist详细配置如下:

《Jenkins + Xcode9 打包报错: requires a provisioning profile with the Push Notifications feature.》 图片.png

  1. 将plist文件拷贝到Jenkins的工作目录(其他目录也可以,但是尽量是一个不随便变动的路径)

  2. 配置脚本

脚本配置

参考配置格式(一定记得替换脚本中的xcarchive文件、xcodeproj/xcworkspace文件、exportOptionsPlist文件和scheme的路径为你自己的路径,Debug看情况而定,如果要打ad-hoc的包记得切换为Release):

由于Jenkins的安装方式不同,工作空间的路径也会有所区别,以下脚本中的路径为通过pkg包的方式安装之后的路径,如果是通过war包安装的Jenkins,路径中的/Users/USERNAME/.jenkins需要替换为/Users/share/Jenkins/Home (只要你确保是Jenkins的工作路径即可)

注意:如果是 workspace 的项目,那就将第一段的命令中 -project /Users/USERNAME/.jenkins/workspace/PROJECT NAME/APPNAME.xcodeproj修改为 -workspace /Users/USERNAME/.jenkins/workspace/PROJECT NAME/APPNAME.xcworkspace 即可。
记得替换命令中的APPNAME,USERNAME,PROJECT NAME, SCHEMENAME 为自己项目的参数

xcodebuild -archivePath "/Users/USERNAME/.jenkins/workspace/APPNAME/build/Debug-iphoneos/APPNAME.xcarchive" -project /Users/USERNAME/.jenkins/workspace/PROJECT NAME/APPNAME.xcodeproj -sdk iphoneos -scheme "SCHEMENAME" -configuration "Debug" archive

xcodebuild -exportArchive -archivePath "/Users/USERNAME/.jenkins/workspace/APPNAME/build/Debug-iphoneos/APPNAME.xcarchive" -exportPath "/Users/USERNAME/.jenkins/workspace/APPNAME/build/APPNAME_debug" -exportOptionsPlist '/Users/USERNAME/.jenkins/workspace/APPNAME/build/ExportOptions.plist' -allowProvisioningUpdates

接下来就可以愉快的开始打包啦,如果还有其他疑问欢迎留言

参考链接(感谢两位大神提供的资料)

https://www.jianshu.com/p/8b3d6b0d71e2
http://www.cocoachina.com/cms/wap.php?action=article&id=20803

    原文作者:北极企鹅QAQ
    原文地址: https://www.jianshu.com/p/7d6ef618f5f4
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞