Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Project file git merge conflict

Tags:

git

xcode

In Xcode, what's the best way to avoid Git conflict in the project file? (I am in manual git, not using Xcode interface for git)

I've cloned mapbox-ios-sdk from Github, hacked it, and now the remote master has changed. When I tried to pull the remote changes into my local, after merging there would be merge conflict in the project file. (Specifically, I mean the project.pbxproj in the .xcodeproj)

I do not really think project file should be put into the ignore, since if there are any new files the project file, the .pbxproj file seems to be changed. (Or am I just plain wrong and this file should be put to ignore? But obviously it wasn't on ignored in the mapbox-ios-sdk to begin with. People need the project file after all.) But I've also ran into this conflict before in my collaboration project with another collaborator and it's keeping me from using Git altogether.

Should I figure out how to manually resolve conflict or is there a better way to deal with this?

like image 323
huggie Avatar asked Oct 16 '12 04:10

huggie


People also ask

How do I merge conflicts in Xcode?

After you choose a resolution for each conflict, Xcode enables the Merge button. Click the Merge button to complete the merge, or click Cancel to abort the merge and restore your branch so you can make more changes before merging.


2 Answers

A lot of websites simply suggest to use a .gitattributes file with:

*.pbxproj merge=union

We're gonna try this approach before trying to use scripts. If we find any issues I'll be sure to update this post. Also if anyone else has comments to this approach please include.

like image 183
Warpzit Avatar answered Sep 21 '22 08:09

Warpzit


.pbxproj will change when you add new files to the project. There will be conflicts if two or more collaborators add files at the same time (without getting one another's changes first). We are avoiding this in my project by following these steps before and after adding new files:

  1. Before adding a file, commit your changes, then pull from the master so that you have the latest.If someone has added a file, you now have the latest .pbxproj
  2. Add your file(s).
  3. Immediately commit and push your changes up to the master (hopefully, before another collaborator has added another file).

It's wimpy, but we don't relish manually resolving .pbxproj conflicts.

Also, see this Stack Overflow question with excellent responses: How to use Git properly with XCode?

like image 20
cmac Avatar answered Sep 21 '22 08:09

cmac