Thomas Clayson Thomas Clayson - 2 months ago 19
iOS Question

Two targets, two header files with the same name how to use each header for the right target?

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.


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.