Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcodebuild test command for using with jenkins doesn´t work

I am having one problem that is killing me. Here it is: I have and app project in xCode that goes perfect when I tried to do everything in xCode UI. Which that I mean build, run, test or whatever in all the different targets that I have (3), 2 of the App and one for the tests.

THe problem comes when I tried to install a continous integration to my system in Jenkins. I need to execute some commands in shell for it. Command like this one:

xcodebuild -project MYPROJECT -sdk iphonesimulator -scheme TESTS_SCHEME TEST_AFTER_BUILD=YES

I also have tried with this other one that in the end it does the same:

xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator  -configuration "Debug"

Then is when the problems cames out, the terminal says the following:

....PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.d
clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=4.3'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1


** BUILD FAILED **


The following build commands failed:
    ProcessPCH /Users/nicoyuste/Library/Developer/Xcode/DerivedData/MY_APP-bxpgsdbefuawmiexyikbtvsatlsf/Build/Intermediates/PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.pth MYLIBRARY-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

I´ve been looking in the Internet (almost in here) but everything what I found with same problem didn´t work for me. The xCode version is 4.5 and if you do xcodebuild -version is what I get so that´s fine.

I also have tried changing headers files and everything what I have found around but nothing fixes my problem...

any suggestions...

like image 460
Nicolas Yuste Avatar asked Oct 24 '12 14:10

Nicolas Yuste


2 Answers

If you're using a custom build script, you can pass -arch i386 to xcodebuild

For instance:

xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator -configuration "Debug" -arch i386

(Scroll all the way to the right in the code sample above. The relevant flag is -arch i386)

Should force it to build against i386. However, you need to make sure i386 is in your VALID_ARCHS settings for the target.

like image 148
Eric G Avatar answered Oct 14 '22 00:10

Eric G


In case anyone running into the same annoying problem again, I will share my script here: Remember to run this command under the directory that has the xcodeproj file.

xcodebuild \
-project "full-path-to-your-xcodeproj-file" \
-target YOUR_TARGET \
-sdk iphonesimulator6.1 \
-arch i386 \
-configuration Debug \
VALID_ARCHS="armv6 armv7 i386" \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY="1" \
clean install

I modified the TARGETED_DEVICE_FAMILY because I only build for iPhone. If you want to build for both iPhone and iPad, delete this line or replace with TARGETED_DEVICE_FAMILY="1, 2".

like image 32
Jingjie Zhan Avatar answered Oct 14 '22 01:10

Jingjie Zhan