Xcode is the most famous IDE for native iOS development. As developers, we use it on daily basis. Some of us love it, others hate it. Nevertheless, it’s worth spending some time to brush up our Xcode skills and make us more productive. In this post, I would like to share some tips and tricks, which helped me a lot.
Every IDE has a lot of shortcuts. Here are some, which I find most useful during my everyday work. Some of them might be obvious for you but I would still recommend reading the whole article. Maybe you will learn something new which will boost your productivity.
Open quickly ⌘⇧O
If I had to choose the most popular shortcut, it would be Open quickly. You can search for anything in your project or even in all Apple’s public headers. It’s worth remembering that you don’t need to write consecutive letters. It’s enough to give them in a correct order.
Reveal in Project Navigator ⌘⇧J
Imagine you work on a big project. You found a file with Open quickly and now you want to add a new file in the same Group. But how to locate it in the Project Navigator? Just press ⌘⇧J and it’s done!
Searchable Menus ⌃6
Now you try to find a particular method in a Massive View Controller. You can search for a text with ⌘F but it’s easier and more practical to press ⌃6 to show a view with listed properties and methods. The great thing is that you can immediately start typing and filter the results.
Documentation Generation ⌥⌘/
To easily generate a documentation select a class or a function name and press ⌥⌘/ shortcut.
Switch between the header and implementation file ⌃⌘ Up/Down
This one is useful only if you write in Objective-C. While writing in this language we need to switch back and forth between headers and implementation files. Frankly speaking, pressing ⌃⌘ Up/Down is one of my favourites shortcuts and it saved me a lot of time.
Xcode has many features which are difficult to find. Even very experienced developers don’t know many of them. Here are two which I use the most during my daily work.
Find callers and callees
This is a very efficient way of finding usages of the function. I like it much more than using regular search in the whole project. I remember that one day this feature worked only for Objective-C. Apple apparently implemented it also for Swift(available from Xcode 7.3). To find callers or callees click on a little box just above the line numbers.
Show recent files
Do you work on a big codebase? Usually, we don’t need to see the whole structure of a project. It’s totally enough to keep track of recently seen files. Just use the hidden button at the bottom of Navigator.
Xcode has some crucial debugging tools which make our life easier. Even small things can simplify bug hunting. Sometimes I wish I knew some of them when I started iOS development.
Everyone programmer knows how to use breakpoint. But what I wanted to say is that Xcode provides great tools for breakpoint edition. Right click on a breakpoint and choose Edit breakpoint from the menu. Now you can set some actions like Log Message, Debugger Command or even Sound. It’s worth mentioning that there’s an option to continue after evaluating an action. It’s useful for example in printing variable to the console. And it’s much better way than modifying source code by adding
Sometimes we log a lot of messages during the app execution. It’s possible to print only debugger output by setting the proper option at the bottom of the console.
There is a cool tool developed by Facebook: Chisel. It’s a collection of LLDB commands to assist in the debugging of iOS apps. For example, it allows to visualise a view in Preview.app, print view controller hierarchy, show/hide a given view/layer and much more. I highly recommend trying it out!
What is your favourite feature?
I hope you learnt something new from this post. I showed what I use during my daily work. Even though Xcode has many features and shortcuts, I wanted to create a short list of things which make me more productive. I am sure it is not a complete list, so please let me know in comments what is your favourite feature!