Error, bridging header test.h does not exist - ios

So I am going crazy, since I keep on getting the error as described in the title and nothing that I worked.
I will show you what I have tried:
What else can I do?
Please help.

Creating Bridging Header File Manually
First of all delete the Bridging header file which Xcode or may be you have created. And Select your project goto > Build Settings > Search the keyword. Swift Compiler - General. Click on Objective-C Bridging Header , delete that path. Now clean your Project.
Now select your project > Click on 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 - General. 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.

In 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...

If above solutions doesn't work, follow this steps:
Create bridging header as usually.
in Build Settings add prefix + / + bridging file name.
This works for me!

remove path at project goto > Build Settings > Search the keyword. Swift Compiler - General -> Objective-C Bridging header worked for me.

Related

"Objective-C Bridging Header" entry in Build Settings does not appear in Xcode 8.3

I need to add some Objective-C files of a library to my project, and I created the MyProject-Bridging-Header.h file myself. But now I'm not able to set its path because in the project's Build Settings I don't find the Objective-C Bridging Header entry.
Is somebody else experiencing the same? How could I solve this?
In Build Setting choose "all" instead of "basic"
Usually when you had an Objective-C/Swift project and have added new Swift/Objective-C class file Xcode asks whether you want to create Bridging Header or not.
If the option to create Bridging Header automatically f.e. has been denied there`s still an option to create it manually.
Since you have already created YourProject-Bridging-Header.h header file all you need to set the path to it in your project Build Settings.
To set the path to your Bridging Header file you need to navigate to your project Build Setting where look for Swift Compiler – General section like the Hoa mentioned above. It is located between "Swift Compiler - Custom Flags" and "Swift Compiler - Search Paths" ones at the same page with all "Swift Compiler" sections.
There you can see Objective-C Bridging Header which you can click and set the path to your YourProject-Bridging-Header.h Bridging Header file like YourProjectName/YourProject-Bridging-Header.h.
Now you can open up your YourProject-Bridging-Header.h and put Objective-C/Swift classes using the #import statement into it.
Thanks to http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/
And Objective-C Bridging Header not getting created with Xcode 8

Swift bridging header file won't work with use_frameworks

I'm trying to use GoogleidentityToolkit library to handle login an things. I enable use_frameworks! on my pod file, but the module GITkit can't be found. I'm trying to figure out what's going. As far as I know if you use "use_frameworks" you don't need to create any bridging header file, since cocoapods compiles down the library into a single module, so later you can imported as usual on your*.swift files.
What do I need to get using Google Identity Toolkit library in Swift?
This question was asked one week after the release of CocoaPods 1.0.0 (at a time where CocoaPods 0.39.0 was still popular), and available version of Google Identity Toolkit was 1.1.3 from 2015, but got deprecated in favor of Firebase Authentication (pod 'FirebaseUI/Auth') following Google I/O 2016.
A) Create a Bridging Header file named
"ProjectName-Bridging-Header.h" in the root folder of your project.
B) Go to the project build settings and set the following values:
"Install objective-c compatibility header" : YES
"Objective-C Bridging Header" : path of your bridging header (e.g. "ProjectName/ProjectName-Bridging-Header.h"
After that you can use the header file to import all your ObjectiveC files which you want use within swift code.
NOTE: if required set the path as a recursive both in the resource headers and the Swift compiler search section.
None of the answers above worked for me or weren't precise enough.
In Xcode 11.4 (Swift 5.2) this solution worked for me:
1. Create a new header file in your project's root directory. I'm not sure if the name of the file actually matters, but Apple's auto-generated bridging header files are named "ProjectName-Bridging-Header.h".
2. Add all the imports you need to the newly created file.
3. In Project Navigator click on your project's name.
4. In the topmost bar choose "Build settings", and in the one a bit lower choose All and Combined.
5. Search for "Swift Compiler" in the upper right corner
6. Find "Swift Compiler- General" tab, expand it and double-click the right side of "Objective-C Bridging Header".
7. All you need to do now is just drag the bridging header file you've created into the pop-up window and hit enter. You're all set!
*Remember that you'll have to update the path to your Bridging Header every time you project's direct path changes
The easiest way I've found is to create a fake .swift file within XCode. This should bring up the prompt to automatically create a bridging header.
File > New > File...
For the filetype, choose Swift.
Allow Xcode to manually create the Swift Bridging Header.
Delete the .swift file you originally created.
Add a new file to Xcode (File > New > File), then select “Source” and click “Header File“.
Name your file “YourProjectName-Bridging-Header.h”.
Create the file.
Navigate to your project build settings and find the “Swift Compiler – Code Generation” section. You may find it faster to type in “Swift Compiler” into the search box to narrow down the results. Note: If you don’t have a “Swift Compiler – Code Generation” section, this means you probably don’t have any Swift classes added to your project yet. Add a Swift file, then try again.
Next to “Objective-C Bridging Header” you will need to add the name/path of your header file. If your file resides in your project’s root folder simply put the name of the header file there. Examples: “ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.Or, simply drag and drop bridging header file from finder to this empty field. This will automatically add the path of bridging header file.
Open up your newly created bridging header and import your Objective-C classes using #import statements. Any class listed in this file will be able to be accessed from your swift classes.
Swift 4 and Xcode 9.3
Create a Bridging Header file:
Xcode> File/New.../File> Header File
Name the file "ProjectName-bridging-header.h"
Save to root of your project folder
Xcode> Go to Build Settings (In the project explorer pane select the top most item, should be your project name and in the right pane select the "Build Settings" topic)
Just below "Build Setting" make sure "All" and "Combined" is selected
In search box type "swift compiler" and find "Objective-C Bridging Header" item
Collapse it and double click to the right of it to edit
Insert the file name of 1. above -> "ProjectName/ProjectName-bridging-header.h" (note the folder path if bridging file is saved in project folder)
Include the #import 's needed
First create briding header file with named "projectname-bridging-header.h" at your project root level.
Now in build settings set your bridging header file path and its objc compatibility header.
Once done, Clean and build your project its work fine.

Bridging header error -- "xxx-Bridging-Header.h"file does not exit in SWIFT

How to resolve Bridging header error -- "xxx-Bridging-Header.h"file does not exit in SWIFT
Check the bridging header file name in the following location in Xcode.
Go to Project traget -> Build Settings -> Objective-C Bridging Header
Set this as your Projectfolder/projectname-Bridging-Header.h
I got an solution for bridging-header.h file does not exit. Just want to share, hope it may help others too.
Follow below steps:-
First of all delete all header file if you have implemented any.
Add new header file from the ios templet. Hope you know how to add any new file, just follow in same manner.
Now go to the buid setting and there search for objective-c bridging header, simply put the header file name with .h extension too.
please see the image how to add the file name in objective-c Bridging Header

Swift Import Obj-C Framework

I am having trouble importing a Obj-C Framework into a Swift Project.
Beginning with an empty swift project here is everything I did:
Drag and drop the Tesseract framework into XCode (copy items if needed was checked)
Drag and drop a random .m file into XCode
XCode generated a Bridging Header File for me
Deleted random .m file, leaving bridging header file
Added import statement to the bridging header file
I dont have enough reputation to add pictures but here are links to various parts of my project:
Project File Structure
Project Build Phases
There is a single line of code in the Bridging Header:
#import <TesseractOCR/TesseractOCR.h>
In Build Settings the Obj-C Bridging Header setting is set to:
Swift OCR Test/Swift OCR Test-Bridging-Header.h
In Build Settings the Framework Search Paths setting is set to:
$(inherited) $(PROJECT_DIR)
I receieve a bunch of Apple Mach-O Linker Errors when I build the project. Could someone offer a suggestion about how to get the project set up properly?
Thanks
You need to add libstdc++.dylib to the Linked Frameworks and Libraries in the General tab for your project.

Swift "Bridging-Header.h" file not allowing me to instantiate objective-c classes in .swift files

When X-code tries to create a bridging header automatically, it crashes every single time, so I followed the instructions on how to manually create a bridging header.
(Create a .h file, name it <#PROJECT_NAME>-Bridging-Header.h, import all the .h files you need?)
Problem is, when I try to instantiate a class in the .swift file that's included in that header, nothing happens (it says that class doesn't exist) Also, in the Bridging Header it doesn't seem to autocomplete my filenames when I try to include them, leading me to believe somethings not linking properly.
Has anyone run into this? Does anyone know how to fix it?
You need to add it to your target's build settings:
In Xcode, if you go into the build settings for your target, and scroll all the way down you'll find a "Swift Compiler - Code Generation" section.
Set "Objective-C Bridging Header" to <#PROJECT_NAME>-Bridging-Header.h
I'm not sure of the correct value for "Install Objective-C Compatibility Header", but it's a yes/no, so you can toggle that if it doesn't work at first.
I tried to create a bridging header myself but for some reason Xcode didn't like it.
So i deleted my custom one, imported an Obj C file which made Xcode ask if I wanted it to create one for me.
I clicked yes, and it worked!
1) create a file called "FMDB-Bridging-Header.h"
inside this file type the following:
#import "FMDB.h"
3) go to Build Settings -> Swift Compiler - Code Generation
- add to 'Objective-C Bridging Header': FMDB-Bridging-Header.h
or if it was placed inside a folder in your project:
FolderName/FMDB-Bridging-Header.h
Add a header file to your project with the name "[your-project-name]-Bridging-Header.h
Go to Build Settings > Build Options and set "Embedded Content Contains Swift Code" to "Yes"
Go to Build Settings > Linking and add "#executable_path/Frameworks" to Runpath Search Paths
Build your project now!
it could help setting the name of the bridging header with its Project root, as "MyProject/MyProject-Bridging-Header.h" into the string value of the Swift Compiler Build key 'Objective-C Bridging Header'

Resources