We often get the requirement of using Objective-C classes and libraries in Swift. In order to help us do this, there is something called the bridging header. The way to implement this to create a header file named project_name-Bridging-Header.h. Make sure to add this in the same folder where the project.xcodeproj file resides. I have encountered issues placing it in a different folder.
Also, you may need to add it to build setting as shown below.
Now, import the required Objective-C header files to project_name-Bridging-Header.h.
Let assume, you have a Objective-C class as shown below.
You can use the methods as shown below.
Using class methods of Objective-C in swift
Leave a Reply
You must be logged in to post a comment.