Swift Bridging Header import issue

Nikita Pronchik picture Nikita Pronchik · Jun 10, 2014 · Viewed 135.6k times · Source

Following instructions, I've created a bridging header and added to my project. Unfortunately, the following error occurred:

:0: error: could not import Objective-C header '---path--to---header/....h'

Screenshot 1

In build settings I added header search path string to the location of bridging header, but nothing helped.

Has anyone experienced this problem?

Answer

Renan Kosicki picture Renan Kosicki · Jun 18, 2014

Be careful to add the file to the folder that your error is complaining! I've made the same mistake, if you create the file from Xcode, it will go to the folder: Project->Project->Header.h

And Xcode is looking for Project->Header.h

That means you need to put the file inside your project folder (ProjectName->ProjectNameFolder)!

Hope that helps ;)

UPDATED: I'm not sure if I got what you mean, but try this to solve your problem:
1. Delete all your bridging files that you created until now.
2. Select the main folder of project and hit new file->iOS->Header file.
3. Write your imports in the header file created.
4. Select the project inside Xcode->Build Settings, type in search field: bridging and put in the key SWIFT_OBJC_BRIDGING_HEADER the name of your header file or the path to it!

If you follow this steps, your header file will be created at the correct location!

:D Hope that helps!