2

I'm using a static library and pointing Xcode to a folder with the headers in it. These headers are organized in a hierarchical folder structure:

headers:
 - a.h
 - b.h
 - subheaders:
    - c.h
 - moreheaders:
    - d.h

I also have some prewritten source code that uses this library, and it refers to the headers based on their locations: #import "subheaders/c.h".

However Xcode flattens the folder hierarchy, forcing me to use #import "c.h". There's a good deal of code, and I can't rewrite it very easily to stop using the foldered imports. Any way to make Xcode recognize the folder structure?

P.S. I'm including these headers using the "Library Search Paths" "Header Search Paths" build setting under my primary Target. The search is non-recursive, so I don't know how it even finds the nested headers...

Thanks for your help!

thomas88wp
  • 2,381
  • 19
  • 31
  • 1
    seeing as these are headers and not libraries, why use Library Search Paths? Try putting the file paths in Header Search Paths – Patrick Goley Jul 01 '13 at 22:47
  • Good point. I tried it but its the same result. – thomas88wp Jul 02 '13 at 14:05
  • 1
    `HEADER_SEARCH_PATHS` is the correct setting. it works, i assure you :) make sure that the setting is defined for the target in question, and that its value is not shadowed (e.g. defined at the project level, but erased by a new definition at the target level). maybe you have specified the wrong path? – justin Jul 02 '13 at 17:05

3 Answers3

1

Xcode builds header maps by default and header maps are flat, except from modules/frameworks, where the map is ModuleName/Header.h. For details about how Xcode builds these maps, which settings exist and what the compiler does, if a file is not found in a map, please see this answer.

Setting an appropriate header search path (HEADER_SEARCH_PATHS or USER_HEADER_SEARCH_PATHS) will make path includes possible, regardless if header maps are used or not, yet the flattened import will still work as well in that case. If you don't want the flattened import to work, you need to disable header maps or ensure that the header files in question are not added to the maps, as shown in the other answer.

Mecki
  • 125,244
  • 33
  • 244
  • 253
0

Unfortunately this was just a case of my not being observant. I had added the headers to the search path, but I had also earlier added them as source to the project (to see if I could get it to work that way). When I removed the source folder and kept the header search path I could reference files by their full paths. Thanks for the help.

thomas88wp
  • 2,381
  • 19
  • 31
0

after Hours of try and fail i found an option in XCode 9.4.1 in an XCode 9.3-compatible project the option to disable the usage of

Ues Header maps

This will let Xcode recognize the project structure.

i althought set every file and folders location to be project relative

I Hope there is someone with the same problem and has now an solution