Tag Archives: Git

How to use Version Control since Xcode 9

Xcode 9 has introduced a few changes in regards to Version Control is now handled. If you’re looking for the once so proud Source Control – Configure menu option, you’ll find that it’s no longer there. Dang! Where has it gone, and how are we supposed to manage our projects now?

Turns out there is a new tab in town, next to the Project Navigator (File manager icon) in the left hand pane of Xcode 9, called the Source Control Navigator. Click on it to find a plethora of options:

And would you look at that: for the first time in a decade, we can actually manage Tags as well as Branches here! And we get to see all those commits and comments we’ve been making for years, all without having to use additional version control tools! It’s like Christmas has arrived early!

Here’s a WWDC video on how we’re meant to use the new features from now on. It certainly didn’t answer all the questions I had, so for that, read what I’ve learnt through experimentation further down. Continue reading

How to fix "Couldn't communicate with a helper application" in Xcode 7

Screen Shot 2015-09-18 at 17.30.49

There appears to be a bug in Xcode 7 that you may or may not encounter: when creating a new project with a Git repository, Xcode 7 may tall you that it “couldn’t communicate with a helper application”. The same bug may tell you that it “couldn’t commit files”.

This happened to me after upgrading from Xcode 6.x with which I’ve never had this problem.

Turns out the “helper application” is in fact Git: for some reason Xcode 7 is eager to associate you (the committer) with a name and an email address. Xcode even offers to access your Mac contacts upon first launch.

To fix it, all we need to do is launch our trusty Terminal app (the command line tool) and tell Xcode who we are, and those errors will be a thing of the past. The good news is that it only has to happen once. Here’s how to do it:

On the command line, type the following:

You won’t receive any feedback if everything went well here. But next time you commit or create a new project those pesky error messages will be a thing of the past (until you encounter the next big Xcode quirk of 2015).

Kudos to Kenneth Vittetoe for this solution!

How to change the Git user pictures in Xcode


Those little avatars / user pictures in Xcode are linked to your Mac Contacts. This is not a Git or SVN feature.

You can associate a Mac Contact with a committer in Xcode and make it show up under Source Control – History. If the contact has a picture and you associate that contact with a Git committer then Xcode will show it in History. Here’s how it works in Xcode 6:

  • in Source Control – History, hover over the name of the committer
  • click on that super teeny tiny disclosure triangle
  • from the drop down menu, select Add to Contacts
  • you can now create a new contact, including a picture, or “Choose existing” and pick a contact
  • confirm your choice and the icon shows up in your project

Xcode isn’t clever enough to apply the same committer contact to all your projects so you need to repeat this process for each project.

In the same manner you can replace and update contacts.

How to checkout a previous Tag in Git

Say you have a project and have been tagging particular points of it on the command line using

Sometime later you’d like to go back to such a tag. This is how we can do that.

First, commit your current changes so that you’re free to checkout anything new without losing your hard work. Then simply type

assuming that v1.0 is the name of your tag. Sometimes you may want to checkout this tag and create a new branch while you’re at it, so that your current branch won’t be overwritten. Thankfully we can do this by issuing

This will create a new branch called NewBranch and checkout tag v1.0. Once you’re done working on it you can go back to another branch (for example master) by issuing

Notice that to switch to other branches you only need to give the branch name – unlike with tags which need to be prefixed with ‘tags/’ as shown above.

Xcode crashes every time you open it – and how to fix it

Have you seen this error message before? Perhaps the last 200 times you’ve tried to open Xcode?

Screen Shot 2014-04-11 at 09.31.34It’s usually followed by its loveable companion, the crash report window. The one where you can enter a comment that nobody at Apple will ever read or respond to:

Screen Shot 2014-04-11 at 09.33.20This is a peculiarity that can happen with a particular project. To avoid the first message, select the option “Don’t reopen windows”. This will bring up the Xcode welcome screen. The second message (the almighty Crash Reporter) may still come back to haunt you when you open a particular project – and only that project.

Looks like that project has a problem.

There is usually a way to fix this by deleting the xcuserdata file from the project. This is one of the most annoying features for version control: this set of files keeps track of which tabs/windows are open, which groups are expanded, which methods are collapsed, and in general how your project looks like when you left it.

The trouble is of course that this file changes every 0.000001 seconds, so every time you make a git commit it’s almost instantly outdated. The implication is that you can’t switch to or merge a branch. If you go ahead and mess with this file outside of Xcode problems can arise – usually resulting in us developers wanting to take up another hobby or calling our therapist.

How to fix this

To fix this problem:

  • open a Finder window and navigate to your project
  • right-click on the .xcodeproj file (it’s a package actually)
  • select Show Package Contents
  • a new window appears
  • delete a folder called xcuserdata

Now open your project again in Xcode and it should work. Your workspace will be reset, bringing a very small amount of happiness and tranquility back into your life.

Until this problem happens again.

How to avoid this in the future

In an ideal world those xcuserdata files should all be ignored by Git. And in an ideal world we should never need to use external version control tools like the command line or GitHub for Mac.

Sadly the version control tools in Xcode are far from perfect which means that we have no other choice. You can use your external tool to ignore these files of course, but adding them to a .gitignore is not enough to make them disappear retrospectively or in other branches.

Here’s how to do that: once added to .gitignore, you must issue the following command:

This may restore some order to your project.

How to use Git Branches in Xcode 5.1

In this episode I will show you how to use the Git Branch feature in Xcode 5.1.

Branches are helpful if you’re developing your app. You can isolate a “working” version, create a new branch and fiddle with new features that may destabilise your project. You can then commit your changes – working or not – to a separate branch, and when all is stable again you can merge them back into the master project.

Watch the full course in one convenient playlist:
Catch this episode on my iOS Dev Diary Podcast: