Xcode 4 & Subversion over SSH With Custom Port

I run a SVN repo on a local server that I wanted to connect to via ssh on a custom port using shared key authentication. I use Xcode 3.2.6 for some legacy apps and Xcode 4 for new software.  Unfortunately Xcode is less than helpful with this setup, and though a few things seem to have changed for the better in 4 it’s still not as trivial as it should be.   But I got it working and thought others might find it useful, so here’s how to do it:

Subversion With Custom Ports
Using SVN with a custom port requires altering the config file, which is located in /Users/yourusername/.subversion  In the [tunnels] section of the file add the following line (assuming your custom port is 1234):

ssh1234 = /usr/bin/ssh -p 1234

This will enable you to connect to the SVN repo with the following call:

svn command svn+ssh1234://yourusername@the.svnrepo.com/path/to/repo

Quickly Create a New Xcode 4 Project With SCM
Connecting to an svn repo in Xcode 3 hasn’t changed much and there’s lots of info online about it.  For Xcode 4 I found this to be the quickest way to create a new project with Subversion SCM:

  1. If you want a basic skeleton from the project templates create a new project and save it somewhere.
  2. Create a new temporary directory, eg. myProj_tmp, with (optionally) 3 subdirectories – trunk, branches, and tags. 
  3. Copy your saved project to trunk.
  4. On your SVN server run the following command:
    svn create /path/to/new/project/repo
  5. On your Mac open terminal and run the folowing command:
    svn import /path/to/myProj_tmp svn+ssh1234://yourusername@the.svnrepo.com/path/to/repo -m "Initial Commit."
  6. Delete the temporary myProj_tmp directory and subdirectories, along with the initial project files.
  7. Open Xcode, go to Organizer, Repositories, click the + at the bottom, select Checkout or Clone Repository…, and use the credentials above (svn+ssh1234://yourusername@…) to pull down the project, saving it to an appropriate location when prompted.