25

It seems that all of the initial Google results for "using subversion with xcode" are actually just tutorials for installing and configuring svn and Xcode, as opposed to actually using the two (i.e. interacting with svn via Xcode's GUI).

Is anyone aware of a good guide that teaches the tricks and pitfalls of working with svn via Xcode's GUI? Something that bridges the gap between the most excellent Version Control with Subversion book and the Xcode IDE (as in pure Xcode GUI without any terminal command use)?

Edit:

We all love our terminal commands, and we all love Eclipse but (and I mean this in the nicest possible way) neither is really the point of the question. I’d prefer to use svn via Xcode’s IDE instead of via terminal just as I prefer (well, for this case) to code in Xcode’s IDE instead of using vim and gcc. Apple engineers spent a good bit of time implementing that SCM menu in Xcode; someone has to have seen a usage guide somewhere.

Kevin L.
  • 4,548
  • 7
  • 39
  • 54

10 Answers10

10

I used this page as a reference for setting up my XCode projects with SVN. It is a good starting point, but I'll give a short walkthrough of what I did (since the page isn't really all that helpful!).

A couple notes: I'm using XCode 3.1.2 and Subversion 1.4.2. I've heard of problems with using SVN 1.5, but there are ways around that which I wont get into.

First off, I had a repository already set up and created the XCode project afterwards.

  1. In XCode you need to set it up to know about your repository using the SCM tab in the preferences window. Enter:

    1. A Name (this is arbitrary and used for reference with XCode)
    2. The scheme (http or svn)
    3. The host (i.e. svn.example.com)
    4. The path (the exact path to the SVN repository located on the host)
    5. The port (only if it isn't the default)
    6. And a username and password used to access the repository.

    The URL will be auto-filled as you enter the other fields. Hit "OK" when all the fields are good and XCode says it can connect.

  2. Then open your project and do a "Get Info" (Round blue icon with an exclamation mark) on the project itself. Under the "General" tab down at the bottom is an option for SCM, select the repository you made in 1 and close the window.

  3. Now open SCM in the menu-bar and go to "Repositories." Hopefully you've built your repository right using branches, trunk, and other directories at the base level because XCode doesn't have support for checking out the root directory. So go one directory at a time down the list and click the "Checkout" button and select a directory to check it out to (I recommend a "Code" or "Source" or "SVN" directory inside your XCode project directory). You cannot checkout multiple directories at once, but you can tell the next directory to checkout before the first has finished and XCode with queue the commands.

  4. Once that is all done go back to your XCode project window and "Add -> Existing Files..." to your project. Select the directory you've checked out the repository to and I recommend using the "Create folder references" option instead of the "Recursively create groups" option because added and removed items will be automatically reflected in a Folder Reference but not in a Group.

Now you've imported your SVN repository into an XCode project. From here any time you make a change, simply Right-Click (Control-Click if you only have 1 button) in the file and at the bottom of the context menu are the SCM options for comparing, committing, updating, and discarding (reverting) the file. You can also use the SCM menu in the menubar for file or project-wide updates/commits/reverts.

Oz.
  • 5,299
  • 2
  • 23
  • 30
5

I know this is not quite what you asked, but I wouldn't rely much on the use of SVN from Xcode as what you can do with it is very limited. It's useful for being able to do a diff or annotate direct from the IDE but not a great deal else. I don't think it's any substitute for using a separate standalone client such as SmartSVN or Versions.

You also have to jump through a number of hoops to get Xcode to work with SVN version 1.5 onwards, so that's something to be aware of before installing a standalone client. If in doubt, check out a sandbox first.

the_mandrill
  • 29,792
  • 6
  • 64
  • 93
  • 1
    Maybe I’m a little fuzzy on what you mean by getting Xcode to work with SVN 1.5 onwards, but my experience has been very smooth. SVN 1.6 comes prepackaged with Snow Leopard, and through the use of just two simple tutorials (http://www.rocxsoft.com/default.asp?W22 and http://iphonedevelopment.blogspot.com/2009/03/version-control-is-your-friend.html) SVN 1.6.2 is talking to Xcode 3.2.1 wonderfully on my machine. I’ve tackled the usual tasks just fine (import, export, commit, update, diff, etc.). It’s just the less common SVN tasks for which I’d like to find an Xcode-centric guide. – Kevin L. Oct 14 '09 at 23:22
  • 1
    I didn't realise that Snow Leopard comes with 1.6. That makes life much easier. If you're using Leopard then you're stuck with SVN 1.4, so then you need to install the OSX build of 10.6 from Collabnet and modify your PATH. To my knowledge, I don't think Xcode has much functionality beyond commit, diff, update, log, etc, and so for other operations such as branching and merging you're best off using a separate client. You can still use Xcode's SVN features while you're using another client, as long as both use the same underlying SVN version (eg SmartSVN 6 = svn 1.6) – the_mandrill Oct 15 '09 at 08:57
  • I haven't seen a specific usage guide for the SVN features of Xcode. I think the limited functionality that exists was sufficient for the Xcode devs to tick a box and say 'yes, it supports SVN/CVS/Perforce'. The functionality is so limited that I don't think there would be a dedicated guide for it (the best I've found is [here](http://developer.apple.com/tools/subversionxcode.html) ). I don't think the intention was for Xcode to be a fully-featured SCM client, rather just to support simple checkout/update/commit workflows. – the_mandrill Oct 20 '09 at 18:24
5

I second the comment by the_mandrill, SVN support from within XCode is very limited, especially if you're used to Eclipse.

I also don't understand why everyone seems to need visual clients. I keep a terminal window open on my project directory and I have no problems interacting with SVN from the command line.

Community
  • 1
  • 1
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
  • I agree. Sometimes people think people who prefer terminals for certain tasks are just being elitist, but it really is a simple process, especially since version control commands are usually relatively simple, it's a lot quicker and easier to keep track of things as your project progresses by using the terminal. – Jorge Israel Peña Oct 13 '09 at 21:32
  • 13
    For simple operations using svn from the commandline is easy enough, but when you want to do things like cherry-pick files for adding to changelists, or do selective commits, or 3-way conflict resolution, or see the branching structure then having a visual client is well worthwhile. AFAIR, I don't think Xcode does any of these, incidentally. – the_mandrill Oct 19 '09 at 21:26
  • 1
    I think there are times when having a visual client is worthwhile but xcode just does not give you any real gains over the CLI. In fact I haven't really found any great GUI clients for svn on the mac (I'd love to be proven wrong). – Nick Van Brunt Oct 20 '09 at 19:55
  • using Terminal isn't "wrong" - but if you want everything in one place, it is – warren Oct 21 '09 at 06:14
  • What do you mean? The terminal makes me run for the documentation often but apart from that its all there. – ruipacheco Oct 21 '09 at 08:31
  • DTerm is a great little "instant command line" utility that's really handy for interacting with SVN/git from inside Xcode. http://www.decimus.net/dterm.php – amrox Dec 07 '09 at 14:54
  • 3
    D*mnit. All those ignor*nts. He asked for a manual of the SCM-abilities built in Xcode, and it doesn't get anyone further if you tell him to use the command line instead. – Akku Nov 15 '10 at 14:01
  • command line is great, we all love it. Visual can be just as good or better. In Eclipse "Synchronize with Repository..." is awesome. Sure there are ways to do it from command line, but I think the visual methods have some power that is often ignored by command line hardliners. – Fraggle Feb 03 '11 at 12:07
  • Woe be to those who update their Mac SVN version. You'll repeatedly get prompted in terminal to upgrade the working copy format and if you do, Xcode will no longer recognize your local project files as an SVN working copy. The terminal option is a less than optimal solution. Perhaps things will get better with Xcode 6. – Phil Aug 07 '14 at 14:21
3

Here is one of the best tutorials to configure subversion in XCode - http://iphonedevelopment.blogspot.com/2009/03/version-control-is-your-friend.html

It also teaches even to create repository in local MAC.

Sagar
  • 3,159
  • 3
  • 29
  • 28
2

if you want to work with svn through a gui interface then i suggest you use eclipse + subclipse plugin (which have more features and much more reliable and easy than svn on xcode)..

you will work in xcode as normal but you will use eclipse only as an svn client (by creating a general project in eclipse and make it points to your xcode project directory )

and here is a tutorial of how to install subclipse

Ahmed Kotb
  • 6,269
  • 6
  • 33
  • 52
2

A lot of people have problems using the build in svn client, especially to get a new project into svn and that it works.

I created a straight foreward tutorial on how to do this, along with a very well known pitfall (works for Xcode up till the latest version of xcode incl. Iphone 4 sdk)

http://www.sodeso.nl/?p=599

ronaldmathies
  • 154
  • 2
  • 6
1

I myself looked up for some good resources and one of the best I've found is a quite recent video from the WWDC 2012 :

Sign in here if it's not already the case : https://developer.apple.com/videos/wwdc/2012/

Then there is a video called :Session 411 - Source Control Management in Xcode

It explains how to use version control both with GIT and Subversion. It's really nice !

Hope it helps!

Andy M
  • 5,945
  • 7
  • 51
  • 96
0

With XCode4 you can perform almost all of your SCM tasks from within the IDE itself, this is a great step forward.

Here is a link to the official guide : http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html#//apple_ref/doc/uid/TP40010215-CH7-SW26

Unfortunately you still have to use the Terminal command line to add a new project to SCM, this is also clearly documented in the link above.

What it does not tell you is that you also need to manually add ignore instructions to your SCM configuration otherwise you are going to end up with user settings and build outputs in your repositories. I am currently figuring out the list and I will update this answer once I have it finalised.

PS : I know this question is quite old now but I have added this for those of you who arrive here looking for answers like I did.

PPS : Terminal command line increases probability of human error, takes longer, is more complex and is less transparent to end users. Overall the omission of being able to add projects to SCM from within XCode is poor design, I expected better from Apple who are usually good at simplifying UI. For the command line fans out there you might feel L337 but try managing a team of programmers and being responsible for their code, command line is not your friend.

Martin Belcher - AtWrk
  • 4,579
  • 4
  • 33
  • 41
  • Re: PPS (Terminal command line): false, false, false, and false. 1. it tells you exactly what you did wrong and command help is available with --help switch, 2. takes less time because it's not driving a memory heavy GUI frontend, 3. it's actually simpler, there is no GUI to hide anything and is always visually consistent, 4. it shows you exactly what it's doing after each command, giving you instant feedback. GUI usually hides this with spinning icon (it's doing something). It's not about being leet, it's about doing things faster and more reliably. – ryan0 Sep 22 '12 at 20:31
  • 2
    Clarify: (1) by human error I do not just mean syntax error (2) When I say takes longer I mean it most people longer to type lines of text instead of clicking a button --------- This could all boil down to person preference. Apple have built a huge success on creating simple GUIs that hide the unnecessary detail and enable humans to not have to think like machines to get things done. IMO a bug free well designed GUI enables humans to work faster and more reliably so it does not matter to me if the CPU has to do more work. That is why I use an IDE instead of text editors and command line tools. – Martin Belcher - AtWrk Oct 03 '12 at 11:20
  • 1
    For anyone still looking for a solution: we have ended up using SmartSVN with KDiff3, once setup these have satisfied our needs very effectively. – Martin Belcher - AtWrk Oct 03 '12 at 11:24
0

As has been mentioned in many other answers, the svn client with Xcode is quite weak (and that is being kind).

Personally, I think that running Eclipse just to get access to a svn client is a bit heavy handed.

I would suggest two answers:

  • Use a dedicated svn client for the Mac (Versions and Cornerstone are both very good, albeit not free... there are free ones, such as svnX)
  • If you are not wildly comfortable with the terminal, you can script a couple of the key commands that you want to use and add them to your Xcode user scripts folder, then you can trigger them from a menu item of from a keystroke, just as if you were using the Xcode native client. There's a ton of examples on how to do this available via Google.
mmc
  • 17,354
  • 2
  • 34
  • 52
0

I came across these - no idea how well they work, but wanted to add some resources if I could:

warren
  • 32,620
  • 21
  • 85
  • 124