Thursday, September 1, 2011

Xcode Project Files And Git

This is my first iDevBlogADay post. I am excited to be sharing with you some of the things I find interesting about iPhone game development. 

I love git.

There haven't been too many tools that got me excited about programming like git. I use to think that version control was a necessary evil and something I 'should' do. I always knew that it was important to version your code. Especially when that something really bad would happen and you could go back to a previous version. But version control systems just never seemed that approachable to me.

 But when I learned that git was awesome at branching it opened up my mind to better ways to organize my code. I immediately started using feature branches and got a huge boost in productivity. It made coding fun again. Even exciting.

But when I started working with someone else on an Xcode project I began to feel some pain with the xcodeproj file. I know that this is not necessarily an issue with git because other people using subversion have the same pain. But none-the-less it is a pain.

The problem is that the format of the xcodeproj file is not a friendly file format to have to merge conflicts. It requires you stop and think about how the xcodeproj file works and can put a halt on your development.  I merged these file a couple of times but then a big change made the effort not worth it.

So I googled the answer.

And it seemed the best answer was to put this in your .gitattributes in your project directory

*.pbxproj -crlf -diff -merge
That will treat your pbxproj file in your xcodeproj as a binary file. This is great until two people add a file to the project. Which on wins? Well you have to re-add the file back to your project.

But there is another solution that I am going to toy with.  I have not tried it yet but perhaps I will have before my next iDevBlogADay post. I will have to keep you hanging until then.

Stay tuned...


3 comments:

  1. Great post. I would agree, this is one of the worst pain points, not only when working with someone else, but when working with multiple branches on your own and merging between them! I look forward to your next post on this subject!

    ReplyDelete
  2. I've also been in project file merge hell, especially with a large team. A few things I've done to try and avoid the pain:

    - put all build settings in xcconfig files, not in the project file
    - put all resources in a bundle, so the project file just has a single reference to the bundle and you can rearrange all you want within it
    - use feature toggles instead of feature branches, so the project file doesn't get a change to diverge

    ReplyDelete
  3. @Steve, I am going to try those! Thanks!

    ReplyDelete