7

While trying to begin using Swift in a framework (including turning on module support), I started getting messages like this:

[snip]/<module-includes>:1:1: Umbrella header for module 'PressKit' does not include header 'NPKBaseAppearance.h'

The headers in question (there are about ten of them) are not listed in PressKit.h, but with good reason—they include internal or rarely-used classes and categories that I don't want to expose to most users of my framework. (Some of them I'd like to expose in select places; others should never be exposed.)

Marking the headers as private doesn't seem to help. This is a warning in my framework's project, but an error in each target using the framework, so I can't just ignore the problem.

Obviously I can add these headers to my umbrella header, but I don't want to. Am I violating some rule of framework design when using modules? What's the recommended way to handle this sort of situation?

Becca Royal-Gordon
  • 17,541
  • 7
  • 56
  • 91

2 Answers2

2

What's the recommended way to handle this sort of situation?

Not sure if it's the recommended way, but here's how I got rid of that warning:

  1. I've created a private module map that lists all internal headers and placed it in the root folder of my framework project, as module.private.modulemap:

    framework module PressKit_Private {
        header "NPKBaseAppearance.h"
        export *
    }
    
  2. I have configured Xcode to use that module map

Screenshot

  1. I configured Xcode to treat those internal headers as private headers. That will cause Xcode to place them in PressKit.framework/PrivateHeaders when creating the framework.

Screenshot

Now, when importing the PressKit module in Swift or Objective-C, the functions from the headers from the private module map are not available. One needs to import PressKit_Private to make them available.

Thomas McGuire
  • 5,308
  • 26
  • 45
1

Don't know if you already solved this issue yourself but did you try to exclude the headers you don't want to export in a custom .modulemap file?

Have a look at: Clang 3.7 documentation - Modules

SanCode
  • 49
  • 1