Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Xcode's Copy Headers phase

In Xcode's "Copy Headers" phase, what is the difference between the headers under the "Project" section and the "Private" section? When would you want to use each?

Also, I can understand why you would want to copy public headers (for a static library for instance) - but why would you want to copy private headers?

Edit: @mipadi below explains the roles of the Public and Private parts. However I'm still missing the difference between including a header in the "Project" part vs. not having the header in any part of the "Copy Headers" phase.

like image 757
Danra Avatar asked May 14 '12 14:05

Danra


2 Answers

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.

like image 98
mipadi Avatar answered Jan 05 '23 11:01

mipadi


@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.

like image 35
user2532301 Avatar answered Jan 05 '23 12:01

user2532301