FREE: Follow my new 100 Days of Swift challenge! >>

Xcode tips and tricks – part four

Paul Hudson       @twostraws

This is part four of a series on Xcode tips and tricks, this time covering testing, debugging, colors, and more!

  1. Xcode tips and tricks – part one
  2. Xcode tips and tricks – part two
  3. Xcode tips and tricks – part three
  4. Xcode tips and tricks – part four

If you have some favorite Xcode tips of your own, let me know on Twitter!

31. Recent files

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.

32. Multiple cursors

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!

33. View debugging

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.

34. Timing tests

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.

35. Detecting tests

Setting a custom environment variable in your Test scheme allows you to detect when tests are running and create test configurations at runtime.

36. Debug sounds

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.

37. Quick Look

Xcode’s Quick Look system is capable of rendering previews for many data types, including attributed strings, Bézier paths, PDFs, and more.

38. Named colors

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.

39. Refactoring storyboards

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.

40. Build settings

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.

Sponsored You’re already busy updating your app for Swift 4.2 and iOS 12, so why not let Instabug help you find and fix bugs? Add just two lines of code to your project and receive comprehensive reports with all the feedback you need to ship a world-class app – click here to learn more!

 

MASTER SWIFT NOW
Buy Testing Swift Buy Practical iOS 12 Buy Pro Swift Buy Swift Design Patterns Buy Swift Coding Challenges Buy Server-Side Swift (Vapor Edition) Buy Server-Side Swift (Kitura Edition) Buy Hacking with macOS Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with Swift Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

About the author

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 Mario Kart world champion. OK, so that last part isn't true. If you're curious you can learn more here.

Was this page useful? Let me know!

Average rating: 5.0/5

Click here to visit the Hacking with Swift store >>