< Previous PageNext Page > Hide TOC

Snapshots

Xcode Snapshots allows you to save project state at particular points in time, which you can restore entirely or partially at a later point. Snapshots provide a multifile undo/redo mechanism that lets you experiment freely with your source files. The changes you make can be easily reverted by restoring your project to a snapshot you made before the experiment

A snapshot stores the state of a directory tree at the time it was taken.

At any particular time, a project can access only one snapshot store. A snapshot store is the set of snapshots taken from one or more projects with the same project root. (See "Managing Project Information" in Xcode Project Management Guide to learn how to set a project’s project root.)

Xcode stores snapshots in your home directory:

~/Library/Application Support/Developer/Shared/SnapshotRepository.sparseimage

The following sections show how to use locally stored snapshots to manage changes to multiple files.

In this section:

The Snapshots Window
Making Snapshots
Comparing Snapshots
Restoring Snapshots
Deleting Snapshots
Rooting Snapshots


The Snapshots Window

The Snapshots window (Figure 3-1) is where you view your project’s snapshots.


Figure 3-1  Snapshots window


The Snapshots window contains the following items:

Making Snapshots

To make a snapshot, choose:

You may want to change the snapshot name to reflect special circumstances.

To change the name of a snapshot:

  1. In Snapshots window > Snapshot list, select the desired snapshot.

  2. In the Name text field, enter the new name for the snapshot.

Comparing Snapshots

When you select a snapshot in the Snapshot window, the changed file lists shows the differences between the snapshot and the current state of the project. That is, Xcode compares the snapshot against the project.

Sometimes you may need to know what changed between two snapshots. You can view the differences between two snapshots by selecting them in the snapshot list.

Restoring Snapshots

To restore the project to the state represented by a particular snapshot:

  1. In Snapshots window > Snapshot list, select the snapshot to restore.

  2. Click the Restore button in the toolbar.

To restore a single file in a snapshot:

  1. In Snapshots window > Snapshot list, select the desired snapshot.

  2. In the file list, select the file to restore.

  3. Click the Restore button.

To restore a single change instead of an entire file:

  1. In Snapshots window > Snapshot list, select the desired snapshot.

  2. In the file list, select the desired file.

  3. In the changes pane, copy the text to restore.

  4. Open the file onto which you want to restore the copied text.

  5. Paste the text in the appropriate location, and save the file.

Deleting Snapshots

From time to time, you may want to prune a snapshot store. You can do this by deleting individual snapshots or deleting the snapshot store.

To delete a snapshot:

  1. In Snapshots window > Snapshots list, select the snapshot you want to delete.

  2. In the toolbar, Click the Delete button.

To delete a snapshot store:

  1. Quit Xcode.

  2. In the Finder, navigate to the directory that contains the snapshot snapshot store (see “Snapshots” for details).

  3. Delete the SnapshotRepository.sparseimage file.

Rooting Snapshots

When you create a project, its project root is set to the project directory. This works out well in self-contained projects (that is, projects that build an entire product and are not part of a larger project). But in projects that compose a larger project, you should set the project root at a directory that contains the subprojects. (This directory doesn’t have to contain all of the larger project’s subprojects, only the subprojects that you modify.) Following this practice avoids snapshot conflicts with files shared by more than one project.

Important: Changing the project root establishes a different snapshot store for the project. The previous snapshot store, while not removed from the file system, is not available in the Snapshots window.



< Previous PageNext Page > Hide TOC


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.