iOS Swift project, already imported Objective-C file and I want to import a swift class into this Objective-C
我有一个Swift项目,我成功地在这个Swift项目中添加了一些客观的C类文件,比如objectiveClass.h,并且能够使用桥接头在项目中使用它。现在在objectiveClass.h类中,我要导入swift项目的swift类。我该怎么做?
我搜索了很多,但还没有找到任何答案。大多数问题都是关于如何将Objective-C类导入Swift项目,或者将Swift类导入Objective-C项目。但我的情况不同
很简单。只需在swift类前申报
1 2 3 | @objc public class YourSwiftClass : NSObject { } |
现在在目标C类中使用
直接从AppleDoc。
When you import Swift code into Objective-C, you rely on an Xcode-generated header file to expose those files to Objective-C. This automatically generated file is an Objective-C header that declares the Swift interfaces in your target. It can be thought of as an umbrella header for your Swift code. The name of this header is your product module name followed by adding"-Swift.h".
大多数人不知道的是,