I am using Xcode to develop application. But I include some test files, and I would like to keep a reference timestamp while I do compiling. Is this possible for me to do some scripting before I start compiling the programme? Of course, I can manually run the script before I compiling, but I would like to do it in one step
, and recommend? Thanks.
Asked
Active
Viewed 6,220 times
7

DNB5brims
- 29,344
- 50
- 131
- 195
3 Answers
9
You need to add a build phase. Go to the project file, Build Phases, click Editor on the tool bar menu, add Build Phase, Add Run Script... You can select and drag the script to put it before/after anything.
Then the shell should be /usr/bin/python, then you can type in your script below. The script will run every time you build.

mergesort
- 5,087
- 13
- 38
- 63
5
- Project File -> Build Phases -> Add Build Phase (Bottom right) -> Add Run Script
- Drag the new build phase into the correct order
- Under Shell -> /bin/sh
- Then in the text box, fill up something like "/usr/bin/python /Users/me/test.py"

NachoChip
- 297
- 4
- 13
-
1kishinmangalani's answer above doesn't seem to work for me in XCode 5. Thanks @NachoChip – snowbound Sep 03 '14 at 12:35
5
Just to clarify a little, since the above answers did help me out eventually but were kind of confusing at first:
After you create a new Run Script in your Build Phases:
Use shell =
/usr/bin/python
, if what you put in the script text box is pure python code.Use shell =
/bin/sh
if you want to run a python file, and include the full command to launch the script e.g.:

Mete
- 5,495
- 4
- 32
- 40