Objective-C Bridging Header for frameworks

Gustaf Rosenblad picture Gustaf Rosenblad · Jul 19, 2014 · Viewed 25.6k times · Source

I've made a framework that requires the sqlite3 framework. How do I add a Objective-C Bridging Header for my framework that imports sqlite3 into my Swift file?

I already have a bridging header file for my project, but not for my framework.

Answer

Gustaf Rosenblad picture Gustaf Rosenblad · Jul 19, 2014

I found a Objective-C Bridging Header setting in the target Build Settings. It was hidden by default. Check All instead of Basic.

In recent Xcode versions this solution would give the error Using bridging headers with framework targets is unsupported.

The workaround I've been using is to make the C-header public in the file inspector and import it in MyFramework.h like this example:

#import <MyFramework/MyObjectiveC.h>

How to change the C-header to public

Open your C-header and view the inspector by clicking in the upper right corner. To view the file inspector, click the file icon in the upper right corner.

enter image description here