How do I create a project in Xcode that allows me to write in Objective-C++, and have a command-line interface?

StackOverflow https://stackoverflow.com/questions/21121648

Question

I'm working with a group of friends on a project, and we're doing it in Objective-C++, which I understand is just Objective-C with the ability to use C++ as well.

I'm curious how I'd go about creating a project like one of my friends has setup. They have a main.mm that runs everything important and starts the program up seemingly, where I'm using to the AppDelegate.m serving that purpose.

How do I get a project where it's just a .mm file that serves as the focal point, but still has all the Foundation properties like NSDate and whatnot? I don't want a UI, I just want command line input/output.

Was it helpful?

Solution

In Xcode, create a new project from the "OS X -> Command Line Tool" template and choose "Type: Foundation". Then rename "main.m" to "main.mm".

OTHER TIPS

In Xcode File > New Project then select Application under OS X. Choose Command Line Tool and press next. Put in a name and make sure Type is set to Foundation.

Then you'll need to rename main.m to main.mm and link against the c++ std library. This answer describes how to add the std lib to the project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top