用现有代码创建一个XCode项目 [英] creating an XCode project with existing code

查看:235
本文介绍了用现有代码创建一个XCode项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Linux应用程序移植到Mac.我有不同的文件,这些文件的源代码可以使用标准的Makefile进行编译和链接.

我要将该代码移植到Mac并继续用C编写代码(对不起,没有obj-c).有没有办法在XCode上创建项目,添加现有代码,以便我可以使用XCode和IDE,编译和调试代码以及​​生成Mac Makefile?

感谢您的帮助

解决方案

新项目->其他->外部构建系统

(在新项目中)

展开目标"

选择模板创建的目标

按回车

修改目标设置:

  • 默认情况下,它使用/usr/bin/make进行调用.如果要使用其他构建系统,则需要进行更多配置.
  • 对于Makefile,您需要将构建设置窗口的"Directory"字段设置为包含要构建的适当Makefile的目录.

请注意,使用Makefile时,您将失去一些集成.

您可以通过将源添加到项目(拖放)中,而不将它们与目标相关联来重新获得其中的一部分.

为了改善导航和代码完成,您可能想要创建第二个(虚拟)目标(例如静态库),以便ide解析您的程序.然后,您将源添加到虚拟静态库中,并将makefile设置为静态库的依赖项"(这样就可以构建它,因此它首先被构建).

I'm in the process of porting a Linux application to Mac. I have different files with the source code that can get compiled and linked using the standard Makefile.

I'm going to be porting that code to Mac and continue writing code in C (sorry, no obj-c). Is there a way to create a project on XCode, add the existing code so I can use XCode and the IDE, compile and debug the code and generate Mac Makefiles?

Thanks for the help

解决方案

New Project -> Other -> External Build System

(in new project)

Expand "Targets"

select the target the template created

press return

edit the target settings:

  • by default, it uses /usr/bin/make for invocation. if you want to use some other build system, then you'll have more to configure.
  • for a Makefile, you will need to set the 'Directory' field of the build settings window to the directory which contains the appropriate makefile to build.

note that you'll lose some integration when using a makefile.

you can regain some of that by adding the sources to the project (drag and drop), and not associating them with a target.

to improve navigation and code completion, you may want to create a second (dummy) target (such as a static library) so the ide parses your programs. you would then add the sources to the dummy static library, and set the makefile as a 'dependency' of the static library (so it gets built, and so it gets built first).

这篇关于用现有代码创建一个XCode项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆