Unknown type name class, did you mean Class

匿名 (未验证) 提交于 2019-12-03 01:26:01

问题:

So I tried to import aurioTouch into my app and I keep getting this error saying

"unknown type name 'class' did you mean "Class"? 

My bridging header file:

#import "AudioController.h" #import "BufferManager.h" #import "FFTHelper.h" #import "DCRejectionFilter.h" 

I tried changing this to .mm for all these files but it doesn't solve my issue. Anyone have any ideas why this is happening?

回答1:

To mix C++ and Objective-C you need to use the .mm extension. If, however, your class is only C++ (and only includes C/C++ headers) then you can use the normal .cpp extension.

.mm A source file with this extension can contain C++ code in addition to Objective-C and C code. This extension should be used only if you actually refer to C++ classes or features from your Objective-C code.



回答2:

I had the same issue, and I could solve by the following answer: Import aurioTouch Library with Swift

In short, AudioController.h is not an Obj-C file because it imports C++ files (BufferManager.h, FFTHelper.h, and DCRejectionFilter.h). So you cannot bridge it to Swift just like that.

You have to create a pure Obj-C file wrapping AudioController.h.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!