Xcode: adding files relative to DerivedSources

Number:rdar://10488973 Date Originated:2010-11-27
Status:Open Resolved:
Product:Developer Tools Product Version:4.2.1/4D502
Classification:Enhancement Reproducible:Not applicable
Xcode nudges users towards using $DERIVED_FILE_DIR (…/$CONFIGURATION/target.build/DerivedSources/) as the output file for script phases. However, there doesn’t seem to be a supported way to add references to files in this directory in a configuration-neutral manner.

Steps to Reproduce:
* Create a new project. (example attached)
* Add a new shell script build phase with a script like:
        mkdir -p "$DERIVED_FILE_DIR"
        cd "$DERIVED_FILE_DIR"
        echo "#include <stdio.h>" > DoSomething.c
        echo "void DoSomething(void) { printf(\"Hello, world\n\"); }" >> DoSomething.c
* Build the project.
* Add the generated file to the project.
* Clean the project, then build a different configuration (e.g., using Build for Archive).

Expected Results:
* The file should be generated and compiled.

Actual Results:
* The file is generated in the active configuration’s DerivedSources directory, but compilation fails because the reference points to a file in the wrong configuration’s DerivedSources directory.

Unknown; I’ve used this type of arrangement in Xcode 3, but I can’t remember if I had trouble setting it up.

My solution was to manually edit the project file to replace the configuration name in the reference with $CONFIGURATION. Ideally, adding a reference to a file in a DerivedSources directory (for any target/configuration combination in the project) would add a configuration-neutral reference, either by using a path with $CONFIGURATION in it or by adding a DerivedSources-relative sourceTree.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!