So I am using Xcode 6.1 on my Objective-C app. My app uses the GameKit framework.
I tried to call external C++ methods from my GameViewController (which is Objective-C source.)
To make GameViewController.mm compile, I had to set the type to 'Objective-C++ Source' manually.
However, even though the source now compiles, it will fail to link with:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GLKViewController", referenced from:
_OBJC_CLASS_$_GameViewController in GameViewController.o
"_OBJC_METACLASS_$_GLKViewController", referenced from:
_OBJC_METACLASS_$_GameViewController in GameViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I can only get rid of the linker error by setting the type back to 'Objective-C Source' and removing the calls to the external C++ functions.
Why does the linker fail if my source is compiled as 'Objective-C++ Source' instead of 'Objective-C Source' type?
Note that I properly link against GameKit in the Build-phases.
OK. It turns out to be a weird one, but:
I was linking to GameKit, and not GLKit. The fix: link to GLKit as well.
Now, the strange part is that not linking GLKit causes no problems if the view controller is built as Objective-C source. It does cause problems if built as Objective-C++ source.
Strange, but true.