Home How to Auto Resolve Git Merge Conflicts in Xcode project.pbxproj file
Post
Cancel

How to Auto Resolve Git Merge Conflicts in Xcode project.pbxproj file

The Headache 🤕

Yo, do you ever get frustrated with having to manually resolve Xcode’s project.pbxproj file merge conflicts whenever you and a teammate add a new file to your project? I know I do. It’s a hassle, right? Even though it’s an easy merge where you want to keep both sides, git somehow can’t seem to figure it out. But guess what? You don’t have to manually resolve these conflicts!

There’s a simple solution to make git merge those pesky *.pbxproj files for you. And it works almost every time! (Well, there are no guarantees, but it usually works.)

1. Create a .gitattributes file

First, create a file called .gitattributes in your project’s root directory. If you don’t have one already, that is.

2. Set the merge strategy to union

Then, add the following line to your .gitattributes file:

*.pbxproj merge=union

This tells git to merge using the union strategy, which keeps both sides (theirs and ours) during a merge. And that’s usually what you want when dealing with a *.pbxproj merge conflict.

3. Add the .gitattributes file to git and push your changes

Now that your merge strategy is set, share the love with the rest of your team. Add the .gitattributes file to your git repo by typing this command:

git add .gitattributes

Commit and push your changes, and you’re done! No more manual conflict resolutions for you!

This post is licensed under CC BY 4.0 by the author.