Developing Your App with Xcode 4

Session 308 WWDC 2010

Xcode 4 contains powerful new features, and subtle refinements, to make you and your team more productive. Discover improvements in the editor, new ways to structure your projects, and how to use source control directly within Xcode, to produce better apps, faster than ever before.

Kerry Hazelgren: Good afternoon!

This is Developing Your App with Xcode 4 and I am Kerry Hazelgren.

Helps to show that.

So today, as you've probably seen by now, Xcode 4 is a pretty major redesign of the product and my team in particular one of the things we've focused on is the workflow of editing source code.

Editing, maintaining, debugging, anything to do with your source code, the whole workflow.

Those are some of the things that we looked at in the new design and some of the primary goals that we had were better navigation, smarter navigation to provide more information and more accurate information.

Overall basically to make you more efficient when you're doing your developing.

Some of the things we'll talk about today, if you were in the intro session just before us, you may have seen some of these things introduced.

We'll go more into detail on them.

They got to go first so they kind of got to seal our thunder but their demos crashed so.

[ Laughter ]

I'm pretty confident that ours won't but with fingers crossed.

We'll start talking about source control.

Now, don't leave.

I mean, I know it's normally not a very interesting topic but in Xcode 4, I think we've done, we've done a lot to make it interesting and I think we are doing some innovative new things.

We'll also talk about the Source Editor and improvements that we've made there.

Find/replace when you want to do large scale changes to your source code and off with the version editor which really shows the polish of the STM integration so, we're going to be pretty demo heavy today.

We're not going to have a lot of slides because I think it's best to actually show you so, I'm going to get over to a demo here.

OK, so here I am with Xcode and I want to start working with a project.

I've got a project here that I checked out from its old version repository but I did that on another machine and I copied it over here and I don't have that repository information configured in Xcode.

Normally, you have to go to repositories and set that all up and type in these long URLs which I don't like to do, and let me just verify that I don't have that by going to the repositories pane in the organizer.

You can get there by going to the Window menu and coming down to Organizer.

And here's my repository's pane, nothing there.

So, what am I going to do?

Well, in Xcode 4, all I have to do is open the project.

Now, if I can see in just second if the network's cooperating, there we go.

We're already getting status information.

So, how is that possible?

Well, in Xcode 4, if I go back to the repository viewer, you can see, it's been configured automatically for you.

So, all I have to do really is, let Xcode take care of it but that's aversion.

What about Gits?

How many people out there use Git?

Quite a few.

[ Applause ]

Quite a few.

Git is the new hotness.

[ Laughter ]

It is. So, what I want to do is get a Git project and I'm going to do that by going to GitHub.

Now if you're not familiar with GitHub, it is a website which hosts Git repositories of open source software.

Now, there's one repository in particular that I'm interested in.

It is called Handshake, it's an iPhone application.

So what I'm going to do is just take this URL here and copy it and then I'm going to come back to Xcode and add this, type in the name Handshake and paste the URL, here we go, and click At.

Now, the only thing we really did there was just was add a bookmark to that repository.

But once I have that down here, I can click this Clone button in the Toolbar to clone that repository and I will choose a location and hit Clone and it's going to start checking it out and when it's done, it senses that there's an Xcode project in there and all I have to do is hit Open.

[ Applause ]

So it's really easy to use GitHub with Xcode to check out or rather clone projects and start using them.

Now, before I begin to edit this project, I'm just going to give it a quick build so that I know if I introduce any changes.

It looks there are a few issues with this project but they're not mine, I'm not going to worry about them and we can see the nice new activity viewer here in Xcode showing us our progress and the app comes up and launches just fine.

Great! So it's a good starting point.

We're going to begin to edit our project.

So, I would like to introduce Daniel Gobera to talk about the Source Editor.

Daniel Gobera: I like to guide you now through some of the improvements we have in the source code editor in Xcode 4.

We have a ton of new stuff so I'm going to concentrate in just three main areas, that's going to be navigation.

How you navigate through the files of your project, how do you find the one you're looking for?

I'm going to talk about editing, writing the code of your application and how can Xcode help you.

And finally, I want to talk about error checking.

How Xcode can help you, not only find but also prevent and even correct errors in the code.

So I'm going to jump directly into the demo and show you those features in action.

So, for Xcode 4 we asked ourselves, what are the most common navigation patterns that people follow when working in a project?

What we found is that one of the most common things is to work in the implementation and the interphase of a class.

Jumping back and forth all the time between those, so you declare a method in the header go to the implementation and you will write the code for that method, back and forth.

Well, we wanted to support that kind of navigation pattern better so what we came up with is the Assistant Editor.

So what you're seeing here is the Assistant, it's going to show you a secondary editor.

Next to the main one that is going to show a related file to the one you're working on, on the main editor.

By default, it's going to show you the counterpart but the Assistant has a deep knowledge of the structure of your code.

So it can show you a lot more than that.

It can show you the superclasses, the subclasses, siblings.

It can show you other classes that inherent from the same superclass so in this case, I can see all the view controllers that I have in my project.

And something that is really cool, it can show you not only the files I'm including but the files that are including my own file.

So, if I were to make a change to this header, I wonder who may I be breaking and it will show me, OK, this other file is including it.

Now, the Assistant as you navigate around your project is going to not including I want counterpart.

It's going to track live whatever you load on the main editor.

Now, where this really shines is that it not only applies to source code, it applies to all kinds of editors.

The most common case is when you're working in the interphase of your application.

Let's say you're working on a name on the interphase and this case it's an e-mail model view and the Assistant is going to show you the code that directly affects this view.

In this case, the view controller so you can write the code, write there that affects this interphase.

It will show you also the headers of other views you may be using in this interphase.

Alright, I want to show you a little trick when using the Assistant.

So, whenever you press the Option Key and perform some kind of navigation, let's say clicking on a file in the navigator, it will open it in the secondary editor so you can keep working on your main file and open something else for reference in the secondary editor.

Now, this works for all kinds of navigation.

Not just when clicking on a file in the navigator.

You may know that when you press Command and double click on a symbol, it would take you to the declaration of that symbol while if you press again with the Option key so Command option and double click, it will open it in the secondary editor so it doesn't throw you far away from your context.

[ Applause ]

So you can keep working on your main file, open something else for reference.

Alright. This also works when you're using Open Quickly.

So in this case, I want to open, I don't know NSArray, alright.

So if I press Option and open it again it's going to open the second writer.

So, remember the Option key is going to open things in the secondary.

Now, that is the Assistant Editor.

I would like to talk a bit about code completion.

In Xcode 4, we have a completely new back end to generate completions.

The really nice thing about it is that is ties directly with the LLVM compiler and who knows better what is valid at certain points in the code than the compiler.

So, we are able to generate much more accurate completions and of course something I know a lot of you are going to like is C++ completions so full support for C++ which is pretty cool.

[ Applause ]

Let me show some of that in a demo.

So, I'm working on the same project.

Let me open counterpart.

So normally, when you're working in the interface and implementation, well, let's say you're adding a new method to this class.

So I want this to return an image and let's say its called image of size its going to receive a size parameter.

Now, normally what you would do is just select this, copy it and paste it in the implementations to actually write the code for it.

Well, that is last century because we have what I think is a better way of doing this kind of thing.

If you just start typing the name of the method, and press CTRL-Space to bring up the completion, it actually knows what methods you have not implemented in this class yet.

And it will suggest them as completions.

[ Applause ]

So, I think that's going to save you a lot of time.

It's actually pretty cool to use.

So all you have to do is accept the completion and yeah, let's implement that later.

For now, I will just return here.

So, that's one thing about code completion.

Let me show you C++.

I have a C++ file on this project.

So now you can do things like, I don't know, using namespace and it will tell you what are the available namespaces you can use here.

So, you can accept the completion.

It can also tell you what is available for a certain namespace.

So well, I'm actually not really a C++ guy so it's kind of a lame demo but please try it out for yourself.

You'll find that it's pretty cool.

One more thing I want to show you about code completion.

You may notice that some of the completions have this gray icon.

This stuff they showed in the previous session.

These come from the snippets library and the snippets library is over here on the right.

It is second top to the right and snippets are little fragments of code that you can reuse over and over in your application.

In a way, they are similar to the Xcode 3 Macros but they have a couple of huge advantages.

We have received a ton of feedback and one of the biggest things people want to do is being able to create and edit them easily.

So now, they are part of your workspace.

They are part of the IDE itself.

Let me show you an example.

So, if anybody has to use Grand Central Dispatch, there's a ton of very useful stuff.

One of my favorite functions is something called Dispatch.

Once that will guarantee that some code is executed only once and that it's executed in a thread safe manner.

The problem is that it requires quite a bit of setup.

You have to declare a static token.

So, let's say it is Dispatch Once T.

Let's call these ones and then in the next line, you call the function.

So, it's Dispatch Once, that's the function I want and the its first parameter is the token.

You send a pointer to the token and a block.

When using blocks, it maybe easy to forget the semicolon.

So, this is quite some setup that we have to do and it's the same every time.

I don't want to ever have to type this again.

All you have to do is select it, drag it to the Library and it's going to be yours to keep forever.

So, it's right here, you can go edit.

Let's give it a name, its called Dispatch Once.

And if you notice, there's something called the completion shortcut.

This is going to be a keyword that you choose that is going to be used to invoke these snippets from code completion.

So, in this case, I'm going to call this dionce.

Well, if you want to get fancy, you can call it dioncé.

[Laughter] So that's going to be my snippet.

Later on, you're working on some other code, and until you want to use it, all you have to do is start typing the name in both code completion, and it's going to there.

You choose it from the list and it will auto complete to that.

[ Applause ]

Let me show one final trick.

You may want to have placeholders for tokens of, you know, where whenever you use this completion, this snippet, where should you put your code?

So, if you type the secret sauce, it is opening in the bracket the cast tag and then close it.

That's going to turn into a token.

So, when you use it, let's see, it's going to insert a token ready for you to edit, and you can have as many tokens as you want and you jump to them with tab.

[ Applause ]

Alright. So, those are some of the improvements to code completion.

I want to show one final feature of the Source Editor.

Usually, you have to wait until you build your project to find out about errors and warnings you may have in your code.

Well, in Xcode 4, it's going to be reading and analyzing what you type in the background all the time, and they can tell you immediately if you have a problem in your code.

So, for example, in this method, I have a to do that, I have to generated a preview.

So, all I have to do is call the self-method.

It was called, I think, generate preview.

Well, and a yellow underline appears.

That's telling me there is something wrong in this code.

And when you see a yellow underline, you really, really have to listen to it, this is going to save you a trip to the Issues Navigator.

It's going to save you a full bill cycle just to find that you have a problem.

It may save you from an embarrassing crash when you're trying to show the new code to someone.

It may save you from causing a time continuum paradox.

[Laughter] So, please listen to the yellow underline.

And if you click on the icon, it's going to tell you, "What's the problem?"

"Oh, it's not that but, I just forgot to implement that method."

So, I'm going to implement it later.

Now, that is one the Fix-it that is running in the background is able to catch a wide variety of problems.

That is one of them.

It can also catch other things like, I don't know.

If anybody here is new to Objective-C, you may find that strings are not the same as what you're used to.

So, if you want to set the title of this view, in this case, it's giving me a red underline that means it not only found the problem, but it actually has a suggestion for me.

In this case, it's telling me, "Hey, you need an @ symbol before this string because this is not a C-string, this is an NSString that you use in Cocoa, so please add an @ symbol."

And you can actually tell it, "OK, well, you know, the fix, so please apply it for me."

[ Applause ]

And that is Fix-it.

We hope that saves you a lot of time and a lot of headaches when writing your code.

So, just to summarize what we saw, the Assistant Editor, it can show you related files in the secondary editor all the time.

It will save you a lot of jumping around, a lot of navigation.

Things will be right there where you need it.

Improvements of code completion using the LLVM backend to produce more accurate completions, not having to save the files, the header files, and they will still be included in the completions.

And of course C++ completions.

Code snippets, being able to save the fragments of code you use over and over and how to integrate them with code completion with a completion shortcut.

And of course, Fix-it, being able to find and even correct common problems in the code as you type it.

OK. Now, I would like to call Chris Ryan and he's going to talk to you about improvements to Find/Replace.

Christopher Ryan: Thank you, Daniel.

So, you've seen how we can use great new features in Xcode 4 and the Source Editor to improve your code workflow.

One of the workflows that many of you will use after you've written some of your code is Find/Replace.

We've done a bunch of things to help improve that workflow.

I'm going to talk about a few of them today.

The first one is updates to our in-editor find script, which allows you to quickly search within a single editor, and you saw some demos of that earlier today.

The second one is the Search Navigator.

The Search Navigator is the place you go in Xcode to do searches throughout all your files within your workspace or projects.

And finally, anybody who went to the last session saw the Find/Replace preview, and that's really the thing you can use to preview your replace before you hit that Replace button.

It really helps make sure that you know what's going to happen before you press that Replace button.

So, I've been talking about that, let's give you a quick demo.

So, we're in our window here.

Before I start, I just want to talk a little bit about the filter on the bottom here, there you go.

There are several ways you can filter the Project Navigator, and this is a great way to work with your project on the files that you use often.

The first one is the recently edited files.

As you can see, here are all the files we've used throughout our demo today.

The second one are all the files with the SCM status, so this is the file we've edited.

And of course if you had updates on your server you'd see those as well here.

The third one are all the files that are unsaved.

And finally, you can just type in filter by name.

And sometimes, you might have a set of files with all similar name that you want to work on.

It's such a great way to get to those.

So, I'm going to filter that right and real quick.

So, the Find bar.

The Find bar is introduced in Xcode 3.2.

It allows you to easily and quickly search throughout things within your editors.

And as we've seen, it works in Source Editors as well as other editors in Xcode 4.

It's simple to use, just use command F to bring it up, and start typing.

As you start typing, we search and find all the results that match and jumped to the results that make sense, and I continue to type and find eleven results here.

Now, one of the big things that we got a lot of feedback on was it was hard to know exactly what the find bar was doing when it did its search, what the configuration was for the search.

So, we've made it much easier to see the Find options.

We can just show the Find options and see them at all times, so you know exactly what's happening when you do your find.

So, I'm going to go here.

I'm just going to change the case sensitivity.

Instead of ignoring case, we're going to match case.

As you can see when I do that, I now only have nine results.

Now, one of the other places we've gotten feedback about is about reasons in jumping back to our recent searches.

Typically, it only shows the recent text that you typed, but you may have change around different configurations and change the way you're searching, searching for a whole word or beginning of a word.

We've made that much easier as well.

So, I go here, I see all the different characters and text that I typed as well as the different criteria for the search.

I'll zoom it up real quick and show you.

So, here is our first, first search with handshake ignoring the case.

As I click that, we find the eleven results again.

So that's a brief update on the Find bar.

The next thing I'll talk about is the Search Navigator.

This is really the place you're going to use to do all your searching within your project throughout all your files and system.

I'm going to go and I'm just going to do quick searches in the same criteria we did before, handshake, right?

So, it's found 94 results.

And one of the first things you may notice is the first result is the property list.

So, we do searches within property list.

And as I select each one, it opens up individual items, so you can see where the result is located.

As we scroll down, of course, we're finding results within source files.

And if you look closely at this result here, you may notice that it's got a special icon and the entire word is in bold, and that's because this result handshake was found within a variable of the K HSK, we can get handshake URL touch.

So, we can detect different symbols that your search results within.

So it's really easy to scrub down and look at your search results and see that your search is found within a function name or method name or variable.

But if we scroll all the way down, you'll notice we're also finding things within your project settings.

This is a great way and so, if we want to rename our project, we have Handshake.

We might search throughout all our source and rename all the places that where Handshake is located.

But sometimes, there's hidden settings and different things within our project settings.

And you can go in, find them, and also do a replace right here in the Find Navigator.

[ Applause ]

So many of you are probably saying, "I don't want to see results all those places.

I just want to see them in many particular set of files."

We've made this really easy.

Just like the In-editor Find bar, we can show our options, we can specify different configurations for our search, and we can also specify specific scope that we want to search in.

So by default, it's the entire workspace.

I can also add all the link all the headers in the linked framework as well.

But I want to create a new scope.

Let's create a scope that searches within all of these source implementation files.

So let's name that appropriately.

OK. So the first criteria that's going to search within the entire workspace.

Now, if I'd want to create a search scope that's without outside the workspace, I can.

And I can search within user include, for example.

But when I search in the workspace, I'm going to add in a second criteria, I want to search by type.

So I want to find all the files in the workspace that our source code files.

But I only want to show the implementation files.

I don't want to show the headers.

So let's change add another criteria, and we're going to find all of the files that are not header files.

So it's really easy to create a scope, specifically for what are you looking for.

Click Done.

Now, as Xcode automatically sets your scope as a scope that is used for your search, and we can just hit Enter here.

And now, we have only 38 results only within our implementation files.

There you go.

So [ Applause ]

You can clap.

So we've done some finds, and that's great, and we can find different pieces within our project, within plist files and source files.

But the next thing you want to do is replace.

So to make this interesting, we started this project out and we started to replace all instances of NSLocalizedString with our own custom version.

I'm going to bring that up right now.

Use open quickly here.

One of the cool features is that I didn't show that off very well.

You can can't use this fuzzy logic and I can magic in something that's not the exact name there.

Open that up.

So here's our new version of NSLocalizedString that we want to use for debugging within our project.

And if you look closely here, you have three arguments: the key, a default value, that's a value you want to specify if the key can't be found, it's not translated, as well as the comment.

So that's what we want to make all versions of NSLocalizedString.

So I'm going to go now and we're going to go search for NSLocalizedString in our project.

So let's look at one of those.

So and here's NSLocalizedString, and it's got two arguments.

It's got the key and the comment.

So we need to come up with a search that can find all NSLocalizedString, take the first argument and the second argument, and properly places into the new call of our new function.

So to do that, we're going to Replace mode here, I'm going to write a regular expression, it's going to hopefully, I can get this right on stage here.

So we're going to match do a sub-expression match to find the first argument.

Second argument, and close out that function hall.

And one thing you may notice is that Xcode automatically detects that whatever written is a valid regular expression, and it allows me to change my search strategy.

So I'm not only searching for a textual exact match here, but now, I can change to a regular expression match.

So let's select that.

So here are the results that it's found.

And it's also it's prepared to allow it's set up so we can easily do the replace.

So let's do that right now.

When it take HSLocalizedString, and we want the first sub-expression found to be the first argument.

And the new default value argument, we don't have a value for here.

So we're going to set that as No.

Actually zoom in so it's easy to read.

And then the third argument is going to be the second argument for NSLocalizedString.

So let's zoom out.

Alright. So I only have 13 results here, but it's still kind of scary.

I don't know if I got this exactly right.

But we have something called the Find/Replace preview that makes it really easy to preview what's going to happen.

So, let's try that.

So, on the left hand side you're going to see the documents, the code as it is in your document right now and on the right hand side it's a preview of what will happen when you hit the Replace button.

So, let's quickly look through here and see if it's done the right thing.

We have NSLocalizedString.

We have our two arguments and we have HSKLocalizedString and we have three arguments.

So, we've got this just right and that's great.

So now we can go through and just select the results that we like and simply hit the Replace button.

So to replace those two results, on the left hand side here, we have a check mark to tell us that we've replaced those results and on the left hand side of our editor we have the update of our results because this is what it looks like within the current file.

It's going to hide the preview mode here.

And one of the thing you can do, you might have seen in the state of union is.

When you're done with the result, I can just delete them and easily pair down my working set then continue to work on that data as I need to over time.

So that is the Find/Replace Preview.

[ Applause ]

So one other thing when Kerry did the build in the beginning he had this nice hud that came up and told them that the build was done.

I don't have that in Find I'm a little jealous.

So I'm going to show you something cool called the Alerts.

Now the Alerts allow you to specify specific Alerts for specific events.

So we have Alerts for build, Build, Failure or Succeed, testing, running and device store being complete.

But I want to set an Alert for Find.

So I'm going to show a Bessel Alert and, you know, you can do other things.

For example I could show the Find Navigator so if you're doing a long running find and you go back to your code you continue to edit, you might want to show the Find Navigator when the find is complete.

But I'm going to one up Kerry and have it speak the results here.

Alex sounds good.

So, let's try this again.

Do a regular text search, and let's look for Handshake.

[ Pause ]

So, if you guys could hear the mouse over here.

The little mouse voice, defined the Xcode spoke the results here, unfortunately, it wasn't hooked up to the speakers but you get the idea.

So, you can easily customize different events that happened within Xcode so you know exactly what's going on.

Alright, so just to summarize, we talked about some of the small changes we've made to In-editor Find bar.

We've heard lots of feedback from you guys on what works and what doesn't work and we're going to continue to iterate on that and make this a great experience.

We talked about the Search Navigator.

This is the place you go within Xcode to search throughout all the files in your workspace or projects and finding all different types of files.

We showed you how you can easily scope that find so you can search in only specific areas or specific types of files.

And also how Xcode can detect regular expressions, easily allow you to jump back and fourth between different search strategies.

Finally, we showed you how Find/Replace preview gives you a little more confidence in hitting that Replace button when you're changing a lot of things inside your project.

So, next stop, I'm going to bring Ian Baird to talk about the Version Editor.

Ian Baird: Hi.

I'm Ian Baird Xcode Software Engineer and today I'd like to introduce you to what I consider to be one of the coolest new features of Xcode 4, the Version Editor.

Much like many of you, I started as an NT Developer and one of the hurdles that I faced was getting to use this raft of SCM tools Git, subversion.

They don't have the easiest term, no interface.

And many of you have known this and I think our team has done a really good job and made just great strides for making this easier for you and getting that information right up in your editor where you're going to be able to put it to great use.

So, let's begin.

The Version Editor consists of three main pieces.

The first one is the Log Mode which brings all of the revisions in your repository, right up into the editor where you can see them.

It's truly awesome to be able to see this.

You can see who committed it, when they committed it, and why they committed it if you can deduce, you know, what their intention was from the commit message.

Sometimes it could be difficult depending on how much tequila was had the night before.

Next there's Blame Mode.

Awesome, awesome feature.

Allows you to go through, block by block in your file, show you again who committed it, when it was committed and why it was committed.

Very sweet feature and you'll see why later.

And finally there's a Comparison Mode which allows you to take two revisions from your repository.

Any arbitrary revision and compare them in a file-merge style interface, it's really cool.

But you know what?

I know like you guys, talk is cheap, let's go to the demo.

Chris made a couple of replacements.

Let's take a look and see what he did.

Going up here is the Version Editor, loading, loading, excellent.

HSKLocalizedString that looks good.

You know what since this is an editor, I should be able to do one or two really interesting things with it like make edits.

I think since Handshake has been there, it's done that, this should probably be changed to Handshake Rides Again.

And as you can see the diff pops right showing you exactly what was changed.

You can even delete, add some spaces, do whatever you want.

The next thing I'd like to draw your attention to up here is the Jump Bar.

The Jump Bar gives you a view into the revisions in your repository.

Let's go to a really old one.

Let's find one from this Kyle guy to see what he did.

Let's go older and older still.

Well, that's the way the ball bounces.

Sometimes with these demos things don't necessarily come right out.

So, you know what, let's move on to the next feature.

If you're not a person who likes to twiddle the Jump Bars to find revisions and you tend to think of things structured in a date, sort of centric way.

Maybe you'd like to try out one of my personal favorite features the Version Timeline accessible here with this handy little clock icon, in the center.

You can see the revision on the left and you can select any revision you'd like to, going back through time on the right.

The thicker bars that stand for revision, the thinner bars divide the dates.

You can move left and right, changing the revisions and the diffs will update most of the time.

So here we go, let's dismiss the bar.

And let's see it again, I kind of like that feature.

If you hold Shift it goes extra slow, kind of like my diffing engine right now.

Anyway, that's a cool feature.

Let's next go to the Log Mode that we talked about earlier and view some of the revisions in our repository.

Looking here, I made some call more efficient, obviously it wasn't but let's jump back and see what it was.

The Action button takes me back to the comparison view so you can review your local file on the left of whichever file you had selected, in this case it was head, versus the revision out of the Log Mode on the right.

It's really cool, very, very useful for seeing what has gone on in your repository especially if you're a consultant.

You've just sat down with the new code base and you want to see how the code base has changed overtime, super useful feature.

So, I've been talking about a few of these really awesome features that we have.

I gave you a quick overview of the Comparison Mode.

We navigate around.

We used the Jump Bar, we used the Timeline Mode to review some features and we also took a look at the Log Viewer to be able to view all the revisions in the repository at the touch of a button.

The next thing I'd like to show you and in my opinion.

I've sort of saved the best for last is the Blame Mode.

The Blame Mode is super useful and to start with I'd like to paint you a picture.

I'm working with my partner on this application and she has added a new feature and the feature is pretty awesome in her mind but it was done a little bit late at night.

So, I'm going to see if the application continues to run, let's built and run, test it and see if it continues to work the way I expect it to at least.

Go up here, send my card, oh man, crash.

We've seen a few of these today.

Go back and it appears, well everything looks right, this is really strange.

All right, well, I think I'm going to use our new Blame View to figure out exactly what happened.

We're going to look, Line 184, go back to Aversion mode and Blame and let's see.

You can see on Line 184, the program counter appears right there and you can see that Sarah Lightwater was instrumenting our calls to release and she says she was going to remove it when done.

I guess she just forgot.

Let's see if we can fix it.

We'll tap the Action button which shows us how the file looked before the change and then after the change.

Let's grab this from over here, use the Jump Bar or the Version Timeline Mode to go back to the Local Revision under the changed, saved, stop, build, run, and try it again and it works.

[ Applause ]

In summary, you have seen the three major components of the Version Editor Mode.

You have seen the integrated version history which is incredibly cool.

It brings all of the revisions from your repository up front and center into your editor where you can interact with them, see them, and become informed by them.

You can also view your changes using the two app Comparison Mode.

You can see the diffs left to right.

You can change the revision that you're looking at and you can even make live edits.

And the coolest feature that you saw today or again in my opinion the coolest feature was how you could find and fix regression using the Blame Mode as integrated into the Versions Editor.

Next, I would like to bring on Kerry Hazelgren to finish this off.

Kerry Hazelgren: I'm going to show you the commit sheet because it's, well I'm just going to in typical managerial fashion, commit the changes that were made up here under my name so that I get credit for them.

No offense to my manager who is in the audience.

OK. So, there's a couple of different ways that I can review the changes and we just saw it's really good to check all of your changes before you commit them.

I can filter the Structure Navigator.

I think we've shown this already by clicking on, let me X out that.

By clicking on the SCM icon in the Filter Bar and if I'm in Version Mode I can just click through the files to view my changes, view and review them.

But I prefer like when I'm reviewing them to be able to to be crafting my commit message so I don't miss any important notes.

If I'm going to go right into the commit sheet by going to the file menu and the source control sub menu and hit Commit.

So, while in the commit sheet I can actually do the same thing.

I can look through each of my files, review my diffs and be typing my commit message as I'm doing that.

Let's see I'll just say, I fixed the crash, I had no help from anyone.

[ Laughter ]

Before I commit let me just show you, you can look at your files a few different ways.

Here we're just looking at a flat list of the files that I'm going to commit but I can also in the project view see the files in the structure that they are organized and in our project or I can go to the file view to see the files as they are organized on the file system.

So, it might be a little helpful for you to know what, you know, what files you're looking at.

You cal also choose not to commit some files in here if you decided that the changes are not what you want.

So, when I hit Commit it will process the commit and then when it's done it will auto dismiss the sheet.

If there had been an error or the commit had failed, it would've presented that error and let me change my commit.

If for any reason though I need to refer back to what just happened if I want to make sure that I committed all the right files and I want just to for sanity sake to check that, I can.

There's a log of it in the Log Navigator.

Let me go to the Standard Editor here and there's an entry here that says you made a commit at this time at 5:15 PM and these are the files that were committed with that.

So, sanity sake there's a record of what we've done.

So, in summary what have we learned today?

We've learned about integrating source control where you can review changes to your files.

And I really think that we're making source control fun and interesting.

We've learned about the standard and assistant editors that help you to navigate around your source code file and also talked about all of great new improvements that we've made to them.

Then there's the Search Navigator with its cool Find/Replace preview and finally the Version Editor with great ways to view changes to your files.

I mean, this stuff is like from a fairy tale don't you think?

There should be ponies and unicorns coming out of here.

I've been using Blame Mode and I think that's my favorite feature of Xcode 4.

It's been very useful to find and track down problems and please be nice when you've identified the person who made the problem.

I don't want to start any flame wars or anything.

For related sessions we had an intro to Xcode 4 just before this one.

Tomorrow there will be two sessions about Building your App and using Interface Builder and then again on Friday, another one regarding Debugging with LLDB.

So, to finalized if you have any question, please contact Michael Jurewitz, he's a real nice guy and very helpful.

Use the Developer Forums.

Apple Engineers monitor those and should be able to answer your questions.

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