A Few Xcode Tips

In this post I just want to share a few super useful tips & tricks I’ve learned over time with Xcode.

 Shortcuts

 ⌘+⇧+O

cmdshifto.png

If you don’t know ⌘+⇧+O (Command+Shift+O) then I’m really sorry because life must be hard. This is definitely the very most important shortcut in Xcode. Try it out, ⌘+⇧+O is a magical “open anything” shortcut. It summons a search bar, a little bit like CMD+Space does on Finder and allows you fuzzy-search anything in your codebase. It can find text, symbols, class names, methods, and more. Given it does fuzzy search, if you want to find a class named MySuperCrazyLongNamedViewController you can type something like MSuCrNa and it will find it.

 Mash+U

“Mash” is common language for ⌘+⌥+⌃ (Command+Option+Control). So hitting ⌘+⌥+⌃+U will run all the unit tests in the file current open.

 Mash+G

⌘+⌥+⌃+G will run again whichever was the very last unit test you ran.

 ⌘+⇧+?

Do you want to do something there is no shortcut for? Use ⌘+⇧+?. This will open the help menu and set the focus on the search text field. This search is actually not constrained to help documents at all. It allows you to search for any functionality or menu item of Xcode, and lets you run it from there.

Screen Shot 2018-11-27 at 1.26.19 PM.png

 Don’t Use Tabs

This took me a very long time to find out but essentially: do not use tabs in Xcode. The implementation isn’t great and essentially each tab is a whole different instance of Xcode so it uses a lot of memory and is super slow. If you need to have multiple files open then use the side-by-side viewer.

 Build Phases

buildphases.png

This isn’t as much a general Xcode usage tip but build phases are a way you can run custom scripts every time the app is built / run. It can allow you to do things like automatically incrementing your project’s build number, posting things to API’s, generating code and reports, etc. CocoaPods uses it to check your dependencies for example.

 Schemes

scheme_options_2x.png

Schemes are configuration combos. They allow you to specify what happens when the app is run, built, tested, analyzed, and more, all in one config. Schemes can also be used to specify environment variables, pass arguments to the app, simulate a GPS location, change the locale / language for iOS, and more.

schemes.png

The idea is to be able to have many of these so you can quickly switch to the configuration you want and run or test your app using a ton of presets you’ve configured.

 
3
Kudos
 
3
Kudos

Now read this

A Day At Square

I work at Square as a Senior iOS Engineer and here’s what a typical day looks like for me. Sunrise – 6AM-7:30AM I usually get up at 6am, brush my teeth, feed my pets and jump in my car to get to work around 6:30am. I don’t usually eat... Continue →