9

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.

The following command builds my project on the command line without any issues, but fails when it gets run within 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"

(line breaks added for clarity.)

The error always looks something like this:

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

What I did so far:

  • 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

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

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.

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.

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?

m.barakuda
  • 91
  • 1
  • 3
  • You might want to post some more of the Jenkins log so we can see the actual error. Also, if you're using CocoaPods, are you checking in all of the pod code into your repo? – Dave Wood Mar 26 '14 at 14:46
  • Also, have you tried using the Xcode plugin, vs entering your own xcodebuild command? – Dave Wood Mar 26 '14 at 14:47
  • Thanks for your suggestions, see edit 2 for clarification. – m.barakuda Mar 26 '14 at 15:15
  • Can you test on the environment that you get the build to work, doing a clean git clone, then xcodebuild, without launching the project into the Xcode IDE. I've noticed in some cases the Xcode IDE will correct some issues automatically (create missing schemes etc), that xcodebuild won't correct (and only changing files that are excluded by your .gitignore). That could be why it works in one place and not the other. – Dave Wood Mar 26 '14 at 15:46
  • Thats exactly what I did. On my build machine, I cloned the repo and it built without any issues. I never opened the Xcode IDE. That seems so strange to me and I can't work out why it happens. – m.barakuda Mar 26 '14 at 15:50
  • Is there any resolution to this question? I am trying to set up a team city machine and I am having the same issue. In my case when I clone from git directly everything works, but the tc agents isn't happy with it and when I try to build it from the build directory with xcode it doesn't work. – rodrigoelp Jun 12 '14 at 00:51
  • 1
    @m.barakuda did you find the solution? I also have the same type of issue after adding cocoapods normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler – Moaz Saeed Jan 07 '16 at 11:50
  • @MoazSaeed what you did then to fix it ? I am also facing the same :P – Abuzar Amin Jul 14 '17 at 13:17
  • Same issue here on latest macmini with Mojave – stonedauwg Jul 25 '19 at 18:30

1 Answers1

1

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.

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.

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

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.

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.

Slav
  • 27,057
  • 11
  • 80
  • 104