How do I remove a bridge header without getting errors?

16,377

Solution 1

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

enter image description here

Solution 2

enter image description hereGo 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
Share:
16,377
Caleb Kleveter
Author by

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, 2022

Comments

  • Caleb Kleveter
    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

    Xcode Bridge-Header error File tree for an Xcode project

  • bitsand
    bitsand about 8 years
    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.
  • lukkea
    lukkea about 8 years
    I had to remove this from the Target Build Settings not the Project, but it's thanks to your answer I found this. :-)
  • Zvi
    Zvi over 7 years
    Did not solve all my problems. When I run my app and using a UICollectionView I get 'Unable to simultaneously satisfy constraints...'
  • egor.zhdan
    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
    Zvi over 7 years
    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.
  • Nelson Capes
    Nelson Capes about 4 years
    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.