7

What's the difference between these Xcode Build Phases: Headers & Copy Files?

When I add a Cocoa Touch Static Library (iOS) to my project, it comes with a Copy Files build phase, whereas when I add a Plain Static Library (macOS), it comes with a Headers build phase.

The source code of the target I'm adding is written entirely in C. And, I want to be able to include this project in my other projects that contain iOS & macOS application targets.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651

1 Answers1

0

The difference between the two is very simple in fact (applicable for static libraries, but not frameworks):

  • Headers Phase copies all Public and Private headers into /usr/local/include folder, so they are available system-wide on macOS when installing the library (while developing, Xcode just creates this folder hierarchy under $(TARGET_BUILD_DIR) for you, so you can inspect the headers as needed).
  • Copy Files offers product-specific destination $(TARGET_BUILD_DIR)/include/$(PRODUCT_NAME), where headers are supposed to be delivered alongside the library binary.

The second approach is more flexible (while you can use the Copy Files phase in both macOS and iOS, using Headers Phase makes sense in macOS only).

P.S. Be advised that for frameworks the Headers Phase works differently and in fact embed the headers with the framework being developed, so in this case it's a more preferred way.

The Dreams Wind
  • 8,416
  • 2
  • 19
  • 49