Gabe Sechan
Gabe Sechan

Reputation: 93542

Trying to use Objective C cocoa pod in Swift project, bridging file compiled as Swift code

I'm trying to use an objective C based cocoa pod (GCM) in a Swift based iOS project. I have the cocoa pods installed and I've created a bridging file by hand, adding it to the build preferences as a bridging file. The problem is that when I compile, the bridge.h file is compiled as Swift (when obviously it should be objective C). More explicitly- all of the lines inside the included.h files are throwing errors, not the bridg file itself. Here's my bridge file

#ifndef bridge_h
#define bridge_h
#import <GoogleCloudMessaging.h>

#endif /* bridge_h */

Any idea what is going wrong and why the code being imported isn't treated as Objective C?

Upvotes: 1

Views: 445

Answers (2)

Gabe Sechan
Gabe Sechan

Reputation: 93542

With the help of a coworker we figured it out- the bridging file must include Foundation/Foundation.h and must do so before it includes anything else. Otherwise it fails to compile.

Upvotes: 1

Damien
Damien

Reputation: 3362

You have the possibility to check and change your file type in the file inspector when you have your file selected. Look if it's objective-c header.

Upvotes: 0

Related Questions