Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 684
CodeChanger Avatar asked Oct 17 '25 08:10

CodeChanger


1 Answers

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.

like image 111
CodeChanger Avatar answered Oct 19 '25 00:10

CodeChanger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!