Xcode MyProjectName-Bridging-Header.h does not exist

IosObjective CXcodeSwift

Ios Problem Overview

I want to start using Swift in my Objective-C project. So i added a swift class:

import Foundation
@objc class System : NSObject {
    @objc func printSome() {
        println("Print line System");

And imported it into a .m file:

#import "MyProjectName-Swift.h"

When building my project i get the following error:

Bridging header 'PathToMyProject/MyProjectName-Bridging-Header.h' does not exist

NOTE: Under "Build Settings->Swift Compiler - Code Generation->Objective-C Briding Header" is set to MyProjectName-Bridging-Header.h

What should i do to solve this issue?

Any help is much appreciated.

EDIT: Bridging-Header file: #if defined(__has_include) && __has_include() # include #endif

#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

#if defined(__has_include) && __has_include(<uchar.h>)
# include <uchar.h>
#elif __cplusplus < 201103L
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class

#if defined(__has_attribute) && __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#if !defined(SWIFT_CLASS_EXTRA)
#if !defined(SWIFT_CLASS)
# if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted) 
#  define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# else
# endif

#if !defined(SWIFT_PROTOCOL)

#if !defined(SWIFT_EXTENSION)

# if defined(__has_attribute) && __has_attribute(objc_designated_initializer)
#  define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"

#if defined(__has_feature) && __has_feature(modules)

#pragma clang diagnostic pop

Ios Solutions

Solution 1 - Ios

If the bridging file is created at the same level as the other classes, you might need to add the relative path, as these pictures show. Note here that the bridging file is created at the same level as the other classes: enter image description here

I have the name entered correctly in the Build Settings, enter image description here

but the compiler doesn't find the file. enter image description here

Therefore, if I add the relative path from the root of the project (that is, I add ./ProjectName/BridgerFileName.h), enter image description here

now it compiles and I can call a method in my Objective C class: enter image description here

Solution 2 - Ios

I found that after creating the bridging header file manually and choosing the default name and location, the bridging header will be placed in the project directory, which is under the root directory.

This requires the following value for the setting: Targets > [Your App Target] > Build Settings > Swift Compiler - Code Generation > Objective-C Bridging Header:


Note that if your project is a swift module (framework) then, as pointed out in the comments, you might prefer:


Solution 3 - Ios

For those who are removing the Bridging Header

I was going the opposite way as most of the other answers here. I had been using a Bridging Header previously, but I didn't need it anymore. After I deleted it from my project I started getting the error mentioned in the question. I performed the following steps to solve my problem.

  1. Go to Targets > [Your App Target] > Build Settings > Swift Compiler - General > Objective-C Bridging Header and delete the path. (Thanks to @Donamite for the idea.) (You can just start typing "bridging" into the search box to find it.)
  2. Delete the derived date. Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.

enter image description here

Solution 4 - Ios

In Swift 4.1

your project you don't have bridging-Header.h file, but your project has that path. For this you need to delete that path...

Go to targets file and select Build Settings, ---->Swift Compiler - General, and delete the bridging-Header.h. Follow below screen shots....enter image description here

Delete the bridging-Header.h file in Swift Compiler - General

enter image description here

Now you got like this...

enter image description here

Solution 5 - Ios

These are steps to create Bridging header.

  1. File->New->iOS->Header File, Give the bridging file name as like "yourProjectName-Bridging-Header.h"

  2. Build-Settings->Objective-C Bridging Header, Just give the bridging header file name be like "ProjectName-Bridging-Header.h"

NOTE: Bridging header file should be located in the main root folder of the project where the ".xcodeproj" file located. If not move the Bridging header file to the root folder of the project. This way Xcode able to access the bridge file.

  1. Build the project, and import necessary files in Bridging header.

Solution 6 - Ios

To add Bridge File in Swift project.

Step 1. Go to File > Add Cocoa with Objective-C File (For temporary Purpose)

enter image description here

Step 2. Then the following pop up will appearenter image description here

Now press Create Bridging Header Button


Solution 7 - Ios

For me it helped to use $(SRCROOT)/$(PROJECT_NAME)/ in front of my bridging header file path

Solution 8 - Ios

For me it helped to use $(SRCROOT) in front of my Objective-C bridging header path.


Solution 9 - Ios

Follow the steps below:

  1. Delete bridging header file . . . (Maybe you create manually) and;
  2. Create new Swift file in Objective-C Project . . . (Not import, first create it)

Maybe these two things will help solve your problem.

Solution 10 - Ios

The following worked for me:

  1. Bridging header file should be located in the main root folder of the project where the ".xcodeproj" file located. Move to project directory and drag and drop bridging header to root if it is inside any other folder.
  2. Correct spelling mistakes in header name.
  3. Clear Derived data
  4. Target -> Build Settings -> Swift Compiler : General -> Add Obj C Header name.
  5. Clean and run again.

Solution 11 - Ios

Creating Bridging Header File Manually

First of all delete the Bridging header file which Xcode is created. And Select your project goto > Build Settings > Search the keyword. Swift Compiler - Code Generation. Click on Objective-C Bridging Header , delete that path. Now clean your Project.

Now select your project > Window in the navigation bar . Select Projects and delete your derived data from there.

Now create a new file , select the Source and then select the Header File and create your Bridging header file . File name must be your projectname-Bridging-Header.h and then create it

Select your project goto > Build Settings > Search the keyword. Swift Compiler - Code Generation. Click on Objective-C Bridging Header and now add the path in this Objective-C Bridging Header like projectname-Bridging-Header.h

Now import your classes into bridging header file and you can compile it your code easily.

Your bridging header file looks like this when you are creating your file manually.

Solution 12 - Ios

What helped me was to move the file manually to the path mentioned in an error message. So:

  1. I deleted the file (moved to trash)
  2. Moved it from trash to the path in an error message
  3. Later I also had to clean the project


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2408952View Question on Stackoverflow
Solution 1 - IosJames ToomeyView Answer on Stackoverflow
Solution 2 - IosuɥƃnɐʌuopView Answer on Stackoverflow
Solution 3 - IosSuragchView Answer on Stackoverflow
Solution 4 - IosNareshView Answer on Stackoverflow
Solution 5 - IosVishnuvardhanView Answer on Stackoverflow
Solution 6 - IosManinderjit SinghView Answer on Stackoverflow
Solution 7 - IosSrinivas PadidalaView Answer on Stackoverflow
Solution 8 - IosAntoineView Answer on Stackoverflow
Solution 9 - IosiHardikTrivediView Answer on Stackoverflow
Solution 10 - IosAlvin GeorgeView Answer on Stackoverflow
Solution 11 - IosMandeep SinghView Answer on Stackoverflow
Solution 12 - Iosjreft56View Answer on Stackoverflow