"Reference to 'Component' is ambiguous" - Obj-C and C++


I'm trying to build a project with a .mm file which houses some Objective-C code mixed with Juce C++.

I'm getting lots of errors like "Reference to 'Component' is ambiguous". These all seem to be coming from dRowAudio library files. 

This is the first time I'm trying to build since introducing Objective-C into the project. Can anyone direct me to where the conflict might be coming from?

EDIT: Not sure if this is to do with dRowAudio or not.. if I remove the .mm file from the project I get lots of Objective-C related errors like:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:373:19: Unknown type name 'NSString'; did you mean 'String'?

Any clues? 


I don't think this is due to any of my code, it's always used Obj-C internally. I think you must be including your Obj-C code incorrectly.

Take a look at how I include the iOS code in the module or how Jules includes the native stuff on OSX/iOS. Essentially, you can't include any Obj-C code in your main app. When declaring classes that use Obj-C, use void* pointers in-place of any Obj-C classes, you can always static cast them on the definition side (in the mm file).

Make sure you include any Obj-C headers first, before any JUCE code and outside of any namespaces.

If you follow these rules you should be ok.


thanks Dave 

I've been trying to wrap my head around this post to help my understanding: http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++

I've been looking through Juce and dRowAudio classes that use Objective-C, and things are beginning to make sense.

In your iOS related classes I see them starting with:


} // namespace drow

which seems strange as its starting with a closing curly brace. Can you explain whats going on there? 

Also, apologies if I was making it sound like there were issues withe the dRowAudio code, I quickly realised it was due to the way I'm using Objective-C in my .mm file. 


Objc-C has no concept of namespaces so you need to jump out of any before including Obc-C code.

As I'm inside the drow namespace at that point in the file I add the closing brace (we're now at global scope), write any Obj-C code and then re-enter the drow namespace before the C++ code.

This ensures the C++ class interface is in the correct namespace whilst the inner Obc-C class is outside it.

It's a real pain to get all this to work properly but hopefully once you see what's going on it should make sense (took me a few goes). Good luck!


Thanks, I'm definitely a lot closer - followed the pattern of the dRowAudio native modules. 

However I'm stuck on compile time errors "Undefined symbols for architecture ..." for all the methods defined in my .mm file.

I've tried various combinations of include/import etc and searched the web, I think its to do with it not finding or including the .mm file, however I can't include it directly as then you get a barrage of Obj-C related errors... 

any pointers greatly appreciated.