Is it possible to use FileMerge as standalone app

applicationsxcode

I'm wondering if there is a way to use FileMerge as a standalone tool. I don't want to install Xcode, since I don't need it. I just want the FileMerge app. Is that possible?

Best Answer

FileMerge 2.8, which ships with Xcode 5.0.1 links to frameworks that are located inside of the Xcode.app bundle. Shared libraries that are used by FileMerge can be displayed by performing the command:

otool -L /Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge

The output of this command indicates that FileMerge needs to use the DevToolsInterface, DevToolsCore, and DevToolsFoundation frameworks. :

/Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge:
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1247.0.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1052.0.0)
    @rpath/DevToolsInterface.framework/Versions/A/DevToolsInterface (compatibility version 1.0.0, current version 3000.1.0)
    @rpath/DevToolsCore.framework/Versions/A/DevToolsCore (compatibility version 1.0.0, current version 2404.0.0)
    @rpath/DevToolsFoundation.framework/Versions/A/DevToolsFoundation (compatibility version 1.0.0, current version 3001.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 852.0.0)

The prefix @rpath indicates that dyld will use the run path list to search for frameworks that are being referenced. Specifically, FileMerge contains "../OtherFrameworks" in its run path list. When located inside of the Xcode.app bundle, those frameworks are right where FileMerge expects them to be.

However, if you copy FileMerge out of the Xcode.app bundle, FileMerge will crash upon launch. This occurs because the referenced frameworks (referenced above) are not in the run path list, which causes dyld to exit with an error of "image not found". The reason it cannot find those referenced frameworks is that a folder at the relative path "../OtherFrameworks" does not exist, and the frameworks do not exist in any other folders listed in the run path.

To use FileMerge without the Xcode app installed, you have a couple of options:

  1. Copy FileMerge to the location of your choosing, and copy the contents of /Applications/Xcode.app/Contents/OtherFrameworks/ to one of the folders referenced in the run path list (~/Library/Frameworks or /Library/Frameworks are probably a couple of the best choices).

  2. Copy FileMerge to the location of your choosing, and copy the contents of /Applications/Xcode.app/Contents/OtherFrameworks/ to be at "../OtherFrameworks" relative to the FileMerge app (e.g., if FileMerge is at ~/Applications, copy the folder "OtherFrameworks" to ~/OtherFrameworks

Edit

The above answer allows FileMerge to launch, but the application will terminate when you actually attempt to compare files. Apparently the application is looking for platform information at the path ../Developer/Platforms/MacOSX.platform/Info.plist. This means that it is necessary to copy Info.plist from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist to ../Developer/Platforms/MacOSX.platform/Info.plist (relative to FileMerge.app). Here are some steps that could be used to copy FileMerge to a folder at ~/Applications:

mkdir ~/Applications
cp -R /Applications/Xcode.app/Contents/Applications/FileMerge.app ~/Applications

cp -R /Applications/Xcode.app/Contents/OtherFrameworks/* ~/Library/Frameworks

mkdir -p ~/Developer/Platforms/MacOSX.platform
cp /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist ~/Developer/Platforms/MacOSX.platform