简单的问题。是否有任何工具可以从命令行生成 Xcode 项目?我们使用 SCons 来构建我们的跨平台应用程序,但这不支持内部 Xcode 项目生成。我们希望避免手动创建项目,因为这将涉及维护多个文件列表。
7 回答
您可以使用 premake ( http://industriousone.com/premake ) 来生成 Xcode 项目。它还可以生成 Visual Studio 项目。
为了解决这个问题的任何人的利益,我实际上只是将SCons 的 Xcode 项目文件生成器推到了 Bitbucket。
Qt 工具链中的 qmake 生成 Xcode 项目。您至少可以在此处下载并查看其源代码(LGPL)。
我认为您的问题应该是“有没有办法从 SCons 生成 XCode 项目?”。我想,通过您的询问和阅读其他人,答案是否定的。
SCons 的人应该更了解它。我想如果你贡献一个 SCons Xcode 项目生成器,他们会很高兴的。
同时,您可以选择切换到 CMake 或手动创建您的 XCode 项目,如果有一个良好的源代码树组织,这可能是最好的实用解决方案。
您可以使用名为waf的基于 python 的构建系统生成 XCode 项目。您需要下载并安装带有 xcode6 扩展名的 waf:
$ curl -o waf-1.9.7.tar.bz2 https://waf.io/waf-1.9.7.tar.bz2
$ tar xjvf waf-1.9.7.tar.bz2
$ cd waf-1.9.7
$ ./waf-light --tools=xcode6
这将创建一个waf
可以构建您的项目的可执行文件。您需要配置如何在一个名为wscript
该文件的文件中生成您的 XCode 项目,该文件应位于您的项目文件夹中。该wscript
文件使用 Python 语法。这是一个如何配置项目的示例:
def configure(conf):
# Use environment variables to set default project configuration
# settings
conf.env.FRAMEWORK_VERSION = '1.0'
conf.env.ARCHS = 'x86_64'
# This must be called at the end of configure()
conf.load('xcode6')
# This will build a XCode project with one target with type 'framework'
def build(bld):
bld.load('xcode6')
bld.framework(
includes='include',
# Specify source files.
# This will become the groups (folders) inside XCode.
# Pass a dictionary to group by name. Use a list to add everything in one
source_files={
'MyLibSource': bld.path.ant_glob('src/MyLib/*.cpp|*.m|*.mm'),
'Include': bld.path.ant_glob(incl=['include/MyLib/*.h', 'include'], dir=True)
},
# export_headers will put the files in the
# 'Header Build Phase' in Xcode - i.e tell XCode to ship them with your .framework
export_headers=bld.path.ant_glob(incl=['include/MyLib/*.h', 'include/MyLib/SupportLib'], dir=True),
target='MyLib',
install='~/Library/Frameworks'
)
您可以使用许多设置来为您的项目配置它。
然后实际生成XCode项目,cd
进入你的项目文件夹wscript
并运行你的waf
可执行文件,如
$ ./waf configure xcode6
您可以使用 Automator 为您生成它们。
我检查并没有预建操作。因此,您必须使用 Automator 记录您的操作才能执行此操作。