Diff .strings files in Git

Diff .strings files in Git

Your Xcode .strings file, such as Localizable.strings, are encoded in UTF-16 and have a BOM, which makes your Git tool (such as Tower in my case) unable to diff them natively. This makes it hard to see what’s changed (I have to launch my external diff program).

However you can tell Git how to read these files. First edit or create a .gitattributes file in the root of your repository. Put the following in it:

*.strings diff=localizablestrings

Then edit your ~/.gitconfig file add add the following:

[diff "localizablestrings"]
textconv = "iconv -f utf-16 -t utf-8"

Then you should immediately be able to see what’s changed in your Localizable.strings and other .strings files.