Bridging-Header Does not exists
In your build settings, give a complete address to your bridging header instead of testLogin/testLogin-Bridging-Header.h
myProjectName-Swift.h not found after clean build
You must not use #import "ProjectName-Swift.h"
in the header files.
If you need Swift classes or protocols in the Obj-C code, you may forward declare them in the related Obj-C header. Here's more information about that:
When declarations in an Objective-C header file refer to a Swift class or protocol that comes from the same target, importing the generated header creates a cyclical reference. To avoid this, use a forward declaration of the Swift class or protocol to reference it in an Objective-C interface.
// MyObjcClass.h
@class MySwiftClass;
@protocol MySwiftProtocol;
@interface MyObjcClass : NSObject
- (MySwiftClass *)returnSwiftClassInstance;
- (id <MySwiftProtocol>)returnInstanceAdoptingSwiftProtocol;
// ...
@end
Also, please note, you may have issues with importing Swift Enums and Protocols and Classes into ObjC, so you may need to explicitly define items which you want to be available to ObjC code with @objc
keyword.
And you won't be able to use Swift structs in Obj-C.
Swift Bridging-Header.h file not allowing me to instantiate objective-c classes in .swift files
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.
How do I create an Objective-C bridging header?
You have to create a new objective c class:
then
then you name it and specify as objective-c class at language
then you select your directory and hit create. At this point xcode is going to ask you whether or not you want to create bridging header. Yep do it.
And at the end it should look more or less like this at your project.
hope that helps you.
Related Topics
Get an Array of Property Values from an Object Array
How to Create a Uilabel with Strikethrough Text
Why Xcode 7 Shows *.Tbd Instead of *.Dylib
iOS 11 Customise Search Bar in Navigation Bar
Perform Segue Programmatically and Pass Parameters to the Destination View
How to Check If a File Exists in the Documents Directory in Swift
How to Read Data Structure from .Plist File into Nsarray
What's the Difference Between "Architectures" and "Valid Architectures" in Xcode Build Settings
iOS Blocks and Strong/Weak References to Self
Posting Video on Instagram Using Hooks
Xcode Myprojectname-Bridging-Header.H Does Not Exist
Xcode 10 (iOS 12) Does Not Contain Libstdc++6.0.9
How to Create P12 Certificate for iOS Distribution
Why Maskstobounds = Yes Prevents Calayer Shadow