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.
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” is common language for ⌘+⌥+⌃ (Command+Option+Control). So hitting ⌘+⌥+⌃+U will run all the unit tests in the file current open.
⌘+⌥+⌃+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.
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.
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 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.
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.