56

Am looking for how to set up file compare/diff in Xcode 4, but have run into brick wall. Anyone can tell me how to do it?

jarrodwhitley
  • 826
  • 10
  • 29
pdenlinger
  • 3,897
  • 10
  • 60
  • 92

3 Answers3

76

If you're looking for comparing two different files (instead of comparing two versions of the same file), you can use the FileMerge tool included with Xcode. Spotlight can find it for you.

zhengyue
  • 1,268
  • 12
  • 18
  • 30
    In the 4.3.2 version of Xcode, FileMerge is hidden in the application package. To launch it, go to the Xcode menu and select Open Developer Tool. – Tim R. Jun 13 '12 at 22:00
  • 4
    FYI, both this answer and the comment above by Tim R. continue to be true in Xcode 5. You can still launch the app by choosing `Xcode` > `Open Developer Tool` > `FileMerge`. – Basil Bourque Mar 07 '14 at 19:45
  • 2
    Alternatively, Spotlight is able to see FileMerge, so simply searching `FileMerge` in Spotlight will bring it up as the first result. – rickcnagy Jul 22 '14 at 18:05
  • Unfortunately, FileMerge is not really nice. The Syntax highlighting is not as beautiful and also it's not an editor. It's meant to *merge* files. If you want to compare two files to correct the second one (e.g. when copying methods to another class) FileMerge is IMHO not the right tool... – Julian F. Weinert Aug 24 '15 at 11:35
  • I'm still looking for something more convenient. – Julian F. Weinert Aug 24 '15 at 11:36
  • Another drawback (as for me) is the missing line-number-display – Julian F. Weinert Aug 24 '15 at 11:39
  • @TimR. is there anyway that I can use fileMerge on 2 different branches? – mfaani Sep 01 '16 at 07:43
38

Richard Brightwell's answer is correct, although it threw me a bit as there is a step missing.

  1. Select the file from project navigator then click the version editor button (top right).
  2. Click the timeline icon between the two files to display a vertical bar representing the revisions (black bar with white indicators for each revision).
  3. Drag the white arrows to the versions to compare.

XCode 4 Compare Utility

Jason George
  • 6,992
  • 8
  • 44
  • 60
2

There is a button above the code window that looks like two file folders inverted one over the other. Click that button to open a side by side view of your file differences.

It's the far right button in the red box drawn on this screenshot.

Richard Brightwell
  • 3,012
  • 2
  • 20
  • 22