Swift Bridging Header for Obj-C

1k Views Asked by At

I have installed Card.IO via CocoaPods. My workspace looks to be correctly setup, I see the Card.IO Objective-C header files in place however when, in my main Swift project, I try to reference any of the Card.IO classes - I get the unresolved identifier error.

Edit My understanding is that Xcode cannot find the bridging header:

#import "CardIO.h"

@import AudioToolbox;
@import AVFoundation;
@import CoreMedia;
@import CoreVideo;
@import MobileCoreServices;

The documentation states

In Build Settings, in Swift Compiler - Code Generation, make sure the Objective-C Bridging Header build setting under has a path to the bridging header file. The path should be relative to your project, similar to the way your Info.plist path is specified in Build Settings. In most cases, you should not need to modify this setting.

This doesn't make sense to me - so not sure where to put the path? I've added the following to Build Settings > Search Paths > Header Search Paths > Debug & Release

MyApp/MyApp-Bridging-Header.h

but it seems this is incorrect?

1

There are 1 best solutions below

0
On BEST ANSWER

Found the answer here

https://bohemianpolymorph.wordpress.com/2014/07/11/manually-adding-a-swift-bridging-header/

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.