How to import private framework headers in a Swift framework?

后端 未结 4 1022
挽巷
挽巷 2020-12-07 23:15

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

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 23:52

    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
      

提交回复
热议问题