Building Qt Xcode Projects From the Command Line

2019-01-12 18:24发布

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

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

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

4条回答
迷人小祖宗
2楼-- · 2019-01-12 18:40
$ man xcodebuild

So a typical command might be something like:

$ xcodebuild -project myProject.xcodeproj -alltargets
查看更多
smile是对你的礼貌
3楼-- · 2019-01-12 18:41

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}

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.

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?

查看更多
何必那么认真
4楼-- · 2019-01-12 18:55

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.

To compile your projects from Terminal.app, just set an environment variable of QMAKESPEC to 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.

查看更多
唯我独甜
5楼-- · 2019-01-12 19:00

Try the following way. It has to work.

xcodebuild -project myProject.xcodeproj -alltargets

I have used this method in most of my projects.

查看更多
登录 后发表回答