Objective-C Bridging Header not getting created with Xcode 8
It seems easiest to simply create a new Objective-C File and have Xcode take care of all the nitty gritty of setting up everything. Once that's done, you can delete the Objective-C file.
- Right Click in the project explorer and choose new file
- Selected Objective-C File
- Name it
delete_me
or something - You'll get prompted to have a bridging file created and say yes
- Delete the file you created (perhaps
delete_me.m
)
Here the solution for the issue.
- Create a new header file and name it like "your project name-Bridging-Header.h". The file must be saved to your project folder
- Select your xcode project -> select your build target -> select build settings -> click the "all" option at the top -> search for Swift Compiler - General
- Select Objective-C Bridging Header item and double click on its value field (right side of the same row). One popup would appear and there you can enter your bridging header file path (Follow the below steps to provide header file path).
Open finder and drag and drop your bridging header file to the popup. Now it will create an absolute path for bridging header. To make relating path, you can give the path as $(PROJECT_DIR)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h
Click outside for the value get saved. Done!! Now you can import your Objective-C libraries (eg. #import "SVProgressHUD.h") to bridging file and start using it in your swift project.
Hope this would be helpful to someone. :)
In the case of multiple targets, make sure the swift classes are members of that target, or else the file will not be generated.
Xcode 8.3
Objective C Header file creation steps
File -> New -> File -> Header File
Name your Header file like this yourAppName-Bridging-Header
Now click on your Project -> Build Settings
Change from Basic to All
Search Bridging
You will get the search result as shown in the below image
after Adding
In that double click the right of Objective-C Bridging Header and enter as follows
eg, yourAppName/yourAppName-Bridging-Header.h
You need to import as follows
- Thats All
Happy Coding :)