Xcode 4 + Subversion server

Introduction / first thoughts

Chances are, you've heard of this little thing called version control. The most basic implementations of which create a local repository with which to version your project source. If you're looking to get your repository up in the cloud without using Xcode's built-in local git repository, and you don't want to use a free open-source github account, the following is my account of the best way to set up a remote subversion repository. This knowledge is based on some existing articles that contained pieces of the puzzle, as well as some trial and error on my part. Let's get started!

Set up server repository

The point of this article being to set up a remote repository, this step will vary based on your hosting provider. I use DreamHost, and was able to follow their instructions to great success. When you're finished, you'll want a password secured subversion repository specifically for your new project, ready to start uploading files.

Set up global ignores for Subversion

There are a few file types you'll want to have your repository ignore. These include files specific to your local workspace, specific data Xcode stores per user, hidden files Apple uses for Spotlight information and so on. You can find your subversion configuration file at the following location: ~/.subversion/.

You'll want to locate the global-ignores line in the svn config file, uncomment it by removing the pound (#) sign, and adding the following text: *.xcuserstate project.xcworkspace/ xcuserdata/ .DS_Store

When you're finished, the line should read as follows:

global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.xcuserstate project.xcworkspace/ xcuserdata/ .DS_Store

New project in Xcode

On to Xcode! First things first, you'll want to change the default build directory. You don't want your build files indexed by subversion. In fact, subversion won't handle binary files properly. You can change the build path by going to Preferences > Locations and changing Derived Data to a custom path. I chose a custom folder in my Development directory, as shown. Really, it can be wherever you like. Keep in mind, this will affect all projects.

Xcode Build Location

After your build directory has been changed, you'll make a new project in Xcode. Choose whichever template suits your needs best, or any pre-existing project templates you might have. It's easiest to go ahead and modify the project folder structure / initial file names at this time. Actions such as adding view controllers or classes you know you'll need, renaming existing controllers, etc. Renaming / moving / deleting existing files can be done at a later time, however, it's far easier to make these changes before you initially commit your project to the repository.

Add repository

Next, we need to inform Xcode of the repository details. Repository settings are found under File > Source Control > Repositories...

Click the plus button in the bottom left, then select Add Repository... to create a new repository for your project, then fill in the settings appropriately. When asked about the settings for Trunk, Branches and tags, just enter: "trunk" "branches" and "tags". Those directories will be created as needed.

Import project to repository

Once you've added the repository to Xcode, it's time to import your project files! One quick note before you start: Xcode doesn't give you any feedback on the status of the import. No progress bar, no spinning beach ball, it just sits there. No indication at all regarding the status of the import. Just leave it alone to work in silence.

Since you've been warned, let's import those files! Click on the Trunk directory in the left pane, then the import button located bottom right. Select the folder containing your project, and Xcode starts chugging away (without any indication it's happening, of course).

Delete (move) old project

You can tell the import has completed when you see your project files listed in the repository.

After this is completed, make sure you close your Xcode project. Next, either move your original project directory to a temporary folder, or simply rename it. In the next step, we're going to request a copy of the project from the repository, and we need a safe place to save it.

Check out project from repository

To begin checking out your project, click on it in the Organizer pane. Then locate the checkout button in the lower left and click it. You'll be prompted for a directory in which to save the project you're checking out. You should choose your development folder.

As before, there will be no indication of progress. The only sign that this process has been completed will be a dialog asking if you'd like to open the newly checked out project.

Final thoughts

After a little bit of trial and error (especially regarding properly ignoring unnecessary files), this method seems to be working very well so far. Hopefully you'll find it useful (if you aren't already using github, that is).

Again, when I was initially figuring this out for myself, the following post over on Blog Pav Blog was immensely helpful, and definitely worth a read. Especially if you have a sense of humor and want a few chuckles.

Share Comment on Twitter