title: xcodebuild fails when run from Jenkins (works in terminal)
body: <p>I am trying to use Jenkins CI (on a Mac Mini with Mavericks) using the <code>xcodebuild</code> command to build my iOS projects.
  I played around with it for hours, but can't get my head around this issue.</p>
  
  <p><strong>The following command builds my project on the command line without any issues, but fails when it gets run within Jenkins.</strong></p>
  
  <pre><code>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"
  </code></pre>
  
  <p><em>(line breaks added for clarity.)</em></p>
  
  <p><strong>The error always looks something like this:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p>What I did so far:</p>
  
  <ul>
  <li>The user is the same in Jenkins and on the command line (see <a href="https://stackoverflow.com/questions/9795410/jenkins-cant-run-xcodebuild-from-project-folder">this SO question</a>)</li>
  <li>The user is the build machine's root user</li>
  <li>The provisioning is working with another sample project I set up (i.e. it's not a keychain issue)</li>
  <li>I installed current Xcode 5.1 command line tools and did a manual <code>xcode-select</code></li>
  <li>I used <code>export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"</code> before calling the <code>xcodebuild</code> command</li>
  <li>I deleted DerivedData before runnig the Jenkins job</li>
  </ul>
  
  <p><strong>EDIT:</strong>
  I forgot to mention that this project uses CocoaPods, not sure if that might be the reason it doesn't build.</p>
  
  <p><strong>EDIT 2:</strong> 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.</p>
  
  <p><strong>Update:</strong> 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. </p>
  
  <p>Still no idea why some files are causing this problem.
  <strong>Can someone please confirm that they can still build projects from Jenkins with <code>xcodebuild Xcode 5.1 Build version 5B130a</code>?</strong></p>