creating an XCode project with existing code

两盒软妹~` 提交于 2019-11-28 17:51:21

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

The Apple Developer docs have a section on porting makefile based projects into XCode.

"Porting UNIX/Linux Applications to OS X"

This subsection is most relevant: "Building makefile projects with XCode"

https://developer.apple.com/library/content/documentation/Porting/Conceptual/PortingUnix/preparing/preparing.html#//apple_ref/doc/uid/TP40002849-BBCJABGC

You can build using your existing makefiles and create a wrapper project with a custom target with a 'Run Script' build phase that just calls down to your makefile. This means that you'll also be able to use the debugger, but you probably won't get the full benefit of the editor with autocompletion etc.

To import C code into Xcode:

  1. start xcode
  2. new project
  3. pick something like Standard Tool. Should read c command line tool.
  4. drag you file or files onto main project window. This is the first window that comes up when you create a new project. My project name is xaBitHoist. I dropped the files on xaBitHoist > src.

just build. Seems to default to main.c

to change start program or add argues Project > New Project Executable.

the online help for xcode is good.

Good luck.

Robert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!