iOS mixed dynamic framework - bridge objc headers with private module

蓝咒 提交于 2019-12-14 00:22:41

问题


In regards to a "dynamic framework" target, I need to bridge internal (private) objective-c headers to my swift counterparts.

From my understanding I need to use a private module.

Some of these swift counterparts are bridged back to objective-c using the @objc class TheClass syntax.

I've gone ahead and created a module.modulemap and a module.private.modulemap file in a directory under $SRCROOT and added the "necessary" flags to the build settings.

SWIFT_INCLUDE_PATHS =>$(SRCROOT)/...

I've also tried adding a "Private module map file" to the build settings

My module map file is:

module InnerModule {
    export *
}

and the private module file is:

explicit module InnerModule.Private {
    header "../Classes/Header1.h"
    header "../Classes/Header2.h"
    ...
    export * // and have tried without it
}

In all of the relevant Swift files I've added

import InnerModule.Private

Now when building the project I get an error in my swift bridge header

#import <MyFramework/MyFramework-Swift.h> // getting an error here

MyFramework-Swift.h // generated header file
@import UIKit;
@import ObjectiveC;
@import InnerModule.Private; Module InnerModule not found

How can this be fixed?


回答1:


Turns out that after you compile the framework you can go to the framework header, delete all the "private" headers you don't want to expose.

After that you can delete all of the header files you don't want to expose from the "Headers" directory.

Works as expected



来源:https://stackoverflow.com/questions/34998570/ios-mixed-dynamic-framework-bridge-objc-headers-with-private-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!