Working Efficiently with Xcode

Session 402 WWDC 2012

Xcode delivers a wealth of features to help you be more productive than ever before. Join engineers from the Xcode team as they teach time-saving tips and demonstrate workflows geared toward the power user, to help you work faster and more efficiently.

My name is Brooke. I'm an engineer an the Xcode team.

This session is about how you can most efficiently work with Xcode.

Xcode supports wide variety of working styles.

When we were designing Xcode, we knew that different engineers wanted to use our tools differently.

So in this session we would like to show you three different ways to use Xcode.

First I'll show you my single window workflow.

After that Kelly will come up and show you her workflow using tabs and behaviors.

And finally Chris will come up and show you his keyboard centric workflow using multiple windows.

All right. So, let's look at how I use a single window.

Xcode tries to automatically show you just what you need in time, or whatever your current activity is.

But sometimes you wanna show or hide parts of the window yourself.

So it can ??? the keyboard shortcuts.

After look at that, we'll see how you can find and open content in the editor.

And then we'll look at some source editor tips and tricks.

All right. So let's see a demo. So, I gotta bug to fix.

But the first thing I notice here is that I got the utility area open and know I'm not gonna need it, 'cause I'm just doing some source editing.

So, I can hide that with this button up here.

But there's also a keyboard shortcut I like to use: command + option + 0 And if I want even more space for the editor, I can hide the navigator area with command + 0 But let's bring that back for now.

So, in my bug I got a crash in the app delegate.

So, I'm just gonna click down here and type “appdel” and there's my app delegate.

But actually, my crash report says what method I'm crashing in.

So, instead I'm gonna use “Open Quickly” command + shift + … — bring that up with command + shift + 0 — that's not right — command + shift + O and type in the name of that method: “saveContext” “Open Quickly” is really powerful and actually kind of forgiving.

It'll find files and symbols both, in my project or in the SDK.

And often I don't even need to type the name of what I'm looking for correctly.

So, now that it's found the method I'm looking for, I'm just gonna hit return And it shown me the symbol I'm looking for.

So, what you just saw, is an example what we call “navigation”.

Navigation is the active opening a document, or a specific location of a document in the editor.

So, on to my bug: I seen here it looks like we're calling abort(). That's probably why we're crashing. And must be from the save error.

I've even got a comment here telling me that I need to fix the bug here.

Well, I wonder, I wonder if NSManagedObjectContext has another save method, that might deal with the error for me.

So, I'm going to jump to the definition of the save method in the assistant editor by holding on command + option and clicking on it.

So, now I can … so, that's brought up NSManagedObjectContext in the assistant editor, so I can use this as a reference while I'm still looking at my primary document that I'm working on.

And this is what we call “modified navigation”.

By … normally … if I do command + click on the save method, it would open up in the primary editor.

But in this case — by holding down option — I jumped to definition in the assistant editor instead.

So, looking around in NSManagedObjectContext I see there's no other save method, so that's not gonna help me.

But there's something else I can try.

Maybe I could — instead of fixing the here — I might try pushing the error on to the callers instead.

So, if I click on the assistant editor category popup here, I see one of the new categories in the latest version Xcode is Callers. I'll select that and I see there are three different callers and there actually right here and none of them are doing any other error handling.

So that's not gonna help me either.

All right, so I'm done with the assistant editor for now. I'm just gonna put that away with command + return All right, so clearly I'm not gonna fix this bug ???

Instead I'm just gonna make this comment to TODO to make it a little bit more obvious and you can see when I did that it made … it promoted that comment into the function pop up.

As you know the function pop up'll show you all the symbols in your document.

But you can also annotate the function pop up with TODOs, pragmas — like this one here —, or FIXME comments, like this one down here.

Another feature the function pop up you might not know about, you can actually search in it.

So, if I type “Application”, it'll show me just the matching entries in the pop up and I can just click to navigate to one of those.

Another way I like to use the function pop up is with the keyboard short cut: I can use … I can just press control + 6 to bring it up, arrow up to the method I'm looking for and hit return and I'm there.

All right, actually, I remember earlier I was in this file and I saw there's a really messy list of imports and I like to clean that up.

And I'm gonna do this using Mac OS X's text services.

Mac OS X has powerful text services that are … and since Xcode is … Xcode like any Cocoa application can take advantage of these for free.

Apple, Inc. AAPL
1 Infinite Loop Cupertino CA 95014 US