Skip to content
devinlane edited this page Sep 13, 2010 · 2 revisions

What is xcode-merge?

xcode-merge is a command line utility offering an optionally interactive merge of xcode project files.

Motivation

During Mac development, for which I chiefly use Xcode, I and my coworkers frequently use multiple branches to organize development strands. When it is time to merge these branches, traditional merging tools suffice for most files — with the glaring exception of Xcode projects. These files, while text, are the serialized representation of an object graph, meaning that the file can be written in a number of different orders. Because of this, an ordinary diff tool produces unreadable diffs, and attempting to resolve the merge conflicts by hand with a text editor can be extremely difficult. In my latest project merge episode, I had over 200 conflicts — all of which I would have had to edit by hand (as opposed to choosing left or right), as the merge algorithm wanted to replace an addition on the left with a different addition on the right, due to line positioning.

This program is designed to eliminate this problem by providing a merging tool that understands the hierarchical structure of Xcode project files and can merge them accordingly.

Design

xcode-merge is designed to produce a xcode project that is a reasonable combination of project changes on two different branches. It aims to produce a xcode project that requires the lest amount of manual tweaking before it is “close enough” to the developer. To this goal it performs a few cheats: it combines items in a group with the same name, and attempts to keep a relative ordering of items in a collection.

Usage

xcode-merge [-i] <base> <local> <remote> [<output>]

The -i flag enables interactive mode. In interactive mode, the user will be prompted to resolve conflicts. If interactive mode is off (the default), the merge is aborted if conflicts are present.

The first three args are the base, local, and remote files in a 3 way merge. The fourth argument specifies an alternate output file for the merged project. If no fourth argument is specified, xcode-merge writes the merged project to on success.

Bugs

Probably many. I wrote this to work as quickly as possible with my Xcode project so that I could get it merged and go. Particular areas of concern:

  1. The tool was built against the Xcode 2.4 project format. While the newer formats seem to be similar, there could be items that aren’t addressed properly. The system is designed to be extremely generic, but there are some parts that are aware of specific project elements.
  2. I had to write an OpenStep style property list writer, as the system one is read only. This writer is a bunch of crap — it’s likely that it doesn’t escape all required characters or put quotes around a string in all cases it’s supposed to.
  3. Some conflicts are presented more than once (I’ve seen some up to 3 times)
  4. The conflict resolution is pretty basic: you either choose the left or ride side, or abort. Better information about what the conflict is, and the ability to enter a manual value would be much better.
Clone this wiki locally