I have an iOS application that relies on a web server to keep track of information like players and games. Is there some way I can have XCode restart the server every time I start the app in the simulator? I am using Django so starting the server involves one terminal command.
1
-
Strictly speaking the answer is no - there is no documented hook for running scripts once a debugging session starts - oops, no, now I remember, there is something in Xcode4... lemme check. There is however a hook for running scripts once a build process is invoked, as explained by Gabriele in his answer below.Till– Till2013-06-09 23:33:35 +00:00Commented Jun 9, 2013 at 23:33
Add a comment
|
1 Answer
Go to you target settings and add a Build Phase. You can set an arbitrary script that runs at every build.
Here's an example taken from one of my projects:

Simply click on the Add Build Phase icon on the bottom right and select Add Run Script. As you can easily find out by yourself, you can specify the shell to run the script into, as well as other handy options.
In your specific case a simple oneliner
python manage.py runserver
would probably do the trick
3 Comments
Slruh
Would this work since runserver normally runs in the foreground?
Gabriele Petronella
There shouldn't be any issues. I'm not 100% sure, but I guess the server log will be visible in the log navigator.
Gabriele Petronella
Of course you may think of more sophisticated solutions such as open an executable script and use the XCode script just as a trigger. Example
cd "${SRCROOT}"; ./runmyserver.sh.