I am trying to mix Swift and C++, and my C++ class has errors "expected ';' after top level declarator" and "unknown type name 'class'; did you mean 'Class'?"

I am attempting to create a C++ file called Fish and to display the fish's num in my SwiftUI app. However, I am encountering the errors "expected ';' after top level declarator" and "unknown type name 'class'; did you mean 'Class'?". It appears that Xcode thinks that the file is a C file. How should I address these errors?

Did you set the C++ and Objective-C Interoperability build setting to C++ / Objective-C++ (objcxx)? I created a tiny test project to exercise this tech and I got exactly this error because that build setting defaults to C / Objective-C (objc).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Set "Supported Languages" to exactly objective-c++ in "Build Settings", then everything works as expected. @jinyangz

The reply from aliwang is correct, and solved this problem for me right away. My Build Settings supported language was set to 'objective-c / objective-c++' and the framework project simply would not build. How on earth in 2024 Apple has not been able to make Xcode interop C/C++/Obj-C/Swift out of the box is beyond me. Since all of these languages are a superset of C. You know many of us want this, you guys use it yourself more and more. Just work it into Xcode and be done with it already.

I am trying to mix Swift and C++, and my C++ class has errors "expected ';' after top level declarator" and "unknown type name 'class'; did you mean 'Class'?"
 
 
Q