Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build/run iOS Xcode project from Terminal

I want to build a Xcode project from Terminal and then run it as required, also from Terminal.

I have been looking for a way to do this for a while now but only managed to find a method which works for the iPhone Simulator, not for the actual device it self.

Is this even possible? The reason I want to a Xcode project on a device from Terminal is because the application runs a series of automated tests and I would prefer to automate this process using a bash script.

Thanks

like image 445
Lkm Avatar asked Sep 20 '11 13:09

Lkm


People also ask

How do I run Xcode from command line app?

go to the 'Info' tab and in a menu 'Executable' choose 'Other...' in file window go to search input field and type 'terminal' and click on its icon when you find it. Now you should see 'Terminal. app' in 'Executable' field.

How do I build and run in Xcode?

Build, Run, and Debug Your App To build and run your code, choose Product > Run, or click the Run button in your project's toolbar. Xcode analyzes your scheme's targets and builds them in the proper sequence. After a successful build, Xcode launches the associated app.

What is Xcode build command?

xcodebuild is a command-line tool that allows you to perform build, query, analyze, test, and archive operations on your Xcode projects and workspaces from the command line. It operates on one or more targets contained in your project, or a scheme contained in your project or workspace.


1 Answers

To build your xcode project from the command line using a bash script use:

/usr/bin/xcodebuild -target TargetYouWantToBuild -configuration Debug 

Look at the man page for xcodebuild for more options.

We do this for our unit test suite target, and we use GHUnit.

This is the section of our build script for running the tests:

export GHUNIT_CLI=1 export WRITE_JUNIT_XML=1 clean echo "Building Bamboo GHUnit Tests..." OUTPUT=`/usr/bin/xcodebuild -target BambooAutomatedUnitTest -configuration Debug -sdk iphonesimulator4.3 build` RESULT=`echo "$OUTPUT" | grep "\\*\\* BUILD "` if [ "$RESULT" != "** BUILD SUCCEEDED **" ] then     echo "$OUTPUT"     exit 1 fi echo "${RESULT}\n" 
like image 103
bandejapaisa Avatar answered Oct 03 '22 22:10

bandejapaisa