如何在目标c中使用swift文件

时间:2023-01-15 18:38:38

I want to use my Swift files in Objective-C code. I found different link that say how to do it.

我想在Objective-C代码中使用我的Swift文件。我找到了不同的链接,说明了如何做到这一点。

My project name is: Test-Project.

我的项目名称是:Test-Project。

I imported #import "Test-Project-Swift.h" to my .m file to use needed classed in objective c source code.

我将#import“Test-Project-Swift.h”导入我的.m文件,以便在目标c源代码中使用所需的类别。

I watched this video and there is no problem, but I have 'Test-Project-Swift.h' file not found.

我看过这个视频并没有问题,但我找不到'Test-Project-Swift.h'文件。

1 个解决方案

#1


0  

As we recognized: It looks like the problem with "-" we need to change it to "_" - "Test_Project-Swift.h". I've checked Objective-C Generated Interface Header Name in the project settings.

我们认识到:看起来像“ - ”的问题我们需要将它改为“_” - “Test_Project-Swift.h”。我在项目设置中检查了Objective-C Generated Interface Header Name。

#1


0  

As we recognized: It looks like the problem with "-" we need to change it to "_" - "Test_Project-Swift.h". I've checked Objective-C Generated Interface Header Name in the project settings.

我们认识到:看起来像“ - ”的问题我们需要将它改为“_” - “Test_Project-Swift.h”。我在项目设置中检查了Objective-C Generated Interface Header Name。