This is a simple way to use both“Swift” and “Objective-C” in the same project. Now, I use swift in project but some frameworks or library are Objective-C. Apple offer easy method called “Bridge-Header” so I will show you: How to use “Brdge-Header” in your project. It very common and fast to understand.
In the example, I want to use AFNetwork that Objective-C framework into swift project. There are a little step and not difficulties. I will make it in step by step.
First, create “Header file” by Newfile -> source -> Header File
I create “Header” that header file’s name so there is Header.h in project. In “Header.h” write some code to import framework.
Then, go to “PROJECT” and “build setting”. In search fill, enter “swift compiler”. In “Swift Compiler-Code Generation”, finding “Objective-C Bridging Header”. Now, it is empty.
Next, double click in this empty and write your path of Header file by [Project Name]/[Header File Name] such as “TestBridgeHeader/Header.h”.
When finished, enter and Objective-C Bridge Header isn’t empty.
Finally, import framework in swift project and you can use all frameworks Objecttive-C that you import at header file in every where.
Congratulation!! you can use both swift and objective-c in the same project. I hope this story will help you so much(Ha Ha Ha~). Thank you for reading. Have a nice month in happy December.