How to import private framework headers in a Swift framework?

Mihai Damian

I have an Objective-C framework (framework A) that exposes some public and some private headers. The public headers are also declared in the framework's umbrella header. I have a second Swift framework (framework B) that links with the Objective-C framework.

Now, if I want to import the public headers of A in B I simply need to do an import A.

But how do I go about importing the private headers?

I know a bridging header is not an option since that's not supported for frameworks. Do I need to somehow create a separate umbrella header for the private headers?

rintaro

You need to modify framework A, So that it export a private module.

  1. Create a private module map file in A project. This would be something like this:

    A/private.modulemap:

    explicit module A.Private {
    
        // Here is the list of your private headers.
        header "Private1.h"
        header "Private2.h"
    
        export *
    }
    
  2. In the "Build Settings" of framework A target, search "Private Module Map File" line, and make that:

    $(SRCROOT)/A/private.modulemap
    
  3. Do not include private.modulemap file in "Compile Sources". That causes unnecessary warnings.

  4. Clean and Build framework A target.

  5. In framework B Swift files. you can import the private module like this:

    import A
    import A.Private
    

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do you selectively import a framework in Swift?

Create and import swift framework

How can I create private module without including private headers into the framework?

How do I use a private iOS framework from Swift?

Import Framework in Swift Project, Xcode

iOS Swift framework: How to import Objective C code into swift framework properly?

How to import and use Swift Pod Framework in Objective-C Project

How to import opencv2 framework in iOS Swift

iOS mixed dynamic framework - bridge objc headers with private module

How to link a stand-alone Swift OS X app to a private framework (also created in Swift)?

Why does Apple discourage the use of '@import' in framework headers?

Import Objective-c framework into Swift framework project

Import Objective-c framework into Swift framework (Google Analytics + Cocoapod)

Import Objective-C Framework (CocoaPod) into Swift?

import .framework inside SPM (Swift Package Manager)

Import Facebook SDK inside Framework in Swift

Import my custom module/framework Xcode Swift

Import Swift framework to Obj-C

Swift - import all of framework VS part of it

How to convince Zend Framework to send duplicate headers?

How to edit configured headers in karate framework

How to hide private module of iOS Framework?

Import C headers in Swift

Finding GPUImage framework headers

How to use Cocoapods in a Swift framework?

Import Swift framework in Swift: "Use of undeclared type 'MyCustomView'"

iOS import swift class from swift using framework

Swift "encrypt" String using RSA Private key with Security framework

How to export a swift class that I made from one file and import it to another using the cocoa framework without Xcode?