How do I remove a bridge header without getting errors?
Solution 1
Go to Build Settings of your project, find Objective-C Bridging Header row and remove its contents.
Solution 2
Go to targets file->Build Settings->Swift Compiler - General, delete the contents in the same line as Objective-C Bridging Header
Solution 3
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
Caleb Kleveter
What I do: I am a Poly-artisan and backend developer using Vapor, a server-side framework for Swift. I also enjoy writing articles on Medium and occasionally do iOS development. What I am: A maintainer of the Vapor package, ConsoleKit. Release Engineer for mobile apps at Garmin. If you want to know my thoughts on Stack Overflow, read this article I wrote. What I used to be: A moderator on the Team Treehouse community. I spoke at the 2019 ServerSide.swift conference on building micro services using Vapor Favorite Accomplishments: One of 294 users to earn the Documentation Beta badge. One of 18 people to earn the Archimedes hat during 2015 winter bash. Hashtags: #winterbash #soreadytohelp A little request of mine: Please don't up-vote any of my accepted answers that haven't been up-voted or answers that you accept until I get the Unsung Hero badge.
Updated on June 18, 2022Comments
-
Caleb Kleveter almost 2 years
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
-
bitsand about 8 yearsThis 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.
-
lukkea about 8 yearsI had to remove this from the Target Build Settings not the Project, but it's thanks to your answer I found this. :-)
-
Zvi over 7 yearsDid not solve all my problems. When I run my app and using a UICollectionView I get 'Unable to simultaneously satisfy constraints...'
-
egor.zhdan over 7 years@Zvi it's some kind of Auto Layout problem, not related to bridging header. This might help you: stackoverflow.com/questions/25630315/…
-
Zvi over 7 yearsI 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.
-
Nelson Capes about 4 yearsXcode 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.