XCode4 hell: PBXFileReference buildPhase

| Comments

We’re used to have troubles with the .xcodeproj file. This file actually behaves pretty bad when several people are working on the same project, stored in SVN. This is usually quite easy to solve, but yesterday it went worse…

Everytime you want to add (remove, rename…) a file to the project, you should first update the .xcodeproj file from SVN, add your files as soon as possible and commit the project file. If you don’t do that, you could end up with several people adding files to the .xcodeproj at the same time, ending up in merge conflicts. Trust me, you don’t want that!

But usually this kind of conflict is easy to solve: open the .xcodeproj with a text editor, fix conflicts manually, all good. This time, it went worse:

So what happened? When you add a file to XCode, it generates a hash for this file. I don’t know how they calculate this hash, but it occurred that two of these hashes (mine and the one from my colleague) were colliding.

To fix this, we had to find the colliding hashes. Look for recently added files, look for anything weird in the .xcodeproj file. In our case, some comments were missing from the file. Based on that info, we found the colliding hashes, removed them and took a deep breath while reopening the project.

“Fixed” :) Good luck if you stumble on this problem. Please post a comment on how you solved this.

And, by the way, what is your trick to avoid problems with this file?