How do I remove a bridge header without getting errors?
Asked Answered
H

4

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

Hawthorne answered 28/8, 2015 at 15:31 Comment(0)
C
114

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

enter image description here

Cooee answered 28/8, 2015 at 15:33 Comment(6)
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.Spirochete
I had to remove this from the Target Build Settings not the Project, but it's thanks to your answer I found this. :-)Ecclesiastic
Did not solve all my problems. When I run my app and using a UICollectionView I get 'Unable to simultaneously satisfy constraints...'Adlar
@Adlar it's some kind of Auto Layout problem, not related to bridging header. This might help you: #25630815Cooee
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.Adlar
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.Gribble
T
7

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

Taraxacum answered 12/10, 2019 at 9:44 Comment(0)
A
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
Absorbing answered 11/4, 2021 at 6:20 Comment(0)
S
-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?).

Sanborne answered 27/3, 2020 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.