Import Header Error Swift when relaunching app - ios

I imported a header file to a swift project.
The header file contained inputs to Parse obj c libraries.
Everything worked fine I tested with Parse no problem.
When I saved then closed the project then re-opned I get a compiler error saying the Header file cannot be found. Here is the error.
failed to import bridging header '/Users/callanmooneys/Desktop/iOS
Deveolpment/Swit/Lab cases Haematology/Lab Maternity Haematology/Lab
Maternity Haematology-Bridging-Header.h'
Tried everything here:
Swift Bridging Header import issue
I don't understand how all worked fine until I saved the project the re-opened it.
Any input appreciated.

You should also try:
cleaning the build folder using Shift-CMD-Option-K
check the build settings to be sure that the correct bridging header with correct path is selected
deleting the bridging header, but only deleting the reference. Then, quit XCode and on relaunch, re-add your bridging header to your project
creating a Objective-C header, copying the code of your old header in there, and then setting the new header as your bridging header in project settings
EDIT:
try saving the file without spaces

Even if Swift isn't in beta anymore, there are still some bugs. So you should try several things.
Delete derived Data
Clean your Project: Product -> Clean
Edit the search path (First answer)
Check that your .h file etc is still available and you didn't delete it by mistake.

This has been happening to me whenever I use an Obj-C Bridging Header in any of my projects.
Whenever I launch, I get the same error, along with another one that goes something like:
Parse/Parse.h file not found
Every time I launch Xcode, I delete the Parse.framework from my Xcode project completely, then drag it back in.
This fixes the issue for me until I quit Xcode, and then I will repeat upon relaunch.
This has been happening to me for many months, not only with Parse, but it's also happened with RevMobAds.framework. I've gotten used to deleting and reinstalling the frameworks each launch.

Related

Xcode 13: Headers of Imported Frameworks Inaccessible

I am having trouble with Xcode referencing header files from imported frameworks. The strange thing is that everything worked fine yesterday. But now, I cannot even import the same headers I see one line above that do not give me a compiler error.
You can see in the image below that the compiler is fine with "Ironsource/Ironsource.h" but when I'm trying to add it again it doesn't know what it is (but it did yesterday):
It is not a localized problem to one Xcode project, Xcode cannot see header files in any of my projects. Or more precisely, Xcode cannot see any NEW header files I would like to import but has no problem with the ones imported a day before. So, I am guessing it is something with Xcode, but I cannot figure out what went wrong.
Also, it doesn't matter if I try to reference headers in:
.framework
.xcframework
files.
The frameworks were added manually in the Project Navigator and can be seen properly in Target -> Build Phases -> Link Binary with Libraries.
I am using Xcode 13.3.1. and my project and used frameworks are both pure Objective C. I have both restarted Xcode and my Mac multiple times but they didn't help.
Does anyone have an idea what went wrong?
Framework headers are usually imported with angular brackets "<>". If you use quotes the compiler would search in the User header search paths in which case you would need to add the relevant path to User header search paths. Also make sure to make the header public if you use angled brackets.

Xcode refuses to let me import Swift files to Objective-C files ('projectname-swift.h' not found)

I downloaded this Xcode project and I want to use my Swift files in the Objective-C files but the 'OpenShop-Swift.h' file not found error refuses to go away.
I have tried what seems like every solution on Stack Overflow, including from here and here. Most other solutions were duplicates of the common:
In build settings, set defines module to yes and product module name for the target to your project name and make sure objective-c generated interface header name is correct.
This top solution seemed promising but I am having trouble understanding what he was saying.
If you decide to give it a whirl, just know that the project lacks a working backend and won't compile properly if you get past the file not found error. But, if you add to one of the .m files you should be able to get the error before the project finishes compiling.
Technically, this is not a duplicate since all the other solutions have failed.
I have found the solution thanks to #skladek. I created a swift file and allowed Xcode to create a bridging header file for me when it asked, and the error went away.
I thought the bridging header file (OpenShop-Bridging-Header.h) was to allow the importation of Obj-C code to Swift files and not vice-versa. Thus far everything I have read on the internet has corroborated this, so it's not clear to me why this solution works. Thanks to #skladek once again.

Xcode 7.3 bridging header can't see other headers

I'm creating app in Xcode 7.3 . Using libraries with Cocoapods. In one moment Xcode started not to see headers in my bridging-header. I can suggest it could be because adding new frameworks with pods (e.g. Alamofire)
It is the second time I got this issue. Last time i've just got previous working build and did the same things and it worked. But now that build also does't work.
I can get two types of error:
this if i try to import headers
file not found
and
segmentation fault:11
with this code, if I commend them out
Make sure you have correctly set the path of your BridgingHeader file in Build Settings.
Make sure you have create header file properly and set Objective-C Bridging Header path in build setting properly.

Why do I keep getting this error for my bridging Header in Xcode 7: Bridging Header does not exsist?

I updated my Xcode to version 7 and now I get this error saying the bridging header doesnt exist. It tells me that its supposed to be in the /users/desktop/apps/projectname/projectname-bridging-header.h. I checked in the file and its there but xcode still gives me an error. Has anyone had this problem before and know how to fix it. Thanks!
Make a new bridging file with a different name and link to that.
Try cleaning your build folder (Product menu, hold down option to reveal it).
I experienced issues with cocoapods 'useframeworks!' and the build folder was being used, so even after removing it and using an objc version of the library, no matter what I did the bridging header was broken.
I got it to work there was a problem in the Framework Search Paths. I had to add the destination for one of my ad networks.

Import of framework in swift bridging header not recognised upon archive

I import the Facebook AsyncDisplayKit framework into my app using the swift bridging header, like so:
#import <AsyncDisplayKit/AsyncDisplayKit.h>
It's always worked fine for building and running my app, but when I go to archive, it gives me an error:
import 'file not found'
Why might this not be recognized, upon archiving?
I always meet this kind of problem. I think you can try to check your file&folder hierarchy.
Such as you have a root folder named Project, as is often the case, there is another Project in your previous Project, the root folder.
And Checking the Objective-C Bridging Header in the Build Setting. Sometime error can occurred for Project/Project/Bridging-Header.h. And the error can be corrected by changing the definition as Project/Bridging-Header.h.
If the location of Bridging-Header.h is not matching with the definition in the Build Setting, the error like import file not found will occur.
I just tell your my solution for Bridging issue I already met, I hope it can help you.

Resources