I am getting this error while running this project.
failed to import bridging header '/Users/OdysseyApps/Desktop/ashraf/onedrive-sample-sync-ios-master/OneAPI Sync/OneAPI Sync-Bridging-Header.h'
I think the problem is the space in project name OneAPI Sync.
please give me some suggestion.
Probably You have imported some class in bridge file.
That is not a part of your bundle.(or didn't accidentally imported .m file)
Try to find that class and remove that class import statement.
Related
I'm working on a project that contains Swift and Objective_C code, it works without any problem until i was trying to import a ".h" class in my "Bridging-Header" file:
Expected a type : in the class that i was trying to import it
Failed to import bridging header '/Users/sysadmin/Desktop/Application /Classes/UI/Application-Bridging-Header.h'
however when i have imported an other class in Bridging Header that works without problem!
There is 3 ways to import objective c file in Swift project.
#import "FileName.h"
#import <FolderName/FileName.h>
#import PackageName; like #import Alamofire;
Try importing your class like
#import "classname.h" if this fails try
#import `<classname/classname.h>`
Remember to clean and then run after you make a change.
Again if it fails check whether you have added the class to your target
I want to use my protocol method of swift class into objective-c class for it I have to import 'ProductModuleName-Swift.h' and declare its protocol in interface but it shows error: 'ProductModuleName-Swift.h' file not found.
But when I import it into test.m file then its fine but when I import it into test.h then it shows the error.
example:
test.h
#import "myProject-Swift.h"
#interface test : UIViewController<mySwiftDelegate>
or There is any way to use protocol method of swift in obj-c class
thanks in advance.
Go to Targets -> Build Settings -> Swift Compiler - Code Generation and make sure the "Objective-C Bridging Header" points to the correct place and the "Objective-C Generated Interface Header Name" is the correct file. My header name for the unit tests defaulted to Module-NameTest-swift.h I needed to remove "Test" from the title.
I'm getting this really weird error when trying to import UIKit in my swift file.
My Code is simply:
import UIKit
class Test: NSObject {
}
The error I get at 'import UIKit' is:
Unknown type name 'import'
Expected ';' after top level declarator
I have added UIKit to my Frameworks folder, the class doesn't contain any code (so therefore there shouldn't be anything wrong with it) and I tried to restart both xCode and my Mac, but the error is still there.
I appreciate any help.
Thanks.
EDIT:
Solved:
I tried to import 'Test.swift' in AppDelegate.
This problem usually happens when you try to import ".swift" file in your Objective-C code, like this: #import "HomeViewController.swift". This is wrong and you should import special, automatically generated Swift header, instead:
#import "ProductModuleName-Swift.h"
where ProductModuleName is the name of your module (or project) containing the Swift code.
Found good Trouble shooting guide - there is great Troubleshooting Tips and Reminders section!
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_87
The import stuff in swift is case sensitive. Example :
import uikit
will not work. You'll have to type it as
import UIKit
In my case, it was because somehow the selected type in the file inspector was objective-c source instead of Default - Swift Source even though i was using a .swift file.
Changing it to Default - Swift Source solved the issue for me.
I'm trying to add a Swift file to my app and get a "Failed to import bridging header" error, among others.
Bridging-Header code:
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "Menu.h"
In build settings, try setting "Embedded Content contains Swift Code" to Yes.
Also, it looks like its failing to recognize objects from UIKit, so try adding "import UIKit" atop one of your Swift files.
I accidentally deleted my library search path and framework search path from my xCode project. Now my bridging header file is not able to import chart boost header files and xCode is giving me swift compiler error while trying to build the app.
I tried to add absolute path of the framework in framework search path in build settings but nothing changed.
Can someone guide me through it?
These are are the kind of errors I am getting
MY_PROJECT/Bridging-Header.h:21:9: note: in file included from /MY_PROJECT/Bridging-Header.h:21:
import <Chartboost/Chartboost.h>
^
/MY_PROJECT/Chartboost.framework/Headers/Chartboost.h:16:42: error: function definition is not allowed here
typedef NS_ENUM(NSUInteger, CBFramework) {
^
/Users/MY_PROJECT/Bridging-Header.h:21:9: note: in file included from /Users/MY_PROJECT/Bridging-Header.h:21:
import <Chartboost/Chartboost.h>
unknown>0: error: failed to import bridging header '/Users/bewakoofmac/Desktop/Jumpy Tiles/jumpytiles/jumpytiles/Bridging-Header.h'