[英]Import Swift code to Objective-C file
I have created a Swift project and imported Objective-C files. 我创建了一个Swift项目并导入了Objective-C文件。 During import Xcode asked me to create a bridging header and created a header.
在导入过程中, Xcode要求我创建一个桥接标题并创建一个标题。
Now in the Objective-C files of the same project I want to use Swift class methods. 现在在同一项目的Objective-C文件中我想使用Swift类方法。 I googled about importing Swift code in an Objective-C file.
我搜索了在Objective-C文件中导入Swift代码。 I found that we have to import
ProjectName-Swift.h
in the Objective-C file. 我发现我们必须在Objective-C文件中导入
ProjectName-Swift.h
。 My questions are as follows: 我的问题如下:
This seems really messed up, but the ProjectName-Swift.h
file isn't visible. 这似乎搞砸了,但
ProjectName-Swift.h
文件不可见。 You just have to #import ProjectName-Swift.h
in your Obj-C classes, and it'll work. 你只需要在你的Obj-C类中
#import ProjectName-Swift.h
,它就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.