You can't use bridging headers within a framework.
Xcode will automatically create umbrella header for you Cocoa Framework project. That will be the file named <FrameworkName>.h in the <FrameworkName> group/folder (where the rest of your sources are).
-
To include the required Obj-C header you need to set it as
Public: select it in the project explorer (left pane) and change the propertyTarget Membership(left—Inspectors—pane) fromProjecttoPublic. -
Open umbrella header (
<FrameworkName>.h) and import the required header as:#import <FrameworkName/objc-header.h>
This effectively makes this header public and available to both your own framework and anyone who uses it.
Note: If you import the header as a local file, i.e. in quotes, e.g. #import "objc-header.h", you likely to hit the compiler error telling you are trying to include a non-modular header.
-
Create a file named
module.modulemapin the root of your project with the following contents:framework module FrameworkName { umbrella header "FrameworkName.h" header "objc-header.h" export * module * { export * } }
In case you want to keep the definitions from
objc-header.hprivate from the users of your framework you can addprivatequalifier like so:// ... private header "objc-header.h" // ... -
In Build Setting set
Module Map Filetomodule.modulemap -
Clean the build directory (⇧⌘K) and build the project (⌘B)
Note: There are options in the Build Settings of the project to specify the Module Map File and Module Private File, but I couldn't manage to make them work—the compiler was spitting something like: Redifinition of <FrameworkName> module.
I followed solution 2 but the build fails saying: objc-header.h is not found.
I created objc-header.h in the root of the project.
Any suggestion?