Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

danabrooks December 15, 2012

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

2 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2012

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.

danabrooks December 22, 2012

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.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 23, 2012

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?

danabrooks December 23, 2012

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!

0 votes
KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2012

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?

0 votes
S Baker December 16, 2012

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?"

0 votes
S Baker December 16, 2012

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?"

0 votes
S Baker December 16, 2012

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?"

0 votes
S Baker December 16, 2012

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?"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events