我用 Swift 编写了一个库,但无法将它导入到我当前用 Objective-C 编写的项目中.
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 推荐答案您需要导入 ProductName-Swift.h.请注意,这是产品名称 - 其他答案错误地使用了类名称.
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.
这个单个文件是一个自动生成的头文件,它为您项目中的所有 Swift 类定义了 Objective-C 接口,这些类要么用 @objc 注释,要么从 NSObject 继承.
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.
注意事项:
如果您的产品名称包含空格,请将其替换为下划线(例如,My Project 变为 My_Project-Swift.h)
如果你的目标是框架,则需要导入
If your target is a framework, you need to import <ProductName/ProductName-Swift.h>
确保您的 Swift 文件是目标的成员
Make sure your Swift file is member of the target
更多推荐
如何将 Swift 代码导入到 Objective
发布评论