I have an XCode (Swift) project which is using native static lib (Swift) and this lib uses another native static lib (C++)
static lib A (C++) -> static lib B (Swift) -> MyProject
first of all, in order to be able to use methods from lib A in lib B, I need to set the bridge file in the BuildSettings, right? then I am free to use any methods from A in B, ok.
If I try to build the lib B with Build libraries for distribution = NO, everything is compiling and works, but if I need to change this value to YES (in order to distribute the lib as Release ver) I get the error
error: using bridging headers with module interfaces is unsupported
After a little google I found a few possible solutions on SO where most of them suggest setting Build libraries for distribution = NO, but this solution looks for me as a workaround, because in order to distribute the lib as a Release version you need to set it as YES.
Then I found another solution
https://developer.apple.com/forums/thread/10419
but here one explains that
You'll need to remove the bridging header from where you added it in the Build Settings, in order to get your framework to compile.
But I can't remove the bridge file as if I remove it I don't be able to use lib A in my lib B.
So, what is the proper solution here?
Yes, you can not use bridging header in a swift framework, but there is some workaround. Use Module!
@interface LibA : NSObject
+ (void)testA;
@end
so you can create map file like this:
module LibA {
header "LibA.h"
export *
}
just be careful the path
header "xxx/libA.h",
add search paths in Build Settings - Swift Compiler - Search Paths - Import Paths
$(SRCROOT)/FrameworkB/
full example in github
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With