iOS mixed dynamic framework - bridge objc headers with private module
Asked Answered
F

1

7

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?

Fluctuant answered 25/1, 2016 at 17:28 Comment(2)
Any luck finding a solution?Tiossem
No! Tried a lot of variations of the documetnation in LLDB but nothing works for me.Fluctuant
F
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

Fluctuant answered 29/5, 2016 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.