Is it possible for SourceTree to use Preview for Xcode Project Files?

When an Xcode project file (*.pbxproj) file is selected in the working directory or staging area in SourceTree, it shows it as a binary file and SourceTree doesn't show the comparison with the previous version. Is it possible to configure SourceTree to recognize *.pbxproj as a text file so I can see the comparison without launching an external diff tool?

6 answers

1 accepted

When a file shows as a binary file, it's usually because it's been encoded as UTF-16. Git and Mercurial can only provide diffs for UTF-8 encoded files, which is why if you encode any other way it treats them as binary.

It's a good idea to change your encoding to UTF-8 for all text files, because as well as not being able to show a diff, Git and Mercurial can't merge UTF-16 files either, so it's much harder to deal with changes across branches. If you have a UTF-16 aware external merge tool you can manually merge things but it does make it harder for you.

When I open the project.pbxproj file (contained in the <projectname>.xcodeproj package) in TextWrangler, the encoding shown in the status bar for the file is UTF-8, so that doesn't seem to be the issue - thanks.

It's odd because I use XCode 4.5.2 too and I always get diffs on pbxproj files. The similar problem here https://answers.atlassian.com/questions/116001/can-sourcetree-diff-markdown-with-file-extension-md-or-markdown/118201 was also a UTF-16 problem, and this has been the case for all other instances of this problem that I've seen too.

The other possibility is that you've marked these files as binary in Git (assuming you're using git), via the .gitattributes file. This can be used to override how Git treats files for diff purposes. Essentially we have no control in SourceTree over what it shown as a text diff and what is considered to be binary, it's all decided by git/hg. Do you have a .gitattributes setup in your repo, and does it mention pbxproj or xcodeproj?

That was the problem. My .gitattributes file contained the following:

*.pbxproj -crlf -diff -merge

As soon as I commented out that line, it worked great - thank you!

My machine shows diff for .xcodeproj file. I think this always worked for me.

I'm using Xcode 4.5.2, within Xcode the project is configured to use git, and using SourceTree version 1.5.6.

However, SourceTree won't show diff for .md file, says it's a binary file. So I asked a similar question:

https://answers.atlassian.com/questions/116001/can-sourcetree-diff-markdown-with-file-extension-md-or-markdown

Maybe a more general question is "How can the user set SourceTree to diff a file of a given type extension?"

My machine shows diff for .xcodeproj file. I think this always worked for me.

I'm using Xcode 4.5.2, within Xcode the project is configured to use git, and using SourceTree version 1.5.6.

However, SourceTree won't show diff for .md file, says it's a binary file. So I asked a similar question:

https://answers.atlassian.com/questions/116001/can-sourcetree-diff-markdown-with-file-extension-md-or-markdown

Maybe a more general question is "How can the user set SourceTree to diff a file of a given type extension?"

On my machine SourceTree shows diff for .xcodeproj file. I think this always worked for me.

I'm using Xcode 4.5.2, within Xcode the project is configured to use git, and using SourceTree version 1.5.6.

However, SourceTree won't show diff for .md file, says it's a binary file. So I asked a related question:

https://answers.atlassian.com/questions/116001/can-sourcetree-diff-markdown-with-file-extension-md-or-markdown

Maybe a more general question is "How can the user set SourceTree to diff a file of a given type extension?"

On my machine SourceTree shows diff for project.pbxproj file. I think this always worked for me.

I'm using Xcode 4.5.2, within Xcode the project is configured to use git, and using SourceTree version 1.5.6.

However, SourceTree won't show diff for .md file, says it's a binary file. So I asked a related question:

https://answers.atlassian.com/questions/116001/can-sourcetree-diff-markdown-with-file-extension-md-or-markdown

Maybe a more general question is "How can the user set SourceTree to diff a file of a given type extension?"

As I mentioned in beepscores post, it _may_ be to do with file associations, but the problem is both pbxproj and md/markdown formats work fine on diffs for me. It's hard to 'undo' those associations on Mac OS X. Out of interest, what happens if you try to open the file in a text editor, then restart SourceTree and take a look at the diff from the staging area?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

541 views 1 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you