Manually Adding a Swift Bridging Header

I watched the WWDC video, got excited, fired up my existing Objective-C project, added a Swift file, clicked “Yes” when Xcode helpfully offered to create a Bridging Header for me, and then watched helplessly as Xcode crashed. After crashing Xcode two or three times, I gave up, and added the bridging header myself, but how?

Here’s how:

1. Add a header file to your project, named [MyProjectName]-Bridging-Header.h. This will be the single header file where you import any Objective-C code you want your Swift code to have access to.

2. In your project build settings, find Swift Compiler – Code Generation, and next to Objective-C Bridging Header add the path to your bridging header file, from the project’s root folder. So it could by MyProject/MyProject-Bridging-Header.h or simply MyProject-Bridging-Header.h if the file lives in the project root folder.

You only need one Bridging Header. Add your #import statements to this file, and your classes will now be available in your Swift code without any extra import statements.