Failed to Import Bridging Header Error

14.4k views Asked by At

I accidentally messed up my projects' settings while installing and then uninstalling cocoapods. I'm now getting the error "failed to import bridging header". I checked my build settings and the path to the file under build settings > code generation > objective-c bridging header is correct. I messed around with my Framework Search Paths (they are empty now) in build settings while trying to get cocoapods to work. Would really appreciate some help on fixing this bridging header issue.

4

There are 4 answers

0
luizParreira On

I hope you have managed to find a solution on your own. I came across this issue today trying to implement a framework into a project without having to use cocoapods. The framework just wouldn't get recognized by xcode. The way I solved this is:


  1. I created a blank project in xCode 6.4 and followed on the steps to add the framework in a swift project normally. As expected the framework worked perfectly in conjunction with the Objective C Bridging Header, as this framework is in Objective-C.

  2. I then did the same with xCode 7 beta 3. Which it didnt work because of this bug.

  3. I then went into the xCode 6.4 project and looked at Target -> Build Settings -> Search Paths and looked at what was written there for the Framework Path and Header path.

  4. Then I went to the same place and xCode 7 and found that it was completely empty there.

  5. Then I just had to copy the path written on xCode 6.4 and adapt it to the xCode-beta path. You can look for the path on finder by typing Command + Shift + G when finder is open to search for a path. And then Test it out for your path for xCode beta and for xCode 6.4 and see if you are on the right path.

  6. Clean and Build your project and check if the Bridging Header is working.

0
Eric Hou On

If you add a pod written in Swift and you dont include "use_frameworks!" in your Podfile, your pods wont install and you will receive this error. Include "use_frameworks!" in the Podfile and pod install again.

5
Darrell C On

Do a search in XCODE for header, see if the bridge header is still "there", if so click on it so it will show in the frame....then look to see if the facebook sdk #import statement is stil there, if not add it .

if you dont find the header file after the search...click file and "Add files to and see if you can find the -Header.h there, if so add it back to your project, if not go to the Build settings again and "clear out " the paths to the header, save your project , close it , reopen it, then try to add a C file and see if the file will regenerate and then you can re add the call to #import facebookSDK

Another thing is you could check to make sure the FBSDKcoreKit.framework is put back into the Build Phases of your target under link binary with libraries

EDIT from your reply :

inside your search paths you should also have the following $(PROJECT_DIR)/yourprojectname just below $(inherited) if you DO NOT have $(PROJECT_DIR)/yourprojectname it WILL give you that error you mentioned as I have duplicated it by removing that from Frameworks search paths

I cant post an image yet or I would for reference

5
Artal On

Sounds like the empty Header Search Paths might be what's causing your problems. Try to add $(inherited) to the Header Search Paths list in Build Settings. It will make sure that the header search paths set in the pods xcconfig files are being used.