http:// / iPhone / xcode-svn.shtml

Issues with Xcode and Subversion

Apple's Xcode environment has the ability to work with source code control systems, such as CVS, or the more modern subversion (or "svn", as it's also known.) I recently started using subversion for my other programming work, so I was rather pleased to find that Xcode has the ability to work with it.

Problems with documentation

Apple's public documentation about setting up subversion and making Xcode work with it is rather dated- as I write this (2009-02-02) it was last updated on 2005-12-08. Because of its age, there are a few problems with it:

To be fair, Apple does have more up-to-date documentation about Xcode, which includes current screen shots and better procedures... however this other documentation is only available if you sign up as an iPhone developer (which you also have to do in order to download the iPhone SDK, so chances are you will have done this already.) However, I did also find one problem with that document as well... at least it seems like a problem to me, because I'm familiar with using the svn command-line program and know more about how to use it.

That document (link may require you to log in first) tells you to move the "build" directory out of the project directory in order to keep subversion from taking control of them. They are correct in saying that the directory shouldn't be under subversion control; however it's not necessary to move it- as you'll see below, it's very easy to tell subversion to ignore it.

Using the Apache-based subversion repository

As I noted above, Apple's public documentation has you install subversion and Apache, then create a temporary directory, copy the entire project into it, and then import that directly into the raw repo directory. If you have Apache configured as shown in that document, it will listen on port 8080 of every IP address on the machine- which means if the machine has (for example) the IP address, then any other machine can access the subversion repo using a URL like "". Being able to access the repo from multiple machines is one of subversion's biggest advantages.

Apple's documentation also has you configure Apache using "SVNPath", which specifies exactly one repository. My own server uses "SVNParentPath", which specifies the parent directory of multiple repositories. I find this to be a better solution, since it allows me to create multiple repositories for different project or different clients. This page explains how I set things up on my own server (again, my server runs Linux rather than using a Mac as a server. I like the Xserve idea, but I don't have the Xserve money.)

Adding an existing project to subversion

I'm actually writing this section as documentation for myself to refer back to when I start a new project. It has specific information about my own server, however I will explain this when appropriate. Note that my server is set up using these directions.

One of the most common things I run into is that I'll start a project with Xcode, then want to add it to a subversion repository afterwards (either right after starting it, or after building part of it and realizing that I'm on the right track and that I'll want to keep this one.) Apple's directions have you manually copy the entire project to a temporary directory, import that into the repo, and then check it back out into the directory where Xcode expects to find it- but that's a lot more work than you really need to do.

What I do is this...

It looks like a long process on the web page, but that's because I've taken the time to explain each step and show every command. When I actually do it, it only takes a few seconds:

$ cd ~/src/iPhone/HelloWorld
$ svn mkdir
$ svn co . ← don't forget the dot!
$ svn add *
$ svn revert --recursive build
$ svn ps svn:ignore build .
$ svn ci

Configuring Xcode to use Subversion

Apple's documentation actually covers this part of things rather well. The only reason I mention it here is because if you've been following along with the page to set things up for yourself, you need to make sure you don't forget to do this. I may or may not add more to this in the future, but for now I don't really think it's needed.

Other notes