Xcode Local History


I found a hidden (gem) feature in Xcode today out of desperation. As I find myself bouncing from Intelli *Ahem* Android Studio to Xcode I often miss features from the former IDE. Hi, I’m Cliff. You’re here because you screwed up a source file and need to recover. Your project was probably completely functional but then you made some random edits and now you cannot figure out which change broke which thing. Don’t commit often? Then you probably have this problem frequently.

The way out lies in a hidden feature of Xcode, something we Java lovers have been spoiled by for years… Local History! That’s right, Xcode actually auto-saves revisions of your files as you work the same way Eclipse and the IntelliJ platforms do. The only wrinkle is that while Xcode does maintain a local history there is no history viewer in the IDE. The trick is to open the source file in TextEdit then click “File -> Revert to -> Browse all revisions” from the menu bar. You will be dropped into a Time Machine like interface for the current file where you can cycle back through the various edits. This interface, though more dramatic than what you find in the Jetbrains suite of tools is not as functional. For example, you cannot see a record of when tests passed or failed, only time stamps. Also, lacking a hot-key trigger, it requires 3-4 steps to coordinate. You must right click inside the source file in Xcode, choose “Reveal In Finder”, drag/drop the file into he TextEdit icon in the dock, optionally open TextEdit if you don’t have it pinned, then do the file menu dance. Still it is an incredibly useful tool which just might save my bacon today since I changed something and can’t figure out what it was.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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