0

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. Commented Jun 9, 2013 at 23:33

1 Answer 1

2

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:

enter image description here

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

Sign up to request clarification or add additional context in comments.

3 Comments

Would this work since runserver normally runs in the foreground?
There shouldn't be any issues. I'm not 100% sure, but I guess the server log will be visible in the log navigator.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.