简体   繁体   English

如何在Xcode中创建一个项目,允许我用Objective-C ++编写,并有一个命令行界面?

[英]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.

相关问题 如何创建一个UIButton来执行2个IBAction iOS-Objective-C - How can I create one UIButton that allows me to perform 2 IBAction iOS - Objective-C Xcode 将 Objective-C、Objective-C++ 项目导入 Swift 项目 - Xcode Import Objective-C, Objective-C++ project into Swift Project XCode:使用命令行工具,如何从文件夹创建git并将其导入项目中 - XCode : Using the command line tools, how do I create a git from a folder and import that on a project 使用Objective-C ++和Interface Builder遇到麻烦 - Trouble with Objective-C++ and Interface Builder iOS命令行构建:如何从命令行创建xcode存档? - iOS command-line build: How to create xcode archive from command line? 相机视图未出现在swift / objective-c ++(opencv)项目中-iOS 10.3 Xcode 8 - camera view does not appear in a swift/objective-c++ (opencv) project - ios 10.3 xcode 8 Objective-C 如何解析给定字符串中的类似命令行的参数? - Objective-C how to parse command-line like arguments from a given string? 为什么我在Xcode命令行应用程序中没有收到来自URL请求的响应 - Why do I get no response from a URL Request in an Xcode Command-Line Application 如何使用目标c匹配两个随机数,然后在xcode界面构建器中打印匹配项 - How do I match two random numbers, then print match in xcode interface builder, using objective c 如何在Objective-C项目中的Xcode中编译+链接C ++代码? - How do I compile + link C++ code in Xcode in an Objective-C project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM