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.
The Snapshots Window
Making Snapshots
Comparing Snapshots
Restoring Snapshots
Deleting Snapshots
Rooting Snapshots
The Snapshots window (Figure 3-1) is where you view your project’s snapshots.
The Snapshots window contains the following items:
Snapshot list. Lists the snapshots accessible to the project, which is determined by the project root (see “Managing Source in Xcode” for details about the project root).
Name. The name of the snapshot. Xcode automatically names snapshots based on where you perform the Make Snapshot command.
Date. The date the snapshot was taken.
Archive. The filename of the snapshot.
Comments. Comments you add to the snapshot.
Changes pane. The differences between a file in the selected snapshot and the file in the project or another snapshot.
To make a snapshot, choose:
File > Make Snapshot
You may want to change the snapshot name to reflect special circumstances.
To change the name of a snapshot:
In Snapshots window > Snapshot list, select the desired snapshot.
In the Name text field, enter the new name for the snapshot.
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.
To restore the project to the state represented by a particular snapshot:
In Snapshots window > Snapshot list, select the snapshot to restore.
Click the Restore button in the toolbar.
To restore a single file in a snapshot:
In Snapshots window > Snapshot list, select the desired snapshot.
In the file list, select the file to restore.
Click the Restore button.
To restore a single change instead of an entire file:
In Snapshots window > Snapshot list, select the desired snapshot.
In the file list, select the desired file.
In the changes pane, copy the text to restore.
Open the file onto which you want to restore the copied text.
Paste the text in the appropriate location, and save the file.
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:
In Snapshots window > Snapshots list, select the snapshot you want to delete.
In the toolbar, Click the Delete button.
To delete a snapshot store:
Quit Xcode.
In the Finder, navigate to the directory that contains the snapshot snapshot store (see “Snapshots” for details).
Delete the SnapshotRepository.sparseimage
file.
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.
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)