5

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.

Christophe
  • 68,716
  • 7
  • 72
  • 138
xyz123
  • 191
  • 1
  • 3
  • 6
  • Can you post the full compiler error? – JAL Jun 27 '15 at 22:25
  • What happens if you delete your bridging header and get Xcode to generate a new one by attempting to drag an Objective-C file into your file navigator? – ndmeiri Jun 27 '15 at 22:35
  • Here's the full compiler error: /Users/xyz123/Documents/Apps/Backups/MostRecentAppName/AppName/Facebook-Bridging-Header.h:11:9: error: 'FacebookSDK/FacebookSDK.h' file not found #import ^ :0: error: failed to import bridging header '/Users/xyz123/Documents/Apps/Backups/MostRecentAppName/AppName/Facebook-Bridging-Header.h' – xyz123 Jun 27 '15 at 22:37
  • xcode autogenerates a bridging header when you try to create or drag in an objective c file to the project for the first time.. it isn't doing that now because its not my first time for this project. – xyz123 Jun 27 '15 at 22:38
  • i am getting same error. – Hiren Panchal Jul 23 '15 at 05:30
  • If you previously had a bridging header and deleted it, make sure you delete the path as well from "Swift Compiler - Code Generation". Then create any Objective-C file in your project, and it will prompt you to create a header file. – Emmy R Nov 25 '15 at 19:46
  • There is answer: [it is a link](http://stackoverflow.com/questions/34046676/file-not-found-in-bridging-header-when-importing-objective-c-frameworks-into-s/34046677#34046677) – childrenOurFuture Dec 02 '15 at 15:37

4 Answers4

1

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.

Artal
  • 8,933
  • 2
  • 27
  • 30
  • i just checked and $(inherited) is already there. any other advice? – xyz123 Jun 29 '15 at 09:48
  • @xyz123 you said that the search paths were empty, so I thought this was the issue. Maybe you're missing something else in the search paths besides the $(inherited). Also, you can try to start over and recreate the bridging header yourself from scratch, make sure everything is valid. – Artal Jun 29 '15 at 11:26
  • i have tried that already, and it doesn't work. what all am i supposed to have in the search paths? – xyz123 Jun 29 '15 at 23:07
  • @xyz123 I don't know if the search paths are even the issue here. As said, I mentioned it because initially you wrote that it was all empty. – Artal Jun 29 '15 at 23:18
  • My search paths seem to be right (I compared with older projects that I have that are working), but I'm still getting the error. It also says not found. Any more advice? – xyz123 Jun 30 '15 at 08:59
1

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

Darrell C
  • 11
  • 4
  • the header is showing up when i do that, and the import statement is there. the fbsdkcorekit.framework is in build phases – xyz123 Jun 29 '15 at 09:48
  • 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 – Darrell C Jun 30 '15 at 00:33
  • I fixed that but I'm still getting the same error. I'm also getting an error that says not found when I go to the bridging header file. Any more advice? – xyz123 Jun 30 '15 at 09:00
  • At this point it sounds like the framework file is corrupt or your paths are not correct. I would make triple sure the paths are correct ie: check for a simple typo, and then delete the frameworks and try a new copy of the framework SDK . Otherwise from what you are saying, it should find the file ok. – Darrell C Jun 30 '15 at 16:47
  • if you can,maybe a screenshot of your file structure and the build phase/setting screen would help. Just grasping at straws now really – Darrell C Jun 30 '15 at 16:49
1

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.

Eric Hou
  • 341
  • 3
  • 9
0

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.

luizParreira
  • 1,079
  • 12
  • 14