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
Go to Build Settings of your project, find Objective-C Bridging Header row and remove its contents.
Go to targets file->Build Settings->Swift Compiler - General, delete the contents in the same line as Objective-C Bridging Header
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
Deleting the lines containing SWIFT_OBJC_BRIDGING_HEADER in MyProjectName.xcodeproj/project.pbxproj did the trick for me.
I could not find the Build Settings in my Xcode project as other answers mentioned (maybe because my project is for MacOS, not iOS?).
Related
To setup a SideMenu in my iOS project, I'm Using SWRevealViewController without pods and this create a bridging header file
SWRevealViewController.h
SWRevealViewController.m
MyProjectName-Bridging-Header.h
Now I want to remove these three files and add my custom SideMenu, but this cause a big problem
I trying some solutions which I found in stackoverflow and another websites like 1. go to Target > Build Settings > Swift Compiler - General > Objective-c Bridging Header and remove its value. but this case a lot of errors. 2. retrive just this file 'MyProjectName-Bridging-Header.h' but this again cause a lot of errors.
the project does not work successfully without the three file. although i don't use these three file in any part of my project.
when I delete the three files + clean the Objective-c Bridging Header I get this error.
Edit: I note that after I do the deletion step the 'import UIKit' disappears from most files in the project.
I solve the problem by the following steps
1- Delete these two files which caused in creating bridge file
SWRevealViewController.h
SWRevealViewController.m
2- remove #import "SWRevealViewController.h" from Bridging file and add #import <UIKit/UIKit.h>
and this solve the problem for me.
Are these only 3 OBJ-C files you use in your project?
Here are the steps you should follow:
1. Delete all the {{obj-c}}.h,.m,.xib along with AppName-Bridging-Header.h
Then go to Target > Build Settings > Swift Compiler - General > Objective-c Bridging Header and remove its value, as you saw in multiple stack overflow post.
Clean build and run the project to solve the errors
I have updated my project from xcode 7.3 to xcode 8 that project is mixture of cordova and native .I am getting error of Bridge Header not found .. I have tried many solutions even I have made a new bridge header many times but getting same error always
error
:0: error: failed to import bridging header
A possible cause for this would be that the Bridging Header is not properly connected to your project.
Solution 1:
I strongly recommend deleting your current Bridging Header and then go to File -> New File -> Objective-C Source File(.m). When you create the file it will ask you if it should create a new Bridging Header. Click Create. After that, put your #import statements in the new header, and delete the .m file, which is unnecessary. Then, you're good to go.
Solution 2:
To check if your Bridging Header is connected properly to your project, go to Project -> Build Settings -> Swift Compiler - General. There, you will have the option Objective-C Bridging Header.
I have a project with mixed Swift and Objective-C in Xcode 8 that uses the generated "ModuleName-Swift.h" header file to import swift into Objective-c classes, but the preprocessor is not able to find the generated header file and throws an error on the import.
"Lexical or Preprocessor issue : 'ModuleName-Swift.h file not found'"
The project compiles just fine, but the preprocessor throws errors for the header not being found and for any Swift classes called inside the class there is no syntax highlighting or code completion. It's a struggle working with Swift classes in Objective-c that are unrecognized by Xcode 8, but yet compile just fine.
Any ideas on how to appease the preprocessor in Xcode 8?
I had exactly the same issue. Found the solution after adding a new file aiming to only one target (by mistake) and noticing that it had no problem reading the Swift classes. So, if you have multiple targets, and since the migration you didn't have the need to build and run them, suggest you to do that.
Have this problem when we have multiple targets. If the Objective-c Generated Interface Header Name variable in Swift compiler of newly created targets is different than the original target's value. Change it to the same value with original target. See the following:
change, newtargetname-Swift.h to originaltargetname-Swift.h for new target
To fix this issue Xcode 9.2, After long research i came to known my "Objective-c Generated Interface Header Name" is named after Product Name "productname-Swift.h"
You need to add this in your build settings.
There might be an issue while migrating to Xcode 8, where you will have unspecified in the build setting Swift header file.
This if from killerz
Go to
Build Settings->Objective-C Generated Interface Header Name
and set the value to YourModule-Swift.h (this is usually already set, this is the filename you need to import on .m file #import "YourModule-Swift.h"
If
your product's normal targets run fine, but
you get the error when running your test targets…
note that each target uses (and should use) a different filename for the Objective-C Generated Interface Header Name.
This means you cannot import the generated header file in your Objective-C .h files, because they won't be found in the test target:
Instead, you should move these #import statements into your Objective-C .m (implementation files), where they'll build successfully.
If you need to refer to Swift classes in a .h file, use the #class directive, e.g.:
//
// ViewController.h
// import-example
//
#import <UIKit/UIKit.h>
#class SomeSwiftClass;
#interface ViewController : UIViewController
- (NSString *) titleFromGenerator:(SomeSwiftClass *)generator;
#end
I'm doing an iPad app using swift. But I have some classes which are already developed in objective-c. Now the problem is even after I'm importing objective-c class in bridging header it is showing error in swift file where I need to use objective c variables. I'm showing the project structure and bridging header's content along with the error below.
the folder structure is like
and the bridging header's content is
#import "SObjectData.h"
#import "SObjectDataSpec.h"
#import "SObjectData+internal.h"
the following is CallSObjectData.swift where i'm actually getting issue.there might be a small mistake.
If the I set
swift compiler - code generation
as follows
I'm getting the following issue.
If the I set
swift compiler - code generation
as follows
It is giving me the file doesn't exist error
Please help me finding the bug. thanks in advance.
Make sure click on project file in left pane file explorer. Target -> Build Settings -> under field Swift Compiler - Code Generation make sure your bridging file path is correct.
I cannot seem to get the SimpleAuth CocoaPod to work in a my swift project. I have:
created a bridging header file
with #import <SimpleAuth/SimpleAuth.h> and
edited the swift compiler - code generation section in build settings
Am I supposed to manually fix the 15 Swift Compiler Errors (mainly 'unknown type name NSString' and 'Expected a type') or is this a sign I am doing something completely wrong?
Thanks
#import <Foundation/Foundation.h>
in your header file
I just went back to several projects with bridging headers to import obj C frameworks and they all appear to have the same issues you have. It looks like a line by line fix for those.