Category Archives: swift

Using Objective-C in Swift projects with a bridging-header

A general problem with starting a new project in a new language is that most of the times you are missing the libraries, classes etc. you feel comfortable with.

Same happens with making the switch from Objective-C to Swift.

But there is a solution that is called “bridging header”, that brings Objective-C into Swift.

Using it , its not that complicated.

  1. create a .h file in your project, e.g. projectname-bridging-header.h
  2. open the Build Settings in your project targets and search for “bridging
  3. add your filename (here: projectname-bridging-header.h) to the “Objective-C Bridging Header” including the path the file can be found (e.g. projectname/projectname-bridging-header.h)
  4. open your projectname-bridging-header.h and add your import lines as you would do in a normal Objective-C header (e.g. #import “foo.h”)

That’s it.

Now you can access and use the new available classes in the Swift way.