In my previous post, Using Subversion with Xcode, Part I, I covered how to create a repository and provided a set of scripts to use to automate these tasks. In this post I will demonstrate how to use the SCM client within Xcode to access your Subversion server.
Before you can use Xcode’s SCM client to connect to your Subversion server, you need to enable the SSH server on your Mac. SSH server is installed by default on OS X 10.5, to enable it open System Preferences.
From the Internet & Network section, select the Sharing icon, within the Sharing preferences check the box labeled Remote Login.
That’s it, at this point your SSH server is running.
Configuring SCM Repositories
After you launch Xcode, you can configure your SCM repositories by selecting SCM > Configure SCM Repositories… from the menu bar, this will open the Xcode SCM Preferences window.
Click the the plus sign ‘+’ to create your repository, it will prompt you for a name and ask you to select which SCM System you are using (Subversion in our case).
Now you need to build the URL to connect to the repository on your computer. Here you enter the Scheme, Host, Path, User and Password and have Xcode build the URL for you.
Host: either <computer name>.local or localhost
Path: the absolute path to your repository
User: your login username
Password: your login password
If you entered everything correctly, you should see a green light indicator with the word Authenticated beneath the password box, click OK. If you are encountering errors, double-check that all information is entered correctly above. You can also try connecting to yourself through SSH via the Terminal: ssh username@localhost.
Before you import your projects in to Subversion, you may want to configure your project so that your build files are not located in the same directory as your project. It is normally not necessary to place these files under version control, as they can easy be regenerated by rebuilding your project.
Viewing SCM Repositories
Whenever you are ready to import into Subversion, you can add it through the Xcode SCM client by selecting SCM > Repositories from the menu bar, this will open the SCM client. If you ran my scripts from the previous post, you should see the following in each column:
Column 1: All of your configured Repositories.
Column 2: The Projects folder you specified when setting up your repository
Column 3: The Project you created
Column 4: The Subversion folders that were automatically created with the script
The horizontal window at the bottom will display the Subversion commands that are being run when you select an item from each column. This can be helpful troubleshooting tool if you are having access or permission problems.
To add your project to Subversion, click the Trunk folder and then click the Import icon. This will display the directory import dialog, here you will want to select the folder of your local project and enter a meaningful comment.
Configuring Projects for SCM
Now that you’ve added your project to Subversion, you will want to configure it so you can start versioning any changes to your code. You may want to create a separate directory on your computer to store projects that are under version control. I recommend choosing a location that is separate from the directory where you initially imported from. Once you establish a location, select the Project folder under the Trunk folder and click the Checkout icon, here is where you will select the folder you created. After you click Checkout, you should receive a Checkout Complete dialog window where you are given the option to open the project. Congratulations! At this point your code should be under version control.
Part III will show you how to commit any changes that you make and will explore some of the SCM tools.