Learn useful Xcode features with short videos.
This is part four of a series on Xcode tips and tricks, this time covering testing, debugging, colors, and more!
If you have some favorite Xcode tips of your own, let me know on Twitter!
The two Xcode shortcuts I use by far the most are Ctrl+Cmd+Left and Ctrl+Cmd+Right, which move back and forward between your recently opened files. Bonus: use Ctrl+2 or Ctrl+3 to show these files as a menu you can browse through.
If you hold down Option and drag over a column of text, you can make edits in multiple places at the same time. Bonus: Ctrl+Shift+Click lets you place new cursors at specific points!
If you have selected a view in the view debugger, you can press Shift+Cmd+D to highlight it in the debug navigator. You can also type a class name or a view’s label into the filter box to show only matching views.
Slow unit tests make it hard to run our tests frequently. Fortunately, Xcode’s Report navigator can identify slow tests so they can be optimized or moved.
Setting a custom environment variable in your Test scheme allows you to detect when tests are running and create test configurations at runtime.
When working with invisible components such as network requests, you can use breakpoints to play sounds when they succeed or fail – it’s a smart way of helping you track what’s going on.
Xcode’s Quick Look system is capable of rendering previews for many data types, including attributed strings, Bézier paths, PDFs, and more.
Creating named colors in your asset catalog lets you load that shared color in code using UIColor(named:), or in Interface Builder’s color selection box.
If you have one storyboard that’s grown too big, you can select view controllers inside it and choose "Refactor to Storyboard" from the Editor menu. This will pull them out into a new storyboard with references back to the old one.
If you’re not sure what one of Xcode’s build settings does, just hold down Option and double-click for an explanation. Alternatively, select it and open the Quick Help inspector.
Paul Hudson is the creator of Hacking with Swift, the most comprehensive series of Swift books in the world. He's also the editor of Swift Developer News, the maintainer of the Swift Knowledge Base, and a speaker at Swift events around the world. If you're curious you can learn more here.
Link copied to your pasteboard.