Snapshots in Xcode

When writing code, I usually write code in an incremental fashion. I try to get one set of functionality to work before I start on the next set. Due to this, I frequently create incremental backups of my files/project before I begin the next set of major changes or mass edits. This allows me to come back to a clean and consistent state if I ever need to.

I typically don’t work on a private branch, so I cannot check in my code until I am reasonably done. To create temporary incremental backups, I usually just end up making copies of my project folder.

Xcode has a handy feature called Snapshot that let’s you create a safety net before you make any major or risky changes to your files. Go to File->Make Snapshot (shortcut: command-control-s), and Xcode remembers the state of the project.

Screen shot-1.png

Now we are free to make changes to the source files all we want. If we need to return to the previous state we use the snapshot window. This window can be invoked from File->Snapshots

Screen shot-2.png

Simply select the snapshot that you want, and press the Restore button. Xcode automatically creates another snapshot when you restore to an older snapshot, which allows you to jump back and forth between two different versions of the project. Pretty useful!

Snapshots are stored in a disk image that lives in ~/Library/Application Support/Developer/Shared/SnapshotRepository.sparseimage

About these ads


Filed under Tools, Xcode

5 responses to “Snapshots in Xcode

  1. Pingback: Snapshots in Xcode


    really useful tips

  3. is there a way to configure xcode for an automatic snapshot say like every time i hit run?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s