Xcode MyProjectName-Bridging-Header.h does not exist
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:
I have the name entered correctly in the Build Settings,
but the compiler doesn't find the file.
Therefore, if I add the relative path from the root of the project (that is, I add ./ProjectName/BridgerFileName.h
),
now it compiles and I can call a method in my Objective C class:
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:
$(SRCROOT)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h
Note that if your project is a swift module (framework) then, as pointed out in the comments, you might prefer:
$(SRCROOT)/$(PROJECT_NAME)/$(SWIFT_MODULE_NAME)-Bridging-Header.h
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.
- 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.)
- Delete the derived date. Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.
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....
Delete the bridging-Header.h
file in Swift Compiler - General
Now you got like this...
These are steps to create Bridging header.
File->New->iOS->Header File, Give the bridging file name as like "yourProjectName-Bridging-Header.h"
-
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.
Build the project, and import necessary files in Bridging header.