![]() |
What is a Swift Bridging Header?
A Swift bridging header is the communication media with your Objective-C classes from your Swift classes. Bridging header plays an important role in Swift that allows to run the Swift code along with some codebase written in Objective C. |
Suppose,you are creating a project in Swift,of course you need to write the whole code in Swift programming language.
But there are some classes or libraries you may use in your Swift project such as SVProgressHUD haven’t been rewritten in Swift and you will need to use a bridging header to use them.
How do you perform wireless debugging in Xcode 9 and iOS11 ?
Xcode gives option to create Bridging Header for my Project automatically
Whenever you Add a new Swift file to your Xcode project and try to name it ,Xcode will show an alert box asking if you would like to create a bridging header.
Note:
If you skip the prompt for creating a bridging header, Xcode will decline the option for you.
But it's not a big task ,you can create it manually.
How to create a bridging header manually in xcode?

Create a new file to Xcode
-Go to File > New > File, then select “Source” and click “Header File“.
-You can rename the file as “Yourproject-Bridging-Header.h” and It will ask for creating a bridging header.Create and click finish button.
-Go to project build settings and find the “Swift Compiler – Code Generation” section.
You can find it faster to type in “Swift Compiler” into the search box.
Note:
If you don’t have a “Swift Compiler – Code Generation” section which means you need to add a Swift file to your project.
You should add a Swift file, then try again.
Next to “Objective-C Bridging Header”, make sure you are adding the name/path of your header file.
If your file exists in your project’s root folder ,then you can put the name of the header file there.
Examples:
“ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.
Open up your newly created bridging header and import your Objective-C classes using #import statements.
Each classes listed in this file will be accessible from your swift classes.
Hope it will help.