9

I need to add some Objective-C files of a library to my project, and I created the MyProject-Bridging-Header.h file myself. But now I'm not able to set its path because in the project's Build Settings I don't find the Objective-C Bridging Header entry.

Is somebody else experiencing the same? How could I solve this?

AppsDev
  • 12,319
  • 23
  • 93
  • 186

2 Answers2

12

In Build Setting choose "all" instead of "basic" enter image description here

Farnad Tohidkhah
  • 1,229
  • 1
  • 10
  • 19
8

Usually when you had an Objective-C/Swift project and have added new Swift/Objective-C class file Xcode asks whether you want to create Bridging Header or not.

  • If the option to create Bridging Header automatically f.e. has been denied there`s still an option to create it manually.

  • Since you have already created YourProject-Bridging-Header.h header file all you need to set the path to it in your project Build Settings.

  • To set the path to your Bridging Header file you need to navigate to your project Build Setting where look for Swift Compiler – General section like the Hoa mentioned above.
    It is located between "Swift Compiler - Custom Flags" and "Swift Compiler - Search Paths" ones at the same page with all "Swift Compiler" sections.

  • There you can see Objective-C Bridging Header which you can click and set the path to your YourProject-Bridging-Header.h Bridging Header file like YourProjectName/YourProject-Bridging-Header.h.

  • Now you can open up your YourProject-Bridging-Header.h and put Objective-C/Swift classes using the #import statement into it.

Thanks to http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/
And Objective-C Bridging Header not getting created with Xcode 8

Community
  • 1
  • 1
Alexander
  • 2,803
  • 5
  • 13
  • 21
  • The thing is that under `Swift Compiler - General` section I only see `Optimization Level` – AppsDev May 01 '17 at 15:50
  • That's true, sorry. I meant if you open up the page with `Swift compiler`'s the `Swift Compiler - General` will be a little bit lower than the `Swift Compiler - Code generation` at the same page. You should stick with the `Swift Compiler - General` and check for `Objective-C Bridging Header` there. – Alexander May 01 '17 at 15:57