Seven Xcode Tricks Every Developer Should Know

Download Your Free Copy of
The Missing Manual
for Swift Development

The Guide I Wish I Had When I Started Out

Join 20,000+ Developers Learning About Swift Development

Download Your Free Copy

To be productive and efficient, you need to know your tools. For a Swift developer, that means mastering Xcode. While Xcode is a complex piece of software with a fairly steep learning curve, the tricks I show you in this episode should significantly boost your productivity.

1. Open Quickly

The Open Quickly command can be found in Xcode's File menu. The keyboard shortcut, Command + Shift + O is much more convenient, though. The command brings up a modal that enables you to search for pretty much anything, including files, types, methods, functions, and properties.

Open Quickly Is an Essential Command to Be Productive in Xcode

This command saves me time each and every day and it is an order of magnitude faster than browsing the project using Xcode's Project Navigator. The Open Quickly command supports multiple editors. Search for a symbol, press Option, and hit Return to open the file in a new editor. If Open Quickly is new to you, then I strongly recommend giving it a try.

2. Reveal in Project Navigator

The Reveal in Project Navigator command is a true timesaver for large, complex projects with lots of files and folders. The command shows or reveals the current file in the Project Navigator on the left. The default key binding is Command + Shift + J.

3. Assistant Editor

You are probably already familiar with Xcode's Assistant Editor. You can open the Assistant Editor by choosing Assistant from Xcode's Editor menu or by using its keyboard shortcut, Control + Option + Command + Return.

Most developers leave the Assistant Editor underused, though. It is great for showing the counterpart of a file or for simultaneously working on the user interface and implementation of a view controller.

The Assistant Editor has a lot more uses, though. I use it often to find out where or how often a particular method is invoked. Place your cursor in the body of a method and select Callers from the Assistant Editor's menu at the top.

The Assistant Editor is a powerful, but underused, tool.

4. Jump to Document Item

When I am working in a large document, I often have the need to quickly jump to a particular item in the document. Searching for a method or property in a large document isn't efficient. The Show Document Items command is faster and more efficient. Press Control + 6 to bring up the Show Document Items command. Type the first few letters of the item's name and hit Return to jump to the item.

Jumping Quickly to a Method

As the name suggests, the Show Document Items command can be used to jump to any item in the document, such as properties and methods as well as MARK, TODO, and FIXME comments and extensions.

5. Browse Documentation and Jump to Definition

No matter how experienced you are, the documentation is a developer's best friend. To quickly open Xcode's documentation browser and search for a particular symbol, press Option and click the symbol you are interested in.

While the documentation is a good starting point, it can sometimes be more helpful to jump to the symbol's definition. Press Command, click the symbol, and choose Jump to Definition from the contextual menu.

Because I use the Jump to Definition command so often, I made that the default behavior when Command clicking a symbol. This is easy to set up in Xcode's preferences. Click the Navigation tab at the top and set the Command-click on Code preference to Jumps to Definition.

Xcode's Navigation Preferences

6. Edit All in Scope

Multiple cursors are great and every modern editor should include this feature. Xcode's code editor also includes this feature, but it is difficult to find and hard to use. In Xcode, the feature is better known as Edit All in Scope.

There are several options to use Edit All in Scope. The first option is a bit tedious. Place your cursor on the symbol and choose Edit All in Scope from Xcode's Editor menu. The second option is pressing Command, clicking the symbol, and choosing Edit All in Scope from the contextual menu. The third and most efficient option is placing your cursor on the symbol and pressing Control + Command + E.

Unfortunately, Xcode's implementation of multiple cursors is not as powerful as that of Atom, Sublime Text, or Visual Studio Code. Xcode only supports multiple cursors for symbols.

7. Authors/Git Blame

A few years ago, Apple renamed Git's blame command to Authors. The idea remains the same, though. To bring up the Authors panel, click the Adjust Editor Options button in the top right of the editor and choose Authors from the menu. Another option is pressing Control + Shift + Command + A to show or hide the Authors panel.

Thanks to Xcode's improved Git integration, you can use the Authors panel to show the commit or open the commit in Xcode's Code Review editor. These options are helpful to find out when a line of code was changed, who changed it, and which pull request included the change.

Use Git Blame to Reveal the Culprit

Favorites

Xcode tricks may seem unimportant, but I can assure you that spending a few minutes learning the tricks in this episode can significantly boost your productivity in Xcode. I always keep my eyes open for tips that can save me time and frustration.

Download Your Free Copy of
The Missing Manual
for Swift Development

The Guide I Wish I Had When I Started Out

Join 20,000+ Developers Learning About Swift Development

Download Your Free Copy