5

I have a Mac Cocoa application that uses several custom frameworks. (Apple calls them private, it’s the frameworks that get distributed in the app bundle with your application.) Inside each framework there is a Headers folder with the framework’s header files. These are not needed inside the resulting application bundle & I’d like to keep them private. Currently I use a Run Script build phase with the following line:

# Remove all headers from our private frameworks
find "${TARGET_BUILD_DIR}" -name Headers -print0 | xargs -0 rm -rf

Is this the way to do it, or is there a better one?


More about my project structure: I have three Xcode projects nested in my main project, these projects have my private frameworks as their products. The frameworks are set up as a target dependency for my main target. And the last part of the setup is a Copy Files build phase that takes the frameworks and copies them into a Frameworks subfolder inside the application bundle. (Hope this is clear enough.)

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
zoul
  • 102,279
  • 44
  • 260
  • 354

1 Answers1

2

you probably have a copy headers build phase in place for your framework. you can:

1) remove it,

2) individually specify the headers' visibility in the ide,

3) or add/remove them from the copy headers phase

i just set my targets up as build dependencies, with:

  • custom search paths for headers
  • a copy phase for the fmwk
  • no copy headers phase

you may choose to do it differently (e.g. only build the fmwk explicitly, or export some headers).

if you (eventually) don't get a satisfactory answer, some more details about your projects' structures may help, because there are a number of ways to configure this.

good luck

justin
  • 104,054
  • 14
  • 179
  • 226
  • Thanks! I do have a Copy Files phase that copies whole frameworks. Is it possible to copy just the framework without headers? (I’ll add more information about my project setup to the question.) – zoul May 12 '11 at 13:33
  • hi zoul - i just copy no headers to the framework bundle (when building the framework target), and add the framework's header directory to the search paths for the targets that require them (using `HEADER_SEARCH_PATHS`). for most private/internal libraries that i write, i just locate headers by using a single source tree (bypassing complex/messy `HEADER_SEARCH_PATHS` definitions), then declare includes relative to the source tree. in that case, you can still write `#include `, assuming the MONFramework directory is a directory in the source tree. (cont) – justin May 13 '11 at 08:33
  • then `MONFramework/MONFramework.h` is responsible for including all its public/exported headers relative to the source tree. – justin May 13 '11 at 08:34
  • @justin can you check this please: https://stackoverflow.com/questions/56753565/hide-objectivec-files-in-a-swift-framework – nr5 Jun 25 '19 at 12:09