Reputation: 21200
I need to add a .mm file which contains both ObjectC and C++, I am wondering how to do it using XCode 4?
Upvotes: 1
Views: 9071
Reputation: 133577
There are absolutely no issues in doing that, just add the .mm fle to the project and XCode will compile it as Objective-C++.
The only caveat is that the .h associated with that ObjC++ code must not contain any C++ specific code or every file in which that header is included must be .mm too.
This because XCode will use different compiler according to the single file, so if a .m is found it will try to compile it as plain ObjC and not ObjC++. You can force to compile it with che ObjC++ compiler but I suggest you to follow the principle described or rename other files to .mm just to avoid getting things complicated.
Upvotes: 3