Reputation: 11
Using Xcode 9 and Swift 4, I created a bridging header file in order to utilize an external framework but no matter what I do, Xcode ignores the bridging header file. I followed the steps that I found online and I don't what's wrong with the project. I attached an image, shouldn't this give me a compilation error since there are invalid characters in the header file?
Click to see Xcode project image
This is not a duplicate question, that question that was suggested has issues making the header file work because of compile errors, in my situation compilation is successful and Xcode doesn't even try to compile the header file.
I created another project from scratch and I was able to make the bridging header work so I guess there is something wrong with this project. I create this project and try again.
Upvotes: 1
Views: 1551
Reputation: 681
I found out that creating objective-c file instead of directly creating header file is more convenient.
You can try to create a dummy objective-c
file.
From Xcode's file menu click File
-> New
-> File
. Choose Objective-C File
and click next
button.
You can give any dummy name you want. I gave the name as DummyFile
.
Click Next
.
Now save this file in the project's directory.
As Xcode is about to add this Objective-C
file to your Swift
project is automatically asks you to create a Bridging Header
as shown below.
[
As you click Create Bridging Header
, Xcode creates a Brigder-Bridging-Header.h
file (As my project name is "Bridger") and put it in the project's directory as shown in Xcode's project navigation pan.
Now you can import your target's public headers that you would like to expose to Swift.
You can now delete the DummyFile.m
from the project's directory if you want.
And this should work as wished.
Upvotes: 3
Reputation: 423
Project > Build Settings > SWIFT_OBJC_BRIDGING_HEADER
Have you specified the Bridging header file name here?
Upvotes: 2
Reputation: 371
As Biju said, specify Bridging header file name - try changing its location (e.g. put it inside project folder)
Upvotes: 1
Reputation: 2099
Perform a clean build by cleaning first (Command + K) and then Building (Command + B).
Had the same issue and this fixed it.
Upvotes: 0