Understanding Xcode's Copy Headers phase Understanding Xcode's Copy Headers phase xcode xcode

Understanding Xcode's Copy Headers phase


If a public header includes a private header, you have to copy the private headers, but you want to make sure that consumers of the library or framework know that those private headers are not part of the public API.

"Project" headers are private headers that are not included by a public header (they're usually part of the internal implementation and thus only included in an implementation -- .c or .m -- file).

When building a framework, public headers are copied into the Headers directory of the framework, whereas private headers are copied into the PrivateHeaders directory.


@Danra, if you put your headers under "Project", those headers will be visible to your implementations 'regardless' of the actual location of the headers.

Let's say, you have your folder structure like this: /Sources/libAF/AFSomething.h /Sources/libAF/AFSomething.m /Sources/exec/main.m

If you've put 'AFSomething.h' under "Project", you can use it in main.m like this: #import "AFSomething.h"

In layman's term, Xcode will include Project headers though you omit actual path info.


From Setting the Visibility of a Header File:

  • Public: The interface is finalized and meant to be used by your product’s clients. A public header is included in the product as readable source code without restriction.

  • Private: The interface isn’t intended for your clients or it’s in early stages of development. A private header is included in the product, but it’s marked “private”. Thus the symbols are visible to all clients, but clients should understand that they're not supposed to use them.

  • Project: The interface is for use only by implementation files in the current project. A project header is not included in the target, except in object code. The symbols are not visible to clients at all, only to you.