UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Xcode tips and tricks – part one

Learn useful Xcode features with short videos.

Paul Hudson       @twostraws

This is part one of a series on Xcode tips and tricks, this time covering faster testing, generating, interfaces, identifying constraints, 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

Xcode is a fantastic tool, but it’s so big it can be hard to keep track of all the things it can do. To help resolve that situation, below you can find a selection of Xcode tips and tricks that you might find useful. If you have some favorite Xcode tips of your own, let me know on Twitter!

Hacking with Swift is sponsored by Proxyman

SPONSORED Proxyman: A high-performance, native macOS app for developers to easily capture, inspect, and manipulate HTTP/HTTPS traffic. The ultimate tool for debugging network traffic, supporting both iOS and Android simulators and physical devices.

Start for free

Sponsor Hacking with Swift and reach the world's largest Swift community!

1. Regex searching

Xcode lets you search through your project using regular expressions. To try it out, go to the Find navigator, click Text, then choose Regular Expression. Now you can search and replace code using whatever regex you like.

2. Faster Testing

When using TDD you can work more quickly by running a subset of tests – press ⌃⌥⌘G to re-run only your last test, or ⌘-click several tests to run only them.

3. Layout stress testing

When using IB in the assistant editor, change Automatic to Preview then change the language from English to Double-Length Pseudolanguage. This will cause every word in your UI to be repeated, letting you make sure it all fits.

4. Opening Xcode

If you’re in a folder that has both a workspace and a project, use “xed .” to open the workspace in Xcode. If there were only a project, that would have been opened instead.

5. Generated interfaces

If you're looking at a Swift data type and just want a summary of what it does, press ⌃⌘↑ to have Xcode generate an interface showing only its external properties and methods.

6. Filtering the jump bar

If you find Xcode's jump bar a little long, try filtering it. After pressing ⌃6 to bring up the jump bar, you can start typing a few letters to filter all your properties and methods using a fuzzy search.

7. Clearing up space

If you’ve been using Xcode for a few years, you should run “xcrun simctl delete unavailable” to remove any old simulators that are no longer supported. It's common to save 20-60GB with that one command!

8. Watchpoints

When your program is paused, right-click on a variable and choose Watch. The next time that variable changes, you can step back one frame to see where it happened.

9. Identifying constraints

It’s common to see lots of output in Xcode’s log when you have an Auto Layout problem, but if you add identifiers to your constraint you’ll get more helpful messages – easy to do in both Interface Builder and code!

10. Measuring build time

If you've ever wondered how long it takes for Xcode to build your project, you can find out with one Terminal command.

Hacking with Swift is sponsored by Proxyman

SPONSORED Proxyman: A high-performance, native macOS app for developers to easily capture, inspect, and manipulate HTTP/HTTPS traffic. The ultimate tool for debugging network traffic, supporting both iOS and Android simulators and physical devices.

Start for free

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

Average rating: 5.0/5

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.