Xcode: Running a script before every build that modifies source code directly
Solution 1:
Every technique mentioned so far is an overkill. Reproducing steve kim's comment for visibility:
In the build phases tab, simply drag the "Run Script" step to a higher location (e.g. before "Compile Sources").
Tested on Xcode 6
Solution 2:
This solution is probably outdated. See the higher voted answer instead; I no longer actively use Xcode and am not qualified to vet a solution.
Use "External Target":
- Select "Project" > "New Target..." from the menu
- Select "Mac OS X" > "Other" > "External Target" and add it to your project
- Open its settings and fill in your script setup
- Open the "General" tab of the main target's settings and add the new target as it's direct dependency
Now the new "External Target" runs before the main target even starts gathering dependency information, so that any changes made during the script execution should be included in the build.