如何在Xcode Objective-C项目中导入/使用swift静态库/框架到.mm类扩展中

时间:2022-09-07 07:41:12

Need to import swift framework classes in c++/.mm class files

需要在c++/中导入swift框架类。mm类文件

Following are the statements declaration in TargetsDefinedViewController.h header file

下面是TargetsDefinedViewController中的语句声明。h头文件

    #import<MaterialShowcase/MaterialShowcase.h>

 @interface TargetsDefinedViewController ()<MaterialShowcaseDelegate>
 @end

MaterialShowcase is swift project. To use it in Objective-C we have to build framework and then integrate it in Project. TargetsDefinedViewController implementation file extension is .mm

MaterialShowcase是迅速的项目。要在Objective-C中使用它,我们需要构建框架,然后在项目中集成它。TargetsDefinedViewController实现文件扩展是.mm。

error: cannot find protocol declaration for 'MaterialShowcaseDelegate'

错误:无法找到“MaterialShowcaseDelegate”的协议声明

1 个解决方案

#1


0  

You can not import swift class file directly in to Objective-C .m file because MaterialShowcase is .swift file and you did first line #import "<"MaterialShowcase/MaterialShowcase.h>". so it's wrong.

不能直接将swift类文件导入到Objective-C .m文件中,因为MaterialShowcase是.swift文件,第一行#import“<”MaterialShowcase.h>。这是错误的。

You can import #import “APPNAme-Swift.h", Used in .m file of TargetsDefinedViewController and it's working, Try it.

您可以导入#import“APPNAme-Swift”。在TargetsDefinedViewController的.m文件中使用,它在工作,尝试一下。

#1


0  

You can not import swift class file directly in to Objective-C .m file because MaterialShowcase is .swift file and you did first line #import "<"MaterialShowcase/MaterialShowcase.h>". so it's wrong.

不能直接将swift类文件导入到Objective-C .m文件中,因为MaterialShowcase是.swift文件,第一行#import“<”MaterialShowcase.h>。这是错误的。

You can import #import “APPNAme-Swift.h", Used in .m file of TargetsDefinedViewController and it's working, Try it.

您可以导入#import“APPNAme-Swift”。在TargetsDefinedViewController的.m文件中使用,它在工作,尝试一下。