can not use fileMerge on swift files

Strange


I am using the latest version of the comand line tools (03/28/2018)


when I try to use fileMerge on a swift file with git It hangs and produces a ton of error messages



2018-05-02 10:23:22.363 FileMerge[3399:182867] Couldn't load language spec for '<DVTSourceCodeLanguage:0x7f8d2331c990:'Xcode.SourceCodeLanguage.Swift'>'


The really strange part is it looks like the error message are automatically piped through less (might have something to do with git). If I scroll through all the messages eventually file merge comes up


Any ideas?


thanks

Andy

Replies

That does seem quite strange. I’d appreciate you filing a bug about it, then posting your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Here is the bug report


https://bugreport.apple.com/web/?problemID=40043083

I'm seeing this as well, even in the iOS 11.4 toolchain release (Xcode 9.4)

This is still an issue. There are dozens of:



2018-09-11 16:55:20.168 FileMerge[14825:13020623] Couldn't load language spec for '<DVTSourceCodeLanguage:0x7fdb59232540:'Xcode.SourceCodeLanguage.Swift'>'


in the terminal. Oddly enough, if FileMerge is already open, it manages to open a diff just fine.


I've managed to work around this by setting this as my diff command from git:


```

open --fresh `xcode-select --print-path`/../Applications/FileMerge.app

/usr/bin/opendiff "$2" "$5" -merge "$5"

```

I still see this as well. FileMerge doesn't seem to be able to save the changes most of the time.


Also no dark mode support. 😀

I have the same problem when using Versions (1.4.1).

I can however open FileMerge from the command line (using opendiff file1 file2), close the compare between file1 and file2, just so the process remains open and shows in the dock, and then FileMerge works fine with swift files.

You can fix it yourself, looks like there is no reaction from Apple for years anyway :(
Code Block
$ sudo zsh -c 'grep -v "xcode.lang.comment.recursive" /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageSpecifications/Swift.xclangspec > /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/Swift.xclangspec'

After that, there are no errors and the highlight is back.
  • This workaround fixed it for me.

  • I did that and now my FileMerge crashes immediately whenever I try compare Swift files.

Add a Comment
Does anyone have a non-workaround update to this (Quinn perhaps?) It must be 6 years this has been the case now, and FileMerge is fairly important especially when dealing with those pesky xcodeproj merge conflicts ;)

I tried the workaround suggested by @serge-iv

sudo zsh -c 'grep -v "xcode.lang.comment.recursive" /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageSpecifications/Swift.xclangspec > /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/Swift.xclangspec'

But the OS does not allow me to write to the Xcode.app directory. I have a brand new Mac Mini m2 with Sonoma 14 and Xcode 15.0.1 and FileMerge 2.11. Should I be using something other than FileMerge?

  • I disabled SIP and installed the file and now i get the same issue as @kennywyland FileMerge doesn't show the error, but it crashes immediately with a crash report in Console.

Add a Comment

I disabled SIP and was able to run the "workaround" suggested by @serge-iv and while FileMerge doesn't show the error any longer it crashes immediately with a crash report in Console. So on a hunch, since this doesn't seem to be a hot topic, I removed the file /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/Swift.xclangspec and launched FileMerge from the command line via

opendiff 'r3922 ViewController.swift' ~/Documents/Davelopment/ChatClient/ChatClient/ViewController.swift

and was indeed able to open FileMerge. I must conclude that FileMerge is not being called with the correct parameters rather than there being an issue with FileMerge and Swift files. Why this only seems to be an issue with Swift files I have yet to figure out. ObjC .h and .m files are fine as is the .plist file. Actually every other file type I have tried seems to open fine via FileMerge just fine when called from FileMerge. I will provide an update if I ever figure it out.

[EDIT] So I have figured out a workaround but it isn't the greatest. If SIP is disabled FileMerge works just fine with Swift file. When it is enabled it either crashes, if FileMerge is not already running, OR it displays the base file as blank which is equally as useless. If I disable SIP, which I had to do to run @serge-iv's solution, I discovered it works fine. So I'm not sure where this sits, but for now I will run with SIP disabled.

[UPDATE] I have figured out a workaround but it isn't the greatest. If SIP (System Integrity Protection) is disabled FileMerge works with Swift file from the command line but only from the SnailSVN interface if FileMerge is already running in the background.

When SIP is enabled it either crashes, if FileMerge is not already running, OR it displays the base file as blank which is equally as useless.

So I'm not sure where this sits, but for now I will run with SIP disabled.

Why are swift files are treated differently from every other file? How has this been an issue for 5 years with no resolution? Apple, can you please comment on this.