从Jenkins运行时,xcodebuild失败(在终端中运行) [英] xcodebuild fails when run from Jenkins (works in terminal)

查看:919
本文介绍了从Jenkins运行时,xcodebuild失败(在终端中运行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用xcodebuild命令使用Jenkins CI(在具有Mavericks的Mac Mini上)来构建我的iOS项目. 我玩了几个小时,但无法解决这个问题.

I am trying to use Jenkins CI (on a Mac Mini with Mavericks) using the xcodebuild command to build my iOS projects. I played around with it for hours, but can't get my head around this issue.

以下命令在命令行上构建我的项目没有任何问题,但是当它在Jenkins中运行时失败.

xcodebuild -workspace ./MyProject.xcworkspace 
           -scheme MyProject 
           -configuration AdHoc 
           -sdk iphoneos 
           DSTROOT=/Users/me/myproject 
           OBJROOT=/Users/me/myproject 
           SYMROOT=/Users/me/myproject 
           ONLY_ACTIVE_ARCH=NO 
           OTHER_CODE_SIGN_FLAGS="--keychain /Users/me/Library/Keychains/temporary.keychain"

(为清楚起见添加了换行符.)

错误总是看起来像这样:

CompileC /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.o MyProject/Code/Controllers/Event/SomeViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/me/.jenkins/jobs/myproject/workspace
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache -Wno-trigraphs -fpascal-strings -Os -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DCOCOAPODS=1 -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-generated-files.hmap -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-own-target-headers.hmap -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-all-target-headers.hmap -iquote /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-project-headers.hmap -I/Users/me/myproject/AdHoc-iphoneos/include -I/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers -I/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/AFNetworking -I/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/SDWebImage -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/DerivedSources/armv7 -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/DerivedSources -F/Users/me/myproject/AdHoc-iphoneos -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -isystem/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers -isystem/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/AFNetworking -isystem/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/SDWebImage -include /Users/me/Library/Developer/Xcode/DerivedData/MyProject-gyrrispdpuygvudbmupzhfzzaaag/Build/Intermediates/PrecompiledHeaders/MyProject-Prefix-asaxoaokmbdwezcdrhupsyxzhzrl/MyProject-Prefix.pch -MMD -MT dependencies -MF /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.d --serialize-diagnostics /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.dia -c /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.m -o /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.o
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.m:9:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.h:10:
/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/SDWebImage/UIImageView+WebCache.h:1:1: error: expected identifier or '('
../../SDWebImage/SDWebImage/UIImageView+WebCache.h
^
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.m:9:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.h:11:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Models/SomeEvent.h:10:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Models/SomeRoom.h:10:
/Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Models/ABKBuilding.h:14:1: error: unexpected '@' in program
@property (nonatomic, strong)   NSString    *buildingID;
^


[... a lot more of this]  

** BUILD FAILED **


    The following build commands failed:
        CompileC /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.o MyProject/Code/Controllers/SomeViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

    (1 failure)
    Build step 'Execute shell' marked build as failure

我到目前为止所做的:

  • Jenkins中的用户与命令行中的用户相同(请参见此这样的问题)
  • 该用户是构建计算机的根用户
  • 配置正在与我设置的另一个示例项目一起工作(即,这不是钥匙串问题)
  • 我安装了当前的Xcode 5.1命令行工具,并做了手册xcode-select
  • 我在调用xcodebuild命令之前使用了export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
  • 在运行Jenkins作业之前,我删除了DerivedData
  • The user is the same in Jenkins and on the command line (see this SO question)
  • The user is the build machine's root user
  • The provisioning is working with another sample project I set up (i.e. it's not a keychain issue)
  • I installed current Xcode 5.1 command line tools and did a manual xcode-select
  • I used export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer" before calling the xcodebuild command
  • I deleted DerivedData before runnig the Jenkins job

我忘了提一下,该项目使用CocoaPods,不确定是否可能是它无法构建的原因.

I forgot to mention that this project uses CocoaPods, not sure if that might be the reason it doesn't build.

我添加了更多错误输出.我正在将我的Pods文件夹检入git.相同项目的构建在命令行上没有任何问题.命令绝对没有区别,我三重检查. 不幸的是,由于各种自定义原因,我无法使用Xcode插件.但是即使可以,我真的想找出两种环境之间的区别.

EDIT 2: I added some more error output. I am checking my Pods folder into git. The same project builds without any issues on the command line. There is absolutely no difference in the command, I triple checked. Unfortunately I can not use the Xcode plugin for various customisation reasons. But even if I could, I really wanna find out whats the difference between the two environments.

更新:我似乎无法编译项目中的某些.m文件,因此,每个版本的输出总是有些不同.我还在构建方案中添加了一个依赖项,以确保先构建CocoaPods.

Update: I just seems to fail to compile some of the .m files in my project the output is always a bit different from one build to another. I also added a dependency in my build scheme to make sure CocoaPods is built before anything else.

仍然不知道为什么某些文件导致了此问题. 有人可以确认他们仍然可以使用xcodebuild Xcode 5.1 Build version 5B130a从Jenkins构建项目吗?

Still no idea why some files are causing this problem. Can someone please confirm that they can still build projects from Jenkins with xcodebuild Xcode 5.1 Build version 5B130a?

推荐答案

我正在使用 Xcode 5.0.2(5A3005),并且我也在命令行中使用xcodebuild进行了构建,而未使用Jenkins插件或IDE.

I am using Xcode 5.0.2 (5A3005) and I am building with xcodebuild from command line as well, without using Jenkins plugin or the IDE.

一个注意事项:Jenkins为每个构建步骤创建了一组新的环境变量.在某个构建步骤中创建的任何新环境变量都不会在下一个构建步骤中复制.有很多解决方法(但这不是您的问题).如果您的export命令与xcodebuild命令在单独的 Execute Shell 构建步骤中运行,则没有任何作用.

One note: Jenkins creates a new set of environment variables for each build step. Any new environment variables created in a certain build step are not replicated in the next build step. There are ways around it (but that is currently not your question). If your export command is running in a separate Execute Shell build step from your xcodebuild command, then it is has no affect.

这里是可以尝试的东西:
在命令行上,输入xcode-select -p.
然后输入set 将输出复制粘贴到可以进行差异分析的良好文本编辑器中

Here is something to try:
On command line, type xcode-select -p.
Then type set Copy paste the output to a good text editor that can diff

然后运行Jenkins作业,并在 Execute Sell 构建步骤中,使用相同的命令:
xcode-select -p set 复制将输出粘贴到良好的文本编辑器中,然后将两个文件进行比较.

Then run a Jenkins job, and in Execute Sell build step, use the same commands:
xcode-select -p set Copy paste the output to a good text editor and than diff the two files.

首先,比较xcode-select -p的输出是否相同.
然后,除了Jenkins执行中的 extra 变量(例如$BUILD_NUMBER等)之外,应该没有区别.

Firstly, compare the output of xcode-select -p is same.
Then, apart from extra variables in the Jenkins execution (such as $BUILD_NUMBER, etc), there should be no differences.

这篇关于从Jenkins运行时,xcodebuild失败(在终端中运行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆