Xcode – How to teach Xcode 5 to create a proper static library public header folder path

static-librariesxcodexcode5

I read in this tutorial that your static library output path for header files should be structured like this for example:

Build/Products/Debug-iphoneos/YourLibraryName

Then you are able to use <YourLibraryName/YourLibraryName.h> as import.

I followed all steps and configured for the target of my static library project (in the static library xcode project) the Public Headers Folder Path to just YourLibraryName instead of /usr/local/include. The change applied to all phases, Debug and Release.

Ok so then I cleaned all targets and deleted the build folder in Finder and build again. But no change. Xcode keeps copying header files to

Build/Products/Debug-iphoneos/include/YourLibraryName

It doesn't want to skip the "include" folder.
I also tried to change the Private headers folder path but also no effect. Is this a bug in Xcode or is there a workaround?

My goal is, I want to have a static library xcode project for my common utility classes. And then drag this into all my apps that use them, and include the framework like the Apple frameworks with angle brackets .

Best Answer

(Disclaimer: I have not yet switched to Xcode 5, but my experience with 4.x may still apply here.)

Check whether you have a Copy Files or Copy Headers build phase for the target. (Select the project item in the Project navigator, then select the target and finally the Build Phases tab.) In new projects, the Xcode templates now include Copy Files in place of Copy Headers, while the article you cite may assume the latter.

The Public Headers Folder Path and Private Headers Folder Path settings are only used by Copy Headers. Copy Files has the target path right in the configuration for the build phase, and defaults to $(BUILT_PRODUCTS_DIR)/include/${PRODUCT_NAME}, which is exactly where your headers are ending up.

If this is the case, the easy solution is to just change the path in the Copy Files build phase. (Remove the "include/" part of the path.) Alternatively, you can switch to a Copy Headers build phase, but this is apparently not recommended for static library projects, due to issues with the Archive action.