如何从 Xcode 项目生成 Makefile?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/95211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:24:13  来源:igfitidea点击:

How can you generate a Makefile from an Xcode project?

objective-cxcodemacosmakefile

提问by Tim

I want to generate a Makefile from an existing Xcode project on the Mac. Specifically, an existing iPhone, Objective-C program on the Mac.

我想从 Mac 上的现有 Xcode 项目生成 Makefile。具体来说,一个现有的 iPhone,Mac 上的 Objective-C 程序。

I found PBToMake, but it looks like it is for Xcode 2.1 and when I tried using it, it did not work for an Xcode 3.1 project.

我找到了PBToMake,但它看起来像 Xcode 2.1,当我尝试使用它时,它不适用于 Xcode 3.1 项目。

回答by rage

GNUStep provides 'pbxbuild' to convert a .xcodeproj file into a GNUMakefile.

GNUStep 提供“ pbxbuild”来将 .xcodeproj 文件转换为GNUMakefile

UPDATE:pbxbuild is now deprecated

更新:pbxbuild 现已弃用

回答by Urkle

It's not an automated way of generating a Makefile, but I found it at least gets a list of source files that are built for a target.

这不是生成 Makefile 的自动方式,但我发现它至少可以获得为目标构建的源文件列表。

I'm using Xcode 4.0.2 in this case..

在这种情况下,我使用的是 Xcode 4.0.2。

  • select the project top node
  • select the target in the target list.
  • Choose "Build Phases"
  • Open the "Compile Sources"
  • Select one of the source files
  • PRess Command-A to select all
  • Press Command-C to copy
  • Paste in your favorite text editor and Regex away to restructure.
  • 选择项目顶部节点
  • 在目标列表中选择目标。
  • 选择“构建阶段”
  • 打开“编译源”
  • 选择源文件之一
  • 按 Command-A 选择全部
  • 按 Command-C 复制
  • 粘贴您最喜欢的文本编辑器和 Regex 以进行重组。

The pasted output is FULL pathnames to each source file.

粘贴的输出是每个源文件的完整路径名。

回答by Chris Hanson

To build your project outside of the IDE, check out the xcodebuildcommand-line tool.

要在 IDE 之外构建项目,请查看xcodebuild命令行工具。

回答by unclerojelio

You could try mfg. It is template based and I think (I haven't played with it too much) you could get it to generate a suitable makefile.

你可以试试mfg。它是基于模板的,我认为(我没有玩过太多)你可以用它来生成一个合适的 makefile。