43

I added a bridge header to my app the other day because I was trying to add Objective-C files to my Swift project. I was having trouble getting the connection to work(and I also did not know how to implement the Objective-C files), so I decided I wanted to start over again. I deleted the Objective-C files and the Bridge-Header file and now I am getting an error saying:
<unknown>:0: error: bridging header '/Users/CalebKleveter/Documents/Development/iOS/personal/swift/Projects/Dicey/Dicey/Dicey-Bridging-Header.h' does not exist

Xcode Bridge-Header error File tree for an Xcode project

Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92

4 Answers4

113

Go to Build Settings of your project, find Objective-C Bridging Header row and remove its contents.

enter image description here

egor.zhdan
  • 4,555
  • 6
  • 39
  • 53
  • 7
    This works, and in case anyone ends up with a lot of new errors with NSObject after removing this, check to make sure that you have 'import foundation' in your classes that inherit from NSObject. The bridging header negated the need for those import statements beforehand. – bitsand Apr 24 '16 at 14:24
  • 12
    I had to remove this from the Target Build Settings not the Project, but it's thanks to your answer I found this. :-) – lukkea Apr 29 '16 at 11:44
  • Did not solve all my problems. When I run my app and using a UICollectionView I get 'Unable to simultaneously satisfy constraints...' – Zvi Aug 29 '16 at 12:50
  • @Zvi it's some kind of Auto Layout problem, not related to bridging header. This might help you: http://stackoverflow.com/questions/25630315/autolayout-unable-to-simultaneously-satisfy-constraints – egor.zhdan Aug 29 '16 at 15:26
  • I think you are right. Just that I got it after I removed the bridging header (or maybe I just noticed it afterwards). Anyway, I fixed it. – Zvi Aug 29 '16 at 15:30
  • Xcode 11.4.1 has a file UIView+image.swift that throws a Build error in an extension to UIView when I removed the objective-c bridging header path as described. I had to edit the file and add "import UIKit" even though "import Foundation" was already there. This seems like an Apple Swift problem. – Nelson Capes May 05 '20 at 20:34
5

enter image description hereGo to targets file->Build Settings->Swift Compiler - General, delete the contents in the same line as Objective-C Bridging Header

Timchang Wuyep
  • 629
  • 7
  • 10
1

Since removing the bridging header or even just leaving it without any content often causes build errors, the quick workaround I've found is leaving the header with nothing but the following two imports:

#ifndef BridgeHeader_h
#define BridgeHeader_h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#endif
Arik Segal
  • 2,963
  • 2
  • 17
  • 29
-1

Deleting the lines containing SWIFT_OBJC_BRIDGING_HEADER in MyProjectName.xcodeproj/project.pbxproj did the trick for me.

I could not find the Build Settings in my Xcode project as other answers mentioned (maybe because my project is for MacOS, not iOS?).

Logan
  • 1,575
  • 1
  • 17
  • 26