I am building a framework in which I need to import some objective-c frameworks for now I need to import "Beaconstac.framework" but as we can not add a bridging header in a swift framework project so my question is how can I use this framework in my project this is not directly accessible in my project I tried
import Beaconstac
but its giving error "No Such Module"
is there any alternative to do this?
Swift has its own runtime, but it also has access to Objective-C runtime, and also access to C . Having access to those runtimes makes the interoperability between Swift and Objective-C easier to bridge.
Call Swift from Objective-CThe Swift library cannot be directly called from Objective-C, since it is missing the required annotations in the code, and in many cases, modules do not inherit from NSObject, rather they use the native Swift data types.
Steps to include an existing Obj C framework in a swift framework project
Say we are creating an “SwiftProj.framework" project in swift which internally has to use an Objective C “ObjC.framework”
module ObjC{
header "ObjC.framework/Headers/ClassA.h"
export *
}
Create xcconfig file (File->New->iOS->Other->Configuration Settings file)
In xcconfig file
SWIFT_INCLUDE_PATHS = $(SRCROOT)/
MODULEMAP_PRIVATE_FILE = $(SRCROOT)/module.modulemap
Now you can access ObjC.ClassA in SwiftProj.framework
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