4

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?

Community
  • 1
  • 1
UncleAli
  • 495
  • 1
  • 5
  • 13

2 Answers2

0

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.

Jacob Lukas
  • 689
  • 6
  • 14
0

I ended up generating files in ${SRCROOT} directory with custom make build target using Makefile that handles regenerating derived files. I just added these generated files to project, and made all actual build target depend on this make target.

UncleAli
  • 495
  • 1
  • 5
  • 13