I have a script that
and a Makefile that has a special timestamp file as a make target and the configuration files as target sources:
SRC = $(shell find ../config -iname "*.txt") STAMP = $(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME).stamp $(STAMP): $(SRC) python inject.py touch $(STAMP)
I added this Makefile as a "Run Script Build Phase" on top of the stack of build phases for the project target.
The script build phase was run before compiling the source.
However, since the script modifies source code during its execution, I needed to build twice to get the most recent version of the build product. Here is what I imagine to be happening:
After reading Xcode documentation on Build Phases, I tried adding a source file which is known to be updated every time the script is run as the output of "Run Script Build Phases", but nothing changed. Since the number of configuration files may vary in my project, I don't want to specify every input and output file.
How do I make Xcode aware of source file changes made during "Run Script Build Phase"?
Xcode uses the set of input and output files to optimize build times, by running your script only when necessary. If you don't specify input or output files, Xcode runs your script every time you build the target. For more information, see Improving the Speed of Incremental Builds.
Go to the Build Phases section of your project. (Click on the project, then on the main target, then on the “Build Phases” tab along the top.) Click the + at the top left to create a new build phase; choose “New Run Script Phase.” Xcode creates the script at the end of the list, naming it “Run Script.”
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With