11 Comments

Summary:

If you are planning on getting started in developing for the Mac, one of the first things I recommend setting up is a version control system. Beanstalk is a hosted Subversion system, so you can access your code from anywhere you have an Internet connection, team […]

If you are planning on getting started in developing for the Mac, one of the first things I recommend setting up is a version control system. Beanstalk is a hosted Subversion system, so you can access your code from anywhere you have an Internet connection, team up with partners across the world, and keep a safe copy of your code off site, just in case. It’s tempting to rely on Time Machine for the ability to roll back changes, but Subversion has some key differences that make it a clear winner in ease of use and features.

For one, you can host a Subversion repository anywhere, either locally on your own Mac, or on the Internet, or on your local private network. Second, Subversion is built to work with multiple users, and can handle conflicting commits to the repository. Finally, Subversion can integrated directly into Xcode, which is what we are going to look at here.

Setup Beanstalk

To start, first head over to Beanstalk and create an account. Since I’m only ever working on one project at a time, the free hosting works fine for me, but there are also for-pay plans depending on your needs. Once you have the URL for your repository, it’s time to make some changes in Xcode. I’ll assume that you already have a project that you want to work with, and some code that you are ready to back up.

Setup Xcode

In Xcode, select “SCM”, and “Configure SCM Repositories.” Click on the + button towards the bottom left and add a name for the repository, and select “Subversion” as the SCM System. Add your custom URL. It will look something like this:

http://username@username.svn.beanstalkapp.com/projectname

Where username is your Beanstalk user id, and projectname is the name of your first project. Enter in your password at the bottom, and the red error jewel at the bottom should go green and say "Authenticated." Now that you have your repository set up, it's time to add your project to it.

Adding Your Project

Open your project, and again go to the SCM menu. This time there should be a new menu option: "Configure SCM for this project," select that. This will bring up the info window for your project. At the bottom of the "General" tab, change the SCM Repository selection from "None" to your newly created Beanstalk repository. Close the info window, and go to the SCM menu item again, you should see several more options there. Go down to the bottom and select "Commit Entire Project." This will upload the project into Beanstalk and set up your project for source control. Once that is finished, it's time to test it out.

Testing Things Out

Change one of the source code files in your project and save it. You should see a capital "M" (for Modified) in the far left column next to the "Groups and Files" area of Xcode. Right click on the file that you changed and select "Compare." This will compare the change you just made with the most recently committed change in Beanstalk. If you are happy with the change, you can select "Commit Changes" from the SCM menu item. You should see the "M" disappear.

If you've made some changes that didn't quite turn out the way you expected, it's easy to roll back to a previous commit. Just select the file that you need to roll back, go to the SCM menu and select "Update to" and "Revision...". This will let you select which version of the file you'd like to roll back to.

Using Subversion you can keep a detailed record of all the changes you make to a project as it progresses. Using a hosted service like Beanstalk ensures that you can recover from a hard drive failure or other catastrophe with very little effort. We have only just scratched the surface of Subversion, but by now you should be able to set up a repository, add your project to it, and commit and compare changes.

  1. Excellent article; worked like a charm. I had the folks at Beanstalk link to your article from their site.

    Share
  2. doesn’t work for me if i don’t import the project directoy manually first..

    Share
  3. Sebastian Bachmann Wednesday, February 18, 2009

    hello,

    i follows your instructions but by the “commit your entire project” step i get the following error
    Error: 155007 (Path is not a working copy directory) Description: ‘/Users/sebastian/Code/ectsPlanner’ is not a working copy

    running Xcode 3.1.2

    regards,
    sebastian

    Share
  4. i did the first commit/import with the terminal svn
    svn import /path/to/project http://username@username.svn.beanstalkapp.com/projectname -m “Initial import”

    Share
  5. yeah, worked! thx!

    Share
  6. I’m having the same issues, i’ve uploaded the project manually and then xcode gives the same error. Do I have to setup the correct directories first in subversion manually, trunk, tag and the like? also when uploaded manually my project files are seperate, not in the class directories/groups that I have assigned in xcode? cheers Bug

    Share
  7. Here’s what I did to get it working properly (I’m a noob so this is probably wrong):

    0. Setup the xcode SCM settings as in the article,
    1. Renamed my xcode project folder (eg sample_app -> sample_app_up),
    2. Imported to svn using the svn import @yene provides in comment #4,
    3. Open xcode > SCM > Repositories > Check out to “sample_app” folder
    4. Profit!

    Share
  8. Ben Thank you. I did the same and it worked for me.

    Share
  9. “Commit Entire Project” is designed to upload changes in the project. To first import the project go to menu SCM -> Repositories , choose your repository and press the big button “Import” on the top left. However, intuitively :) ?

    Share
  10. Whoops.
    Just as an FYI, when you use the big IMPORT button it brings up a folder view and asks you to select the folder to import. By default, or at least in my case, it defaulted to the Users directory. Since I work in both a Windows and Mac world I mistakenly double clicked on Users (to open it)… I’m still waiting for it to finish import the GBs of files in the Users directory so that I can just delete it and do the right things this time. Unfortunately there does not appear to be a way to stop the Import. Live and learn but hopefully this will help someone else avoid making this mistake.

    Share

Comments have been disabled for this post