Question: I am trying to clean up some of my projects, and one of the things that are puzzling me is how to deal with header files in static libraries that I have added as "project dependencies" (by adding the project file itself). The basic structure is like this:

```

MyProject.xcodeproj
  Contrib
    thirdPartyLibrary.xcodeproj
  Classes
    MyClass1.h
    MyClass1.m
    ...

```

Now, the dependencies are all set up and built correctly, but how can I specify the public headers for "thirdPartyLibrary.xcodeproj" so that they are on the search path when building MyProject.xcodeproj. Right now, I have hard-coded the include directory in the thirdPartyLibrary.xcodeproj, but obviously this is clumsy and non-portable. I assume that, since the headers are public and already built to some temporary location in ~/Library (where the .a file goes as well), there is a neat way to reference this directory. Only.. how? An hour of Googling turned up blank, so any help is greatly appreciated!

Answer: 
If I understand correctly, I believe you want to add a path containing $(BUILT\_PRODUCTS\_DIR) to the HEADER\_SEARCH\_PATHS in your projects build settings.

As an example, I took an existing iOS project which contains a static library, which is included just in the way you describe, and set the libraries header files to public. I also noted that the PUBLIC\_HEADERS\_FOLDER\_PATH for this project was set to "/usr/local/include" and these files are copied to $(BUILT\_PRODUCTS\_DIR)/usr/local/include when the parent project builds the dependent project. So, the solution was to add $(BUILT\_PRODUCTS\_DIR)/usr/local/include to HEADER\_SEARCH\_PATHS in my project's build settings.

```
HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include

```

Your situation may be slightly different but the exact path your looking for can probably be found in [Xcode's build settings](http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html). Also you may find it helpful to add a Run Script build phase to your target and note the values of various settings at build time with something like:

```
echo "BUILT_PRODUCTS_DIR " $BUILT_PRODUCTS_DIR
echo "HEADER_SEARCH_PATHS " $HEADER_SEARCH_PATHS
echo "PUBLIC_HEADERS_FOLDER_PATH " $PUBLIC_HEADERS_FOLDER_PATH
.
.
.
etc.

```
I think that your solution is sufficient and a generally accepted one. One alternative would be to have all header files located under an umbrella directory that can describe the interface to using the depended-on libraries and put that in your include path. I see this as being similar to /usr/include. Another alternative that I have never personally tried, but I think would work would be to create references to all the headers of *thirdPartyLibrary* from *MyProject* so that they appear to be members of the *MyProject*. You would do this by dragging them from some location into *MyProject*, and then deselecting the checkbox that says to copy them into the project's top level directory. From one perspective this seems feasible to me because it is as if you are explicitly declaring that your project depends on those specific classes, but it is not directly responsible for compiling them.

One of the things to be wary of when addressing this issue is depending on implementation-specific details of Xcode for locating libraries automatically. Doing so may seem innocuous in the meantime but the workflows that it uses to build projects are subject to change with updates and could potentially break your project in subtle and confusing ways. If they are not well-defined in some documentation, I would take any effect as being coincidental and not worth leveraging in your project when you can enforce the desired behavior by some other means. In the end, you may have to define a convention that you follow or find one that you adopt from someone else. By doing so, you can rest assured that if your solution is documented and reproducible, any developer (including yourself in the future) can pick it up and proceed without tripping over it, and that it will stand the testament of time.