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:
xcode-select
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
before calling the xcodebuild
commandEDIT: 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
?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With