Objective-C Bridging Header not getting created with Xcode 8

Augustine P A picture Augustine P A · Sep 21, 2016 · Viewed 36.7k times · Source

I am trying to add objective-c libraries to my Swift 3 project (Xcode 8 IDE). But objective c interface header is not getting generated automatically. I tried to add bridging header manually but showing linking error saying bridging header .h is not found. Any help would be appreciated :)

Answer

Augustine P A picture Augustine P A · Sep 21, 2016

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. :)