XCode Tips And Shortcuts To Improve Your Workflow

Intro

This is my first #iDevBlogADay post and I wanted to give a quick intro before jumping in. My name is Brandon Trebitowski and Iā€™m a software developer and author from Albuquerque, New Mexico. I graduated from the University of New Mexico in 2008 with a bachelors degree in computer science. For the past 2 years, I have been writing mobile applications (primarily for the iPhone) for ELC Technologies.

I also started http://icodeblog.com and currently write on it about once a month.

A Post On XCode Shortcuts?

Well, Iā€™m sure by now, you have seen countless infographics and ā€œcheat sheetsā€ chock full of XCode shortcuts, tips, etcā€¦ These can be great resources, however, if you are anything like me, you see these, tweet the link, and move on never looking at them again. The only difference between these and the XCode key-bindings menu IMHO is a fancy background. So, I thought I would share some of the most important shortcuts that I have adopted to really improve my workflow. We spend so much time inside of XCode, it is worth the time to learn some of these.

Build Commands

By now, I would hope that you donā€™t click the ā€œBuild and Go/Debugā€ with your mouse whenever you want to run your application. If you do, no worries, here are some of the build quick keys.

**āŒ˜ return ā€“ **This builds and launches the application in debug mode.
**shift āŒ˜ return **ā€“ Kills the running application in the simulator.
**shift āŒ˜ k ā€“ **Cleans the build target.
**shift āŒ˜ a ā€“ **Build and Analyze. This is quite possible the most important command to learn. This invokes the static analyzer to help spot memory issues in your code. Run this as early and often as possible.

My general workflow after writing a bit of code is to kill the last run, clean, analyze (hopefully not spend time on memory issues), and then build and debug. These 4 commands in sequence are much faster than searching out the menu items for each of those commands.

File Management and Navigation

Navigating around files is one of the most common tasks you will perform in XCode. It is really to your advantage to speed things up.

option āŒ˜ ā†‘ ā€“ This quickly switches between your .h and .m file.
**āŒ˜ ā†‘ ā€“ **Move to the top of the file
**āŒ˜ ā†“ ā€“ **Move to the bottom of the file
**shift āŒ˜ d ā€“ **This was recently showed to my by @cruffenach and it has drastically sped up my workflow. This is the command for ā€œOpen Quicklyā€. It brings up a small window with a search box at the top. Typing in the box instantly searches your project and allows you to quickly open up files by pressing return on the selected file. I canā€™t believe I had been using XCode for so long before I found out about this command.

Binding Your Own Quick Keys

Some commands simply donā€™t have quick keys. For example, I constantly use the Edit -> Sort -> By Name command to sort my source files alphabetically. By default, you must click through all of the menus and select the command to get it to work. However, XCode (like most OSX applications) will allow you to define your own quick keys and hereā€™s how.

  1. Open up the XCode Preferences
  2. Click on the Key Bindings tab
  3. Navigate to the command that you want to bind keys for. (hint: they are organized the same way they in the top menu)
  4. Once you have found the command, double click in the Key column
  5. Press the keys that you wish to bind (I bound option shift āŒ˜ s for sorting)
  6. If there are any conflicts, XCode will let you know. Otherwise, press apply and youā€™re good to go.

Wrap Up

Well, this concludes my relatively short first post for #idevblogaday. If you have any shortcuts of your own that you canā€™t live without, please share them in the comments. Iā€™m always up to improve my workflow.

Thank you to everyone (especially @mysterycoconut) for allowing me to be a part of this community and I look forward to sharing my knowledge and experiences with you.

Happy Coding!

—-

ļ»æļ»æThis post is part of iDevBlogADay, a group of indie iOS development blogs featuring two posts per day. You can keep up with iDevBlogADay through the web site, RSS feed, or Twitter.



#Articles
Brandon Trebitowski

šŸ’» Software šŸ• Outdoors šŸ  Family šŸƒā€ā™‚ļø Fitness