This is usually how we discover the interoperability layer. An existing Objective-C code base is getting upgraded to Swift and you need to expose existing Objective-C classes to your new Swift code.
In Swift, all of your classes are available in the current module, depending on their access control scopes. In Objective-C, one developer need is to import a header through the #import "MyClass.h" directive or the module through @import ExternalLibrary. In order to expose your classes to Swift, you'll need to use a bridging header. Its responsibility is to expose only the classes you wish to the Swift compiler.
The bridging header is a header file that contains all of the import statements of the libraries and classes that are available to Swift. Once exposed this way, those classes are automatically available in all of the Swift code.
Let's set up a project for bridging:
- Add a header file to your project; call it Bridging-Header.h, for example
- In your Project Build settings, set SWIFT_OBJC_BRIDGING_HEADER to the path relative to your project root to your Bridging-Header.h file
- Add the required imports to your header