jonepatr
jonepatr

Reputation: 7809

Xcode 4, git and mergeing projectfile!

I have a problem! We are working on an iPhone-app and are using git. The problem is that if someone changes something in the project(adds a file and so on..) and i try to pull that change, I have to merge it. But the merge isn't painless, I often end up getting a corrupt project file and have to spend quite some time just to fix that.

Does anybody have a solution for this problem?

(Sorry for my crappy English)

Upvotes: 3

Views: 1577

Answers (2)

Adam Dymitruk
Adam Dymitruk

Reputation: 129566

Project files are notorious for conflicting. I would enable rerere (stands for "Reuse Recorded Resolution") so that if you have to redo conflict resolutions, you can at least have your decisions cached from the previous time you did them. An excellent write up on rerere is located here: http://progit.org/2010/03/08/rerere.html

If you have the inclination, the better thing to look at is an advanced topic of writing a custom merge driver. See "Defining a custom merge driver" in http://git-scm.com/docs/gitattributes

Hope this helps.

Upvotes: 4

user189804
user189804

Reputation:

Three important steps:

  • Cause git to ignore everything in the project file except for the project.pbxproj under the .xcodeproj folder - use .gitignore for this.
  • before you pull a changed .pbxproj close your project. One of the biggest problems you face is that if you get a new version while Xcode has the project file open it can just save its "current" version over the changed one you want.
  • merges will sometimes result in spurious data like ">>>>YOURS" or ">>>>THEIRS" merge markers getting included in the project file. If you have to merge do it manually with a tool like filemerge where you can inspect each change and choose whether to include it or not.

If all this fails and you get a corrupted project file anyway

  • accept the version someone else submitted and redo your own changes, it's almost always easier and the link errors will remind you soon enough.
  • learn the value of frequent commits.

Upvotes: 1

Related Questions