Setting Up Subversion in Xcode 3.0

Using version control during software development allows experimentation without worrying about removing the experimental work when it does not pan out. Apple has gone a long way to integrating Subversion into Xcode but their instructions are oriented more towards groups of developers rather than a stand-alone version control for a single developer. There is a much easier and more secure way to use Subversion.

The Apple instructions show how to use both svnserve and the Apache plugin as approaches to setting up Subversion. Both allow outside access. The Apache approach is useful for large groups of developers while the svnserve approach is appropriate for smaller groups. But neither address a single developer working on one computer. Svnserve can be used in a local fashion that does not require turning on remote access. Since everything is local, ssh is not necessary and connections are more reliable and do not require internet access.

Setting up the repository

Start by following the instructions to set up a repository. For this article it will be located at /Library/Subversion/Repository but can be located elsewhere.

mkdir -p /Library/Subversion/Repository
svnadmin create /Library/Subversion/Repository/Project1

Import an empty directory structure using a temporary directories.

mkdir -p /tmp/Project1/trunk /tmp/Project1/branches /tmp/Project1/tags
svn import /tmp/Project1/ file:///Library/Subversion/Repository/Project1 -m "Initial import"
rm -rf /tmp/Project1

Restrict the permissions.

sudo chown -R root:admin /Library/Subversion/Repository
sudo chmod -R ug+rwX,o= /Library/Subversion/Repository

Setting up Xcode

Open Xcode and create Project1. It can just be placed on the Desktop since it will be removed once it has been imported into Subversion. Since the build directory does not need to be stored in Subversion, go to Project->Edit Project Settings and specify a Custom location and Build products location. Click on the Configure Roots & SCM button. If there already is an entry, delete it (-). Click the add repositories (+). For the Root, put the path to the Xcode project directory. Under Repository select Configure SCM Repositories.

Now we will diverge from the Apple instructions. Instead of using ssh enter the local repository form of the URL.

file:///Library/Subversion/Repository/Project1

The remaining fields should automatically fill once you leave the URL field and the status indicator should quickly show "Authenticated." The advantage of this approach is remote login does not have to be enabled, the computer does not have to be hooked up to the internet, and the response is much faster.

Continuing with the instructions from Apple, go to SCM->Repositories and using the Repository browser select the trunk directory of the Project1 repository. Click on Import. Select the Xcode Project1 directory, add a comment and click on import. Click OK to confirm. Once the files are imported they can be deleted from the desktop.

Checking out and turn on SCM

Start Xcode but cancel at the first menu. Go to SCM->Repositories. Select the repository and then the trunk and Project1. Click on Checkout. Edit the name of the directory and select the location for it. When the checkout is completed you will be prompted to open it.

Go to Project->Edit Project Settings. Click on the Configure Roots & SCM. Under Root, enter the project directory. For the Repository, choose the repository just set up for this project.

Categories

Mac