views:

252

answers:

1

Hello,

When building a project in Xcode (3.1.2), 2 folders are automatically added as header directories with the '-I' option:

/ (ProjPath) / (ProjName) / build / (BuildConfigName) / include  
/ (ProjPath) / (ProjName) / build / (ProjName).build / (BuildConfigName) / (ProjName).build / DerivedSources

I realized this when trying to add -Wmissing-include-dirs to the warnings list in my project. A warning is emitted for both folders. This happens for both Cocoa Applications and C++ Dynamic Libraries. I haven't tried any other project type, but I suppose this behavior applies to any project type.

  1. How are these folders used by Xcode?
  2. Can they be either avoided, or automatically created by Xcode when build begins?
  3. If not, how to successfully use -Wmissing-include-dirs with Xcode?

Thanks.

+1  A: 

You can add a script to your target which creates the directories for your:

Right-click your target, select Add -> New Build Phase -> New Run Script Build Phase. Drag this build phase to the top of your target, before the "Compile Sources" phase.

Then enter a script like this (by double-clicking the phase):

mkdir -p "${TARGET_BUILD_DIR}/include"
mkdir -p "${PROJECT_DERIVED_FILE_DIR}"

You can see the various environment variables in the build transcript (Command-Shift-B, click the little text icon, drag the build transcript up.)

Nikolai Ruhe
Thanks for the tip. PROJECT_DERIVED_FILE_DIR is not the variable needed in my case though (it does not include the Build Configuration name). DERIVED_FILES_DIR, DERIVED_FILE_DIR or DERIVED_SOURCES_DIR should be used instead.
Guillaume