Resolving xcode git merge conflict

Preview:

Citation preview

Resolving Xcode’s git merge Conflict

Ricardo Pramana Suranta

@edopelawi

Xcode loves Git.

Git, not SVN or Mercurial 🤔

Image taken from atlassian.com

Image taken from atlassian.com

Image taken from nvie.com

Xcode loves Git.

💢 💢

👊💥

Real love is hard love.

Image taken from atlassian.com

merging(git merge)

*.pbxproj conflict problems

• It’s opaque, Xcode-generated.

• It makes no sense.

How to fix this?

• Famous last words: “I’ll do it manually.”

How to fix this?

• Famous last words: “I’ll do it manually.” 💀

How to fix this?

• Famous last words: “I’ll do it manually.” 💀

• Let Git fix it.

Fixing using Git?

Add

*.pbxproj binary merge=union

to .gitattributes file

(https://robots.thoughtbot.com/xcode-and-git-bridging-the-gap)

How to fix this?

• Famous last words: “I’ll do it manually.” 💀

• Let Git fix it. ❌

💢 💢

👊💥

How to fix this?

• Famous last words: “I’ll do it manually.” 💀

• Let Git fix it. ❌

• Let Xcode fix it.

Fixing using Xcode?

• Clear project structure

Clear project structure

Domain > Type > File(in the Finder / real folders, too)

Clear project structure

Groups in Xcode Full path (Xcode’s Inspector bar)

Folder structure(Finder)

Fixing using Xcode?

• Clear project structure

• Pick higher priority changes using git checkout --theirs / --ours

Deciding change priority on *.pbxproj

• Prioritize changes on build settings (build number, post build script, framework, etc.)

• On file changes, always pick other people’s changes over ours.

Deciding change priority on *.pbxproj

👩 👱Anna’s changes: - Bumped build number - Changed provisioning profile

Bob’s changes: - Added new files

Deciding change priority on *.pbxproj

👩 👱Anna’s changes: - Bumped build number - Changed provisioning profile

Bob’s changes: - Added new files

Higher priority

Deciding change priority on *.pbxproj (As Bob)

👩 👱Anna’s changes: - Bumped build number - Changed provisioning profile

Bob’s changes: - Added new files

Pick the other branch (git checkout --theirs *.pbxproj)

Deciding change priority on *.pbxproj (As Anna)

👩 👱Anna’s changes: - Bumped build number - Changed provisioning profile

Bob’s changes: - Added new files

Pick the her own branch (git checkout --ours *.pbxproj)

Fixing using Xcode?

• Clear project folder structure

• Pick higher priority changes using git checkout --theirs / --ours

• Drag and drop folder to Xcode as groups

How to fix this?

• Famous last words: “I’ll do it manually.” 💀

• Let Git fix it. ❌

• Let Xcode fix it. ✅

How to improve?

• Make script / app to automate Xcode’s *.pbxproj update process to replace drag-and-drop step

• Using folder references for prevent drag-and-drop (?)

Further reading

• Vincent Driessen’s successful Git branching model (http://nvie.com/posts/a-successful-git-branching-model/)

Thank You! :)