[SOLVED, partially]Qt 4.8.3: qmake creates bad Xcode 4.5 projects in OS X Mountain Lion
I am trying to create an Xcode4 project from a Qt Creator project (qt.pro), using "qmake -spec macx-xcode qt.pro". The file "qt.xcodeproj" is created, but when I open it, the project navigator view shows all the files/folders in red. The red color indicates that the file/folder path is bad, and that is indeed the case (inspecting the file qt.xcodeproj/project.pbxproj with a text editor).
It appears that all the file paths are one folder/directly level too "shallow": that is, a file that is actually located at "../../source/Foo.cpp" appears in the project file as "../source/Foo.cpp".
I ran the qmake command from within the same directory that contains the qt.pro project file. The "source" directory I just referred to is a sibling of that directory, so within the qt.pro project file, the path to "Foo.cpp" appears correctly as "../source/Foo.cpp".
As any Mac developer knows, an xcode "project file" is actually a directory, and within that directory reside the actual files describing the contents/settings of the project. So, from within this subdirectory, the path to "Foo.cpp" should be constructed to be "../../source/Foo.cpp".
Given all this, one would expect that the qmake command would properly account for this "extra" level of file path, and append the paths accordingly with "../". I have used Qt Creator and qmake to construct xcode projects in the past (using earlier versions of Qt), and do not recall having had this problem before.
Yes, I could go in and edit my xcode project file, and fix all the paths (and probably some in qt_preprocess.mak as well), but this is somewhat fragile.
Does anyone know how I might invoke quake, such that I don't get this problem? Or otherwise know how to fix or otherwise deal with it?
Any help/advice would be greatly appreciated :-) It's entirely possible I'm simply forgetting some basics about qmake/Qt, so please point out any foolishness I may be committing...
Update: I looked at an older version of my xcode project, which I created using Qt 4.7.4 and opened with XCode3, and the file paths such as qmake generates are lacking that "extra" level of "../". So, it would perhaps appear that XCode4 may differ from XCode3 in its interpretation of relative path names???
You can use macx-g++ (or macx-llvm) mkspecs instead. Those will not generate xcode projects at all - just standard Makefiles like on any other platform. Those work well.
It appears that the problem is indeed a change in XCode4, which perhaps might be rightly called a bug. If I select one of these red folders or files, I see in the File Inspector that the "Location" control is set to "nothing". So, XCode doesn't know how to properly access the file/folder. By setting the "Location" control to "Relative to Group" or "Relative to Project", the file paths are correctly resolved.
For example, here's a thread of perhaps some relevance: http://www.cocoabuilder.com/archive/xcode/314464-xcode-4-preference-for-children-paths.html
In lieu of a "bug fix" from Apple on this (if it indeed is a bug), it seems that qmake would need to programatically set this "Location" setting, when it constructs the XCode project. I suspect that someone familiar with the qmake code for XCode generation might be able to provide a workaround/fix on the qmake side rather easily?