Q:

How to keep the XCode 4 pbxproj file in sync in a CMake-controlled project?

We have a C++ project which is built using CMake (2.8.7) and versioned with Git. Two of our developers (DevA and DevB) use XCode 4.2. They can generate an XCode project using CMake's -G Xcode feature, no problem, and push/pull/commit changes through the IDE. The problem starts when the project gets restructured. If DevA adds a few files and commits/pushes, DevB can pull the changes (they are visible in the file system), but they won't be reflected in the XCode project setup. We thought that maybe putting the *.pbxproj file under version control could solve this; however, the file is full of absolute paths. So far the only "solution" we could find was to re-create the XCode project by running CMake -G Xcode every time the source tree gets reorganised, which is very tedious. Is there a simpler way? Thanks.

A:

CMake registered a ZERO_CHECK target as the dependency for every "real" target in Xcode, its sole responsibility is to rerun CMake in "CMakeScripts/ReRunCMake.make" and update the Xcode artifacts if one of the CMakeLists.txt files was changed. If you do not see the changes reflected in Xcode, it is because Xcode won't watch its .xcodeproj directory for changes. The pragmatic solution is to close the project in Xcode and reopen it. At which point you could rerun "cmake -G Xcode .." anyway.
The same applies to Visual Studio 10 as well, except that it will ask you for every target whether you want to reload it. It works fine for smaller changes but not for adding / removing files.
I can live with it, as there is a point in a projects life, when the set of source files is not really changing anymore. At least that's my experience.

