What does this file hold and how important is it to keep it "correct"?
I've seen people write scripts to just merge any change dealing with it and I've heard others merging it manually every time.
What is the correct way to handle it and why?
The project.pbxproj contains all of the metadata about your project that Xcode uses to build it; the settings, the file references, configuration, targeted platforms, etc...
I.e. it is a critically important.
There really isn't a great answer for this. Typically, teams will avoid conflict by limiting edits to the project to one team member at a time.
The Xcode team has put a lot of effort into making the file merge-friendly. In managing several large projects via svn, I've generally found that the merges are automatic and painless.
Until they aren't. And when they aren't, revert, merge changes by hand (i.e. make the changes in the project that conflicted), and move on.
Try my script xUnique. What it does:
project.pbxproj
to JSON formatobjects
in JSON and give every UUID an absolute path, and create a new UUID using MD5 hex digest of the path
children
, files
, PBXFileReference
and PBXBuildFile
list and remove all duplicated entries in these lists
sort_pbxproj
method in xUnique.py if you want to know the implementation;sort-Xcode-project-file
, with some differences in ordering PBXFileReference
and PBXBuildFile