Moving Xcode 3 Snapshots to Subversion

When starting my first iOS app I just played a bit with Xcode and suddenly I had created something nice I wanted to keep and build upon. Naturally I didn’t care about version control because coding was more fun and I would have used trunk for the initial version after all. My punishment for neglecting a source control system is writing this post to remind me of using version control for every project with more than two files straight from the beginning.

Instead of Subversion I used Xcode 3 snapshots to at least save a working state before doing some refactoring and trying something new. (See, my subconscious felt guilty for not using a versioning system.)
Now that I’m switching to Xcode 4 I’m also finally moving my sources to Subversion. I want to keep the snapshots but Xcode 4 has another snapshot format. So the logical thing to do is importing my old snapshots as revisions into Subversion. This post describes how to achieve exactly this.

You should be (at least a bit) familiar with Xcode, Subversion, the shell, etc. to do this.

Step 0 — Make a last Snapshot

Create one last Snapshot in Xcode 3 and close the IDE.

Step 1 — Create SVN Repository

Create a Subversion repository in your preferred location, for example: svnadmin create /Users/USERNAME/Development/SVN/PROJECT

Step 2 — Initialize your Repository

Create your directory structure in the newly creates Subversion repository (trunk, branches and tags directories).

Step 3 — Get

Download and store it on your Mac.
I had to set the $svn variable at the top of the script to the location of my svn binary.

Step 4 — Locate the Snapshots

Xcode 3 stores the created snapshots in an image file. You can find the SnapshotRepository.sparseimage in /Users/USERNAME/Library/Application Support/Developer/Shared. Double click to mount it. Locate your Xcode project in the ArchivedDirectories directory on the Snapshots volume. Copy the directories named something like 2011-01-23 13/01/19 +0100 from /Volumes/Snapshots/ArchivedDirectories/PROJECTNAME/ to a folder (CopiedSnapshots) on your desktop.

Now is the time to remove snapshots you don’t want to import into Xcode or remove files you don’t want. (Like temporarily renamed files, etc.)

Step 5 — Import the Snapshots

Now you can put to good use. If you want different commit messages for every snapshot, you have to manually add every snapshot’s content to Subversion. I’m fine with the same message for every version of my initial import.

Change to the directory containing your snapshots: cd ~/Desktop/CopiedSnapshots/
Then run this command (one line):

ls -1 . | /PATH/TO/SCRIPT/ -no_user_input -message "Initial import of Xcode created snapshots." file://localhost/Users/USERNAME/Development/SVN/PROJECT/ trunk/

What this command does:

  • ls -1 . — lists all directories containing your snapshots
  • | /PATH/TO/SCRIPT/ — use the listed snapshot directories in the script
  • -no_user_input — required when reading the directories from stdin
  • -message "some message" — your commit message
  • file://localhost/Users/USERNAME/Development/SVN/PROJECT/ — the location of your repository
  • trunk/ — store the imports on the trunk

Step 6 — Configure Xcode for SVN

All that is left is to configure Xcode to use your Subversion repository.

See the for more info on your new favorite IDE.

tags: , , , ,

Leave the First Comment!

313 posts. 18 pages. 423 comments. 53 categories. 28 queries. 0.216 seconds.
Blog © 2005-2014 Daniel M. Gattermann. Logos, trademarks, etc. © by their respective owners.