Search code examples
xcodexcode4referencexcode4.2auto-generate

Xcode 4.2 — add derived files to project


I'm using bison parser generator in my Xcode 4 project. I've written custom build rule for generating C++-source file from *.y grammar file:

/usr/local/bin/bison
--defines="${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.hpp"
--output="${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.cpp"
--verbose "${INPUT_FILE_PATH}"

As you can see, Xcode places generated files in $DERIVED_FILES_DIR folder. Now I need to export generated header file grammar.hpp with object files as library.

The problem is that Xcode doesn't allow export files, that aren't included in project.

The first solution, as it seems, is to create a group with absolute path set to $DERIVED_FILES_DIR. Well, it actually works until I change my build settings to build Release configuration, since $DERIVED_FILES_DIR is dependent on build settings. The second solution is somehow set group path to literally variable, i.e.

path = $DERIVED_FILES_DIR

So far I've found two possible ways to do it: How to reference files with environment variables? and File references relative to DERIVED_FILE_DIR in Xcode. Either way doesn't work for me.

Maybe someone knows better way to add generated files to project?


Solution

  • Your best options are:

    1. Generate the files in your SRCROOT
    2. Generate the files in BUILT_PRODUCTS_DIR

    These both have "Relative to..." options that should allow you to add the files to your project.