从命令行构建 Qt Xcode 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/377992/
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-09 02:56:56  来源:igfitidea点击:

Building Qt Xcode Projects From the Command Line

xcodemacosqtmakefile

提问by Ankur Sethi

I've been playing around with Qt for a few hours now. I found that qmake produces Xcode project files on Mac OS X instead of good ol' makefiles. I don't want to launch Xcode every time I want to build "Hello, world".

我已经玩 Qt 几个小时了。我发现 qmake 在 Mac OS X 上生成 Xcode 项目文件,而不是好的 ol'makefile。我不想每次想构建“Hello, world”时都启动 Xcode。

How do I make qmake generate regular makefiles or, if that's something that cannot be done on the Mac, how do I compile .xcodeprojfiles from the command line?

我如何让 qmake 生成常规的 makefile,或者,如果这在 Mac 上无法完成,我如何.xcodeproj从命令行编译文件?

I tried xcodebuild -project myProject -alltargets. I get a lot of output followed by Abort trap.

我试过了xcodebuild -project myProject -alltargets。我得到很多输出,然后是Abort trap.

采纳答案by user47488

The open-source Qt binary installers for OS X from Trolltech default to creating .xcodeproj files when you run qmake. I don't use XCode for editing so it is a pain to open it to compile the project.

当您运行 qmake 时,Trolltech 的 OS X 开源 Qt 二进制安装程序默认创建 .xcodeproj 文件。我不使用 XCode 进行编辑,所以打开它来编译项目很痛苦。

To compile your projects from Terminal.app, just set an environment variable of QMAKESPEC to macx-g++

要从 Terminal.app 编译您的项目,只需将 QMAKSPEC 的环境变量设置为 macx-g++

If you want to just compile a certain project from the terminal, go into that directory and run

如果您只想从终端编译某个项目,请进入该目录并运行

qmake -spec macx-g++

When you run qmake, this will create a Makefile which you can use by running make.

当您运行 qmake 时,这将创建一个 Makefile,您可以通过运行 make 来使用它。

回答by Olie

$ man xcodebuild

So a typical command might be something like:

所以一个典型的命令可能是这样的:

$ xcodebuild -project myProject.xcodeproj -alltargets

回答by Vijendra Kumar H.

Try the following way. It has to work.

试试下面的方法。它必须工作。

xcodebuild -project myProject.xcodeproj -alltargets

I have used this method in most of my projects.

我在我的大部分项目中都使用过这种方法。

回答by Mike Heinz

Looking at this part of your back trace:

查看您的回溯的这一部分:

# 2008-12-18 20:40:52.333 xcodebuild[1070:613] [MT] ASSERTION FAILURE in /SourceCache/DevToolsBase/DevToolsBase-921/pbxcore/FileTypes/PBXCFBundleWrapperFileType.m:174 # Details: path should be a non-empty string, but it's an empty string # Object: # Method: -subpathForWrapperPart:ofPath:withExtraFileProperties: # Thread: {name = (null), num = 1}

# 2008-12-18 20:40:52.333 xcodebuild[1070:613] [MT] /SourceCache/DevToolsBase/DevToolsBase-921/pbxcore/FileTypes/PBXCFBundleWrapperFileType.m 中的断言失败:路径应该是非-174 #空字符串,但它是一个空字符串 # Object: # Method: -subpathForWrapperPart:ofPath:withExtraFileProperties: # Thread: {name = (null), num = 1}

This implies that something, maybe one of your configuration variables, is blank when it needs to refer to a file. What I'm wondering is if maybe you have an extra target in your project that doesn't work, so that building with -alltargets is what's causing your problem.

这意味着某些东西(可能是您的配置变量之一)在需要引用文件时是空白的。我想知道的是,您的项目中是否有一个额外的目标不起作用,因此使用 -alltargets 进行构建是导致您出现问题的原因。

I tested xcodebuild without any arguments on one of my projects just now - it did a default build of my project without errors. What happens if you try it without arguments?

我刚刚在我的一个项目上测试了没有任何参数的 xcodebuild - 它没有错误地对我的项目进行了默认构建。如果你在没有参数的情况下尝试会发生什么?