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

문제

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.

도움이 되었습니까?

해결책

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".

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top