[英]How do I create a project in Xcode that allows me to write in Objective-C++, and have a command-line interface?
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. 我和一群朋友在一个项目上合作,我们在Objective-C ++中做,我理解的只是Objective-C,能够使用C ++。
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. 他们有一个main.mm,它运行所有重要的东西,并且似乎启动了程序,我正在使用AppDelegate.m
服务AppDelegate.m
目的。
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? 我如何得到一个项目,它只是一个.mm文件作为焦点,但仍然具有所有的基础属性,如NSDate
和诸如此类的东西? I don't want a UI, I just want command line input/output. 我不想要UI,我只想要命令行输入/输出。
In Xcode, create a new project from the "OS X -> Command Line Tool" template and choose "Type: Foundation". 在Xcode中,从“OS X - >命令行工具”模板创建一个新项目,然后选择“类型:基础”。 Then rename "main.m" to "main.mm". 然后将“main.m”重命名为“main.mm”。
In Xcode File > New Project then select Application under OS X. Choose Command Line Tool and press next. 在Xcode File> New Project中,选择OS X下的Application。选择Command Line Tool,然后按next。 Put in a name and make sure Type is set to Foundation. 输入名称并确保将Type设置为Foundation。
Then you'll need to rename main.m to main.mm and link against the c++ std library. 然后你需要将main.m重命名为main.mm并链接到c ++ std库。 This answer describes how to add the std lib to the project. 这个答案描述了如何将std lib添加到项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.