Yan B.

Friday, February 19, 2010

XCode iPhone app compile and run via command line

I always wanted to compile and run my iphone apps from the commandline but i never took the time to find out if it's possible and how to actually do it.
My intention is to keep the dropdowns in xcode for an iPhone device deployment setting and use a makefile to compile and run the simulator configuration.

So here's what i came up with so far:

1) Compiling
Since i have different compilation targets i setup a target in my makefile for each of them.
This is how i compile the phone version of my app:

xcodebuild -sdk iphoneos3.1.2 -target HelloWorld_phone -configuration Debug

checkout this out for other available options:
xcodebuild --help

2) Copying an app to the simulator
Find out where your app gets usually installed and then copy over your .app file to this folder.

cp -r build/Debug-iphonesimulator/HelloWorld.app /Users/chris/Library/Application\ Support/iPhone\ Simulator/User/Applications/EBF60BB7-DF69-4F92-846B-D78FB3938C38

i also found out here that you need to have a file with .sb ending alongside (not inside) the folder.
Mine is here:
~/Library/Application\ Support/iPhone\ Simulator/User/Applications/EBF60BB7-DF69-4F92-846B-D78FB3938C38.sb

with the content:
(version 1)
(debug deny)
(allow default)

3) Running the simulator
Unfortunately this only runs the simulator (not the app) and you have to select your app manually.
I'll have a look if this can be automated as well (as soon as i clicked a zillion times on the wrong button in the simulator).

open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app

Followers

About Me

My photo
Currently switching between iOS contractwork, crafting components for ultramarine-ui.com and making my own games for 2D Rockers.

You can follow me via: @csch_ @ultramarineui and @2DRockers

Me on github: http://www.github.com/csch