I have written a library in Swift and I wasn't able to import it to my current project, written in Objective-C.
Are there any ways to import it?
#import "SCLAlertView.swift" - 'SCLAlertView.swift' file not found
You need to import ProductName-Swift.h
. Note that it's the product name - the other answers make the mistake of using the class name.
This single file is an autogenerated header that defines Objective-C interfaces for all Swift classes in your project that are either annotated with @objc
or inherit from NSObject
.
Considerations:
If your product name contains spaces, replace them with underscores (e.g. My Project
becomes My_Project-Swift.h
)
If your target is a framework, you need to import <ProductName/ProductName-Swift.h>
Make sure your Swift file is member of the target