Xcode 9 在 Jenkins 中使用 Xcode inte

作者: Tolecen | 来源:发表于2017-10-01 12:48 被阅读3338次

问题概述

自己使用 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.ipa

Build step 'Xcode' marked build as failure

Finished: FAILURE

因为 Xcode 9 默认不允许访问钥匙串的内容,必须要设置 allowProvisioningUpdates 才会允许,但是由于 Xcode integration 插件封闭,并不能对其进行修改加上这个属性,所以决定使用 Shell 脚本代替插件。

解决方案

将 Jenkins 项目里的 Xcode integration 构建步骤去掉,使用下面所示的命令:

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

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

如果是 workspace 的项目,那就将上面第一段的命令中 -project APPNAME.xcodeproj 修改为 -workspace APPNAME.xcworkspace 即可。

再说明一下 ExportOptions.plist,这个文件如下所示:

里面的有 Bundle Id, ProvisioningProfiles 和 teamID 的信息,对应填写上即可,如果不确定,那就先用 Xcode 9 手动打包你的项目,然后导出,导出的文件夹里会有这个文件,直接复制到你持续集成需要的路径中即可。

相关文章

网友评论

  • 路过你的全部:大神,我想问下,我打包完成后,因项目需要,需要更改.ipa的包名称,有什么方法吗?
  • a9c0b2ad52f4:你好Tolecen,有两个问题想咨询一下。一是配置GitHub project的时候,project url是我本地的project工程文件地址吧?第二个问题,构建shell中,archive path 是我本地随便的一个地址,还是jekins的默认安装地址
  • 独酌清风:打包时会卡在
    Build settings from command line:
    BUILD_DIR = /Users/caifangmao/.jenkins/workspace/iOS-rice/build
    DEVELOPMENT_TEAM = 000000000
    是怎么回事啊
  • 囚你于无期_99bb:打包成功后确找不到ipa的文件位置

    ** ARCHIVE SUCCEEDED **

    + xcodebuild -exportArchive -archivePath /Users/Shared/.jenkins/Home/workspace/aritube_ios/build/Debug-iphoneos/NewAritube.xcarchive -exportPath /Users/Shared/.jenkins/Home/workspace/aritube_ios/build/NewAritube_debug -exportOptionsPlist /Users/Shared/Jenkins/Home/workspace/aritube_ios/ExportOptions.plist -allowProvisioningUpdates
    2018-02-01 16:52:57.386 xcodebuild[39820:4143429] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/kp/bn19ns655z9cmjx1q4yr20hh00007x/T/NewAritube_2018-02-01_16-52-57.385.xcdistributionlogs'.
    Exported NewAritube.xcarchive to: /Users/Shared/.jenkins/Home/workspace/aritube_ios/build/NewAritube_debug
    ** EXPORT SUCCEEDED **

    Root directory to find files to upload : /Users/Shared/Jenkins/Home/workspace/aritube_ios
    found remote files : []
    ERROR: Could not find the file specified by the pattern **/*.apk,**/*.ipa
    Build step 'Upload to fir.im' marked build as failure
    Sending e-mails to: reddoor@orangenat.com
    Email was triggered for: Failure - Any
    Sending email for trigger: Failure - Any
    An attempt to send an e-mail to empty list of recipients, ignored.
    Finished: FAILURE
    hnxyzhw:看下你的账号有没有实名认证,或者下一下旧版本的fir-plugin插件试试
  • 小vv:小哥 你好 请问 我导出ipa都成功了 但是还是报错是什么鬼

    Exported MedicalAlliance.xcarchive to: /Users/Shared/Jenkins/Home/workspace/MedicalAlliance-iOS/build/MedicalAlliance_Release
    ** EXPORT SUCCEEDED **

    FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
    java.lang.NoClassDefFoundError: Could not initialize class hudson.util.ProcessTree$UnixReflection
    at hudson.util.ProcessTree$UnixProcess.kill(ProcessTree.java:647)
    at hudson.util.ProcessTree$UnixProcess.killRecursively(ProcessTree.java:668)
    at hudson.util.ProcessTree$Unix.killAll(ProcessTree.java:589)
    at hudson.Launcher$LocalLauncher.kill(Launcher.java:949)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:510)
    at hudson.model.Run.execute(Run.java:1724)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)
    Finished: FAILURE
    Tolecen:@小vv 这个还是得看看导出后边还有什么步骤吧,应该是那里的错
  • 小vv:你要需要打release包呢?把脚本里的Debug全换成release?
    Tolecen:@小vv 是的
  • 黄鱼儿啦啦啦:您好,发现xcode9 按这个试了还是报一样的错
    Code Signing Error: No profiles for 'com.***' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.***'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.
    Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.2'

    ** ARCHIVE FAILED **
    改成了手动打包 profile 文件也相应的复制到目录下了
    黄鱼儿啦啦啦:@小vv 成功了,把你那些失败的工程的profile 文件复制到Jenkins 相应的profile文件目录下试试
    小vv:你解决了吗 最奇葩的是我建了3个工程 一个成功 一个抱这个错 还有一个是另一个错误 也是** ARCHIVE FAILED **
  • IAM121:您好,我在xcode9.02上,Jenkins 中的shell这样执行的"1. xcodebuild -archivePath "$WORKSPACE/build/xhm-iphoneos/APPNAME.xcarchive" -workspace Gassistant.xcworkspace -scheme "Gassistant" -configuration "Release" archive
    2.xcodebuild -exportArchive -archivePath /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos/APPNAME.xcarchive -exportPath /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos -exportOptionsPlist /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos/exportOptionsPlist.plist -allowProvisioningUpdates" ,在方法1能执行成功,方法2导出ipa的时候,Jenkins总出现如下情况"+ xcodebuild -exportArchive -archivePath /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos/APPNAME.xcarchive -exportPath /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos -exportOptionsPlist /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos/exportOptionsPlist.plist -allowProvisioningUpdates
    2017-12-20 14:23:54.926 xcodebuild[40008:1299395] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/l8/2l0qwhv548395mnhx5c9c_nr0000gn/T/Gassistant_2017-12-20_14-23-54.925.xcdistributionlogs'.
    /var/folders/l8/2l0qwhv548395mnhx5c9c_nr0000gn/T/jenkins677381069499960397.sh: line 4: 40008 Segmentation fault: 11 xcodebuild -exportArchive -archivePath /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos/APPNAME.xcarchive -exportPath /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos -exportOptionsPlist /Users/xhm/.jenkins/workspace/GassHelp2/build/xhm-iphoneos/exportOptionsPlist.plist -allowProvisioningUpdates
    Build step 'Execute shell' marked build as failure",我点击日志文件中去看"did not contain a "archived-expanded-entitlements.xcent""有67个地方库说这样的问题,我在网上查看只有换一个新库就可以,但是这个工作量太不可思议了。我又把方法2在终端运行了一下,结果就能正常导出ipa。请问有好的解决方法让Jenkins也可以正常导出ipa包?感谢
  • 偏偏就是祢:使用你的这个还是报一样的错
    东也_:楼主 有点问题请教 我QQ 1026238004 谢了
    偏偏就是祢:有qq或者微信吗?
  • 郝程序猿:请问我再打包的时候 开始打包就出现了如下错误
    error: exportArchive: "ClassMate.app" requires a provisioning profile with the Push Notifications and Associated Domains features.

    Error Domain=IDEProvisioningErrorDomain Code=9 ""ClassMate.app" requires a provisioning profile with the Push Notifications and Associated Domains features." UserInfo={NSLocalizedDescription="ClassMate.app" requires a provisioning profile with the Push Notifications and Associated Domains features., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}
    使用同样的证书,直接手动打包没出现该问题,而且按照错误所说,在plist中增加了provisioningProfiles字典 并且里面有bundleid 对应的证书名称 还是出现该问题 这种情况该怎么解决呢
    Tolecen:@郝程序猿 那也是这个-allowProvisioningUpdates的问题,这个加了么
    郝程序猿:@Tolecen 可是我用的是shell脚本 出现了该问题 没用到Jenkins
    Tolecen:@郝程序猿 你好,就按照我文中所说,最重要的是那两行命令
  • f1bd5906b5f5:我的为啥还是不行 提示The file “ExportOptions.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/lixiang/.jenkins/workspace/ESE/build/ExportOptions.plist, NSUnderlyingError=0x7fd38d8f12f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
    是因为没找到plist文件吗
  • jins_1990:今天遇到这个问题了,感谢分享,先去试试
    jins_1990:@Tolecen halo!那天我建了一个新项目是可以使的,也可以上传到蒲公英等第三方,但是今天我尝试将正式项目接入jenkins,但是打包时候总是报错

    ** ARCHIVE FAILED **
    The following build commands failed:
    PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/yangjian/Library/Developer/Xcode/DerivedData/shoppingMall-bhoirzagodbdtoeisrxjmxryoobx/Build/Intermediates.noindex/ArchiveIntermediates/shoppingMall/IntermediateBuildFilesPath/shoppingMall.build/Release-iphoneos/shoppingMall.build/Script-A8A4F04AD7A11A57978AB7E7.sh
    (1 failure)
    Build step 'Execute shell' marked build as failure
    Finished: FAILURE

    不知道你有什么建议没有,昨天搞这个问题找了一天也没有找到答案
    Tolecen:@jins_1990 必须好使

本文标题:Xcode 9 在 Jenkins 中使用 Xcode inte

本文链接:https://www.haomeiwen.com/subject/qbaoextx.html