Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Compiler is attempting to compile ObjC

Tags:

xcode

swift

I've been digging into Swift since last night and I've encountered something strange. I have included a few ObjC classes in my Swift project -- making use of the Bridging Header. However, when I attempt to build the project, the Swift compiler complains because, by all appearances, it is attempting to compile the ObjC code. Is there a step I'm missing here? Has anyone else encountered this problem and found a solution?

I have scoured the docs, to no avail.

like image 584
bgilham Avatar asked Jan 21 '26 07:01

bgilham


1 Answers

It turns out this was a silly oversight on my part. Many third-party ObjC libraries/code do not include Foundation -- assuming it would already be present. Of course, in Swift, this is not the case.

Once I added #import <Foundation/Foundation.h> to my imported header, all was well.

like image 174
bgilham Avatar answered Jan 23 '26 21:01

bgilham