Getting error while using ObjC class include in .cpp file (unqualified-id @class)

4.1k Views Asked by At

I am working with Wikitude SDK and while adding some file supported in Wikitude example folder its showing me Foundation file error like below.

In file included from /Volumes/DATA/Dhanesh/Projects/experiments/AR/ARWikiDemo/ARWikiDemo/WikiSDK/Controller/Examples/Categories/PluginsAPI/CustomCamera/YUVFrameInputPlugin.cpp:11: In file included from /Volumes/DATA/Dhanesh/Projects/experiments/AR/ARWikiDemo/ARWikiDemo/WikiSDK/Controller/Examples/Categories/PluginsAPI/CustomCamera/WTDeviceCamera.h:9: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:492:1: error: expected unqualified-id @class NSString, Protocol;

Not getting whats wrong here but it says that

All NSString, NSObject, NSLog are unqualified-id @class

I have set all related Linker flag and Header & Library search paths for that but still getting the above error.

Can anyone guide me on this whats going wrong here?

Error Screenshot for reference:

enter image description here

Thanks in Advance!

1

There are 1 best solutions below

0
On BEST ANSWER

For the Above issue, I struggle a lot, and finally, I am concluding this with the below solution.

  • To use .cpp file in ObjC we required to convert that .cpp extension to .mm for ObjC++ compiler only. (thanks Mats for your comment it's helped me a lot.)
  • Compile the source as ObjectiveC++ in the Build setting.

Ref Link 1: Objective-C++ and .cpp files in Xcode

Ref Link 2: Adding C++ code to an iOS project

Hope this will help others who are facing the same issue related to it.CPP ext.

Thanks.