Take the 2-minute tour ×

Ok, here's what I've tried.

I have the header files in two separate directories IRL. They're named the same, but are in two different locations.

I want to only include the relevant header file for each target. Lets say for ease of explaination that the header file is called "Config.h".

So I have:




These files appear in the LHS of Xcode as well in two different groups (Header1 and Header2 which point to the IRL folders).

So now all I need to do is to make Xcode choose the right one from the right folder for each target.




I have tried adding the path to the User Header Search Paths for each target, but its still choosing the wrong one. I've also tried toggling "Always search user paths" which also doesn't seem to have an effect.

So my question is, is this because they're in the Project directory? Or is it because they're in Xcode in the file manager on the LHS, so therefore Xcode is copying them into the build folder?

The strange thing is it seems to be choosing the header files from the folder with the last name alphabetically...

In previous versions of Xcode I'm sure you could choose which headers to copy into the build folder.

Anyway.. does anyone know how I can fix this so that I can have it select the proper header file for the target?

Many thanks.

share|improve this question
I am not sure but what about conditional import? –  Anoop Vaidya Feb 15 '13 at 18:14
That's the back up plan. :) But it'll add a load more steps than this way. I'm sure this should be possible. –  Thomas Clayson Feb 15 '13 at 18:14
1. Actually i can't understand why you have problems with "Header Search Paths". Try to exclude these headers from the project and do not use "**" recursive search paths. 2. Usually I use different "include" with "ifdef else". So you can add any global variable to any target and make check what you have to include (ex: "ifdef target1 #include"header1.h" else #include"header2.h" endif;). So it depends on your requirements. –  Jlexyc Feb 18 '13 at 11:28

1 Answer 1

up vote 4 down vote accepted

The problem I was having was 2 fold:

  1. You need to remove the header files from the project. If they're in Xcode, in the file manager, then they will automatically be included in the project.

  2. You need to use relative paths to your folders in "User Header Search Paths". I was using ${PROJECT_DIR}/path/to/header/folder which gave the right path, but didn't seem to work properly. Changing the entry to ./path/to/header/folder instead worked fine.

share|improve this answer

Your Answer


