My IDE of choice for the Mac (at least for C++ and Objective-C development) is Xcode. I have a 64-bit Intel Mac with OS X Lion installed, and Xcode version 4.2 downloaded from the Mac App Store.
My problem is that Qt is apparently not compatible with Xcode 4 (it crashes when launching projects generated by qmake), so I'm basically asking how I can integrate Qt with Xcode. I don't have to be able to run and debug the project from Xcode, just build it.
So I thought it might be a solution to use qmake as an external build system within Xcode, the problem is that I have no idea how to set up qmake as my build system, so that I can develop my Qt applications in Xcode 4.
Please help me! :)

- 541
- 1
- 9
- 17
1 Answers
Google shows up many pages, but this Qt4 with Xcode page appeared at first glance to be a fairly definitive resource. However, it was last changed in 2006.
Please check out: http://qt-project.org/doc/qt-5/macosx.html
There is a much more recent Qt Developer Network forum post that seems to have good info in it. Specifically, this reply from August 19, 2011 gives a complete recipe.
Update 25/05/2016:
The first two links are now dead, and not archived due to robots.txt
.
However, I've updated the link to the forum post.
And here's a copy of emiguel's answer. It is now 5 years old, so I don't know how current it still is.
Hi,
To solve my problem I did the following.
First I`m going to have a subproject in Qt that mantains the graphical interface, I created this project as a C++ library, so I could include this in the main project.
The main project is a C++ project in Xcode (which is a plugin template with a lot of configurations).
Second, I ported the Qt project to Xcode using the spec macx-xcode parameter.
Third, having both projects in Xcode, I can attatch the library (in Qt) to the main project. To do this, right click in the xcode project and click in the "existing file..." option, select the xcodeproj file from the Qt project. Finally add the library to the linkage phase, this is done by dragging the lib file, wich is under the xcodeproj file, to the "Targets" section in the "Link binary with Libraries".
Fourth, import the Qt framewoks to the main project, to do that, right click in the main project, click in add a existing framework, select the Qt features used by the project (ex. QtSDK/lib/QtCore.framework)
And finally, add the header and library paths in the main project. Click in project menu->project settings, set the header search paths option with the Qt headers (ex QtSDK/include//) and the library search paths (ex QtSDK/lib//**).
That's all, now I can instantiate my own Qt widgets from the C++ project.
Note: I have to do an additional step because my target was i386 and the downloaded Qt version were 64 bit, so I downloaded the sources and compiled it for i386.
Now I have another problems about drawing inner the plugin... but I think that will be for another post.
Thanks a lot for your help
Finally, current information on building Qt in Xcode is available in Qt for OS X - which is too long to copy here, and will be maintained and updated by Qt...

- 3,670
- 2
- 31
- 45
-
Hi, thanks for your reply. Both of those links I found on Google, but I have still failed to make anything of them, could you please explain further, given you know anything that is? :) – Benjamin Oct 18 '11 at 21:08
-
Sorry they didn't help you get going. I think you might be able to get more help here if you could post info about what you tried, then, and what didn't work, e.g. include details of error messages. – Clare Macrae Oct 18 '11 at 21:28
-
I have some good news :) I have been able to add qmake as my external build system. I created 3 targets: Level Editor (main target using 'make' as the build system, generated by Xcode), qmake, and qmake -project. Pretty much as described in the wiki link you provided. It just took me a little while to realize how to do it in Xcode 4 :D. When I build the project, first qmake -project, then qmake, and then Level Editor, it'll spit out an .app file, just as I want it to :). But now here's the next question: How do I add the Qt framework to Xcode 4? – Benjamin Oct 18 '11 at 22:43
-
But you don't know how to add the Qt frameworks to a such project in Xcode 4? – Benjamin Oct 20 '11 at 08:21
-
All of the linked-to posts are now dead. In future answers, please consider writing out the answer rather than merely linking. – Stan James Apr 03 '16 at 20:50
-
1@StanJames Thanks for the comments - much appreciated.I've updated the answer as best I can - hope it helps someone! – Clare Macrae May 25 '16 at 20:56
-
this line from http://doc.qt.io/qt-5/osx.html does the magic well. `qmake -spec macx-xcode project.pro` – Fitsyu Dec 30 '19 at 05:30