Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git and pbxproj

Tags:

git

xcode

I was looking at an open source Mac application, and they gave some suggested values for .gitignore. They were what I would expect...

However, they also suggested an entry into a .gitattributes file:

*.pbxproj -crlf -diff -merge

I'm not the most knowledgable in terms of git, so I was wondering - what exactly are the benefits of adding this line? What does do in particular? I've only seen this suggested in this one project, and if it was normal practice I would have expected to see it elsewhere right now. So I was curious about how it applies to the pbxproj file specifically.

like image 598
DarthNerdus Avatar asked Oct 11 '09 01:10

DarthNerdus


People also ask

Should I ignore project Pbxproj?

This file holds the list of all the files in the project, settings of targets and which files belong to which targets. It's probably the meatiest file in project bundle. You should not ignore this file.

Should I commit Xcodeproj?

For example, the Xcodeproj is actually a bundle of more folders and files! Teams need to share the project's configurations, but people don't want to invest full days in solving stupid conflicts on autogenerated files. So what is the solution? Do not commit these files!

Where is Project Pbxproj located?

Usually it is situated inside corresponding YourProjectName. xcodeproj package - it is a folder but looks like an ordinary file in MacOS's Finder - you can go into it right-clicking and choosing 'show package contents' option.


1 Answers

The pbxproj file isn't really human mergable. While it is plain ASCII text, it's a form of JSON. Essentially you want to treat it as a binary file.

Here's what the individual flags do:

-crlf: don't use crlf <=> cr conversion

-diff: do not diff the file

-merge: do not attempt to merge the file

From the Pro Git book by Scott Chacon

Some files look like text files but for all intents and purposes are to be treated as binary data. For instance, Xcode projects on the Mac contain a file that ends in .pbxproj, which is basically a JSON (plain text javascript data format) dataset written out to disk by the IDE that records your build settings and so on. Although it’s technically a text file, because it’s all ASCII, you don’t want to treat it as such because it’s really a lightweight database — you can’t merge the contents if two people changed it, and diffs generally aren’t helpful. The file is meant to be consumed by a machine. In essence, you want to treat it like a binary file.

like image 121
Grant Limberg Avatar answered Sep 24 '22 05:09

Grant Limberg