Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Setting up XCode 3.0 with SVN

, 19 Jul 2009 Ms-PL
Rate this:
Please Sign up or sign in to vote.
codeproject Everyone knows SVN (Subversions) is the best version control tool on the planet. XCode, though, might not be as great as eclipse or Visual Studio, it offers one of the best integration with open platforms than both eclipse and Visual Studio. Apple scripting and XCode makes XCode even


Everyone knows SVN (Subversions) is the best version control tool on the planet. XCode, though, might not be as great as eclipse or Visual Studio, it offers one of the best integration with open platforms than both eclipse and Visual Studio.

Apple scripting and XCode makes XCode even more powerful. In fact you can set up keyboard shortcuts to directly search the selected function name or keyword on Google or Apple Docs. (Visual Studio doesn’t offer this support (or atleast that I’m not aware of) But more on that on another post.

Let’s come to the point.
Myself being a iPhone developer, I didn’t use SVN for a long time as a majority of tutorials out there are either too complicated or not direct to the point. Finally I managed to find out a way to use SVN with XCode. In this post, I attempt to take you through one of the easiest way to configure SVN to work with XCode.

<script type="text/javascript"><!-- google_ad_client = "pub-3370464792810806"; /* 468x60, created 7/14/09 */ google_ad_slot = "8086337047"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

Pre-requisites:
I assume that you have already installed XCode. If not, go download your copy from iPhone developer center for free.

First, ensure SVN is installed on your mac.

Your Mac normally comes with SVN installed by default. To check whether its installed, open Terminal.app (I really don’t have any idea where it’s located, Spotlight “Ter” and Boom! there you go…!)

Type, the following

svn  --version

in the prompt.

You should see something like this…

Type SVN --version to check the version of SVN installed on your mac

Type SVN --version to check the version of SVN installed on your mac

If not SVN is not installed on your machine. But this should normally not be the case. If that happens to you, install SVN Server from https://opensvn.csie.org/

SVN Client Configuration

Many other sites advise you to download Versions. Though it’s good and it comes clean client. I don’t see a value @ 39 pounds (100 Singapore $) I’m not aware of any free alternatives. But the good news is XCode comes with a very limited XCode client.

Limited as in, It can connect to an existing repository, but not create one. So committing and checking differences shouldn’t be a problem. However XCode doesn’t have the ability to add your project to a SVN repository. So you have to do two things using the SVN command line.

1) Create  a SVN repo

2) Add your project to the created repo.

After these two steps are done, you can use XCode to checkout the files, commit changes directly from XCode.

Let’s see these two steps with illustrations.

<script type="text/javascript"><!-- google_ad_client = "pub-3370464792810806"; /* 468x60, created 7/14/09 */ google_ad_slot = "8086337047"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

*** BEWARE *** these two steps involve command line. But the good point is, its not complicated.

Step 1:

Type the following command into Terminal

svnadmin create /Users/<mugunthkumar>/tempsvn

You should see the folder /tempsvn created under your user directory with the following sub directories.

Sub folders created for a SVN repository

Sub folders created for a SVN repository

You don’t have to touch any of these. This is just to confirm that the svn create command has indeed worked.

Whoa… Step 1 is done!!!

Relax

Step 2: Create a SVN repository and import your project into it.

This step is easy. But not as easy as the first step. In Terminal prompt, ls to the folder where you have your source code files.

*** IMPORTANT ***

For importing into SVN repository, you have to copy the files you want to import into an empty folder. This is because, if you want to import a folder /Source which contains some files and some sub folders, the import command will not add the folder /Source to the repo. It will add only the *contents” of the folder /Source. This is not what we normally expect.

So, to import your files into the repo under a folder /MyGreatApp, you have to create a folder called /Temp (or anything) and copy your /MyGreatApp folder into /Temp and import /Temp into your project. Don’t worry, the /Temp doesn’t get created in your repository.

Yeah, i know it’s quite counter-intuitive. But you don’t have a choice. Now let’s get started.

Create a directory (I’ve chosen Temp in the example). Copy your code directory “MyGreatApp” into this Temp. Do all these in Finder. Now open Terminal and ls to the directory about “/Temp”. and type in this command into Terminal

svn import -m "Comment goes here" ./Temp file:///Users/mugunthkumar/tempsvn

the  -m “Comment goes here” is optional

the command takes in the directory you have to import and the URL of the repository as it’s parameters. Remember the first step? The repo creation step? We created the repository in /Users/mugunthkumar/tempsvn? If you pass the directory as such, the command fails. So prefix, “file://” to it. (Note the triple / in the command)

After typing this command, you will see a log of all sub directories and files being added to the repo.

Done!!!

Now we will setup XCode to open the project from the repository. Fire up XCode from your Dock (or Spotlight it)

From the XCode menu, choose SCM and select Configure SCM Repositories as shown

SCM Menu in XCode

SCM Menu in XCode

To the left, click the “+” icon to add a new repository to XCode.

Type in a name for your repo (iPhone Dev). This name can be anything.

Fill in the URL as file:///Users/mugunthkumar/TempSVN and the remaining will be filled in automatically by XCode. This URL is same as the one that your provided to the svn import command in step 2. You can provide a user name and password if you want, but if you are the only user (like me and many other iPhone developers), it’s not required.

Click OK

Now you have mapped your repository to XCode. Next, checkout the code which you have imported. To do this, Click SCM from XCode menu and choose repositories. You should see the repo you created (iPhone Dev) on the left and some commands including “Check out” on the Repository Window.

XCode Repositories Window

XCode Repositories Window

Click the “Check out” button (second from the left) and check out the files to any convenient location.

Now open the project you checked out. you can safely delete or archive the copy that you imported previously.

XCode will open it normally. Your project is still not linked to SVN! Relax. Just one more step…! You have to tell XCode to use the (iPhone Dev) repository you just created. This is easy. Don’t worry.

Open your project properties by clicking Project -> Edit Project Properties.

Project Settings

Project Settings Menu

From the project info dialog, select the General tab if it’s not already selected and choose the SVN Repository for your project.

Choose Repo

Select a Repository

Close the info Window.

All Done! Your XCode project is now linked to your checked out. On your files menu, you should see something like this.

SVN Connected Project

SVN Connected Project

The “M” denotes modified files. Various other statuses are also displayed here.

Your SCM menu should show the following options.

SCM New Menu

SCM New Menu

You can now compare your changes to the latest version, commit your changes to the repo and do a lot others from this menu.

That’s it. Hope you liked the article.
Do write a comment or link back if you liked this article


Mugunth

Share and Enjoy: Print this article! Digg del.icio.us Facebook Google Bookmarks Netvibes

Related posts:

  1. iPhone Tutorial – In-App Email codeproject Sending an email from your iPhone application is...

Related posts brought to you by Yet Another Related Posts Plugin.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Mugunth Kumar, Singapore
Software Developer Honeywell
Singapore Singapore
Working as a Software Engineer @ Honeywell Singapore
I also develop iPhone Apps, Windows Apps, Web Apps in my free time.
Visit, http://mugunthkumar.com
for more information.
 
I blog @
http://blog.mugunthkumar.com/

Comments and Discussions

 
GeneralMy vote of 5 PinmemberOfer Hamerman18-Jul-10 10:26 
GeneralNice article Pinmemberrupesh_gangi17-Jul-10 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 20 Jul 2009
Article Copyright 2009 by Mugunth Kumar, Singapore
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid