Getting “file not found” in “Bridge Header” when importing Objective-C frameworks into a Swift project

I have a Swift project for which I am trying to import frameworks based on ObjC. The structure is located in the directory on the path to the project and refers to the project in Xcode. It is also added to the "Link Binary with Libraries" on the "Create Phases" page of the project.

However, for some reason I cannot include the framework in the Bridging-Header file. I get the following error:

BridgingHeader.h:5:9: error: 'Parse/Parse.h' file not found #import <Parse/Parse.h> ^ <unknown>:0: error: failed to import bridging header 'BridgingHeader.h' 

Things I checked:

  • "Set Objective-C Compatibility Header" is set to "YES".
  • Header search paths include a framework path.

I am sure that I have something missing, so if anyone has any clues, it will be great.

+78
xcode swift
Dec 16 '14 at 1:23
source share
19 answers

Found a solution:

  • The parameter "Objective-C Bridging Header" (aka SWIFT_OBJC_BRIDGING_HEADER ) must be set at the target level, and NOT at the project level. Be sure to delete the parameter value at the project level.

(for me, this looks like an Xcode error, since I don't know why it fixes it).

+67
Jan 18 '15 at 6:26
source share

I have the same problem. I changed all my imports from #import "HMSegmentedControl.h" to #import <HMSegmentedControl/HMSegmentedControl.h> , for example.

+53
Feb 12 '16 at 11:13
source share

I had to add my lib directory in the user header search path:

test target settings - user header search path

In my case, the lib directory contains the .a -library file and some header files. They are included in the bridge header file. However, the fast compiler did not find them. Only when I added ${PROJECT_DIR}/lib to the user header search path did he create a test target.

(I am using Xcode 6.2 on Mavericks 10.9.5)

+23
Apr 27 '15 at 18:02
source share

We encountered the same error message with a completely different reason.

Setup:

  • Purpose of the application, all Obj-C code
  • Unit Test with one quick test case and a connection header that references application code

When we added the second test case, after a clean one (or on the machine for the team), we saw this error when creating the unit test target.

It has been fixed by adding a dummy Obj-C class to the unit test target.

+18
Mar 06 '15 at 23:30
source share

This somehow helped me:

  • Clear project
  • Empty build folder
  • Restart xcode
+5
Aug 04 '16 at 15:11
source share

Well, this is a little strange, but I think you should add the resource to your “Copy Stock” phase of your test target so that it loads all the headers from the main goal of the application. In my case, I added main.storyboard and took care of the error.

enter image description here

+4
Apr 28 '15 at 16:20
source share

This error occurred when installing the CocoaImageHashing library with Cocoapods. The problem was that the search paths were wrong. Thus, at the target level, in the assembly settings → search paths → search paths for the headings of the paths corresponded to nonexistent folders, for example, “$ {PODS_ROOT} / header / publication / CocoaImageHashing” when the folder structure Headers / Public / does not exist. I added the path $ {PODS_ROOT} / CocoaImageHashing, and the error went away.

+4
Feb 23 '17 at 11:09
source share

If someone helped.

In my case, my obj-c files were added, there is a help folder (blue folders in xcode), and the header could not find them. Just added the files, not the folder, from the crawler to xcode and decided.

+3
Jul 13 '16 at 22:44
source share

I had the same problem. For me, the reason is that I used the same header for my application and my Today Extension. My Today Extension does not include Parse, but since it was defined in the header, he tried to find it. I created a new header for my Today extension and error.

+2
Dec 30 '15 at 16:14
source share

I had a problem and fixed it by spending 2 hours searching. My environment is as below:

cocoapod 0.39.0

swift 2.x

Xcode 7.3.1

Steps:

  • project path: project_name / project_name / your_bridging_header.h
  • In the Swift section in setting up the Objective-C assembly, the header title should be: project_name / your_bridging_header.h
  • In your_bridging_header.h, change all ads from .h to #import
  • In the class used by your_3rd_party . Declare import your_3rd_party
+2
May 16 '16 at 10:31
source share

My framework worked before that and suddenly stopped working, and none of these answers worked for me. I removed the framework in Build Phases> Link Binary With Libraries and re-added it. Started to work again.

+1
Feb 19 '16 at 15:34
source share

I just duplicated an existing circuit and added another configuration to the project. I had to add a configuration with the same name to the framework project so that it could also be created in the same folder DerivedData/($AppName)/Build/Products/($CONFIGURATION_NAME) . Otherwise, the .framework file is not created and therefore cannot be imported.

+1
Sep 16 '16 at 19:35
source share

Today I came across the same question when trying to use a pod written in Objective-C in my Swift project, none of the solutions above seem to work.

In podfile I wrote use_frameworks! . Commenting on this line and then running pod install , it again solved this problem for me and the error went away.

+1
Jan 18 '17 at 8:18
source share

(Updated on May 27, 2017)

Xcode 8. Swift Project - Import Target C.

What you need to know:

  • The bridge header file MUST be saved in the project folder. (that is, it is not saved at the same level as .xcodeproj is saved, but instead, one level is further down to the folders where all your fast and objective files are saved c). It can still find the file at the top level, but it will not link correctly and will be able to import Objective-C files into the bridge header file
  • A bridge header file can be called anything if it is a .h header file
  • Make sure that the path in the build settings> Swift Compiler - General> Objective C Bridging Header correctly indicates that you hover over the header file that you created.
  • IMPORTANT: if you still get "not found", try first to clear the header file of the bridge and delete all the data you imported there that you wrote. Make sure the first header file can be found first, and then add the object import c to this file. For some reason, it will throw the same “not found” error, even if it is found, but for some reason import is not possible.
  • You should not #import "MyBridgingHeaderFile.h" in any of your objective C files. This will also result in a "file not found" error.
+1
May 29 '17 at 16:19
source share

If using cocoapods, try reinstalling the containers by running the following command.

 pod install 
0
Sep 02 '15 at 11:20
source share

I had a similar problem and only one solution was developed for me. I tried everything suggested, and I knew that I set the bridge title normally, because some other library worked for me.

When I copied (dragged) the library to a project without Cocoapods, only after that I could import the headers without errors.

I used the Facebook / Shimmer library.

0
Feb 09 '18 at 13:15
source share

I had a similar problem with pods. Mostly trying to run my user interface tests, Xcode complained about the lack of modules. The solution to this problem was much simpler than any of the above:

  1. go to the project file (the main thing is not the goal)
  2. click on the "Information" tab (left)
  3. set the correct module configuration for the purpose of the user interface tests (section "Configurations" in the section "Deployment Goal")

At work!

I found this in the stream: https://github.com/CocoaPods/CocoaPods/issues/2695

Sounds like a bug for cocoa beans, but I see reasons why it can be tricky.

0
Mar 22 '18 at 14:28
source share

Clean project, Clean build folder, Restart Xcode. I just delete the path in the project go> Build settings> Search by keyword. Swift Compiler - General -> Objective-C Bridging Header worked for me.

0
Feb 05 '19 at 14:12
source share

In my case, I just needed to exit the simulator ...

-one
Jun 14 '18 at 11:22
source share



All Articles