WWDC2003 Session 302
Transcript
Kind: captions
Language: en
hello everybody and welcome to
to introduction to Xcode I hope that was
the glitch for the evening with the bad
batteries in the clicker and that's me
and alright we have a full packed
program and we'll be going a little bit
more in depth from what you've seen
yesterday in session 300 let's talk
about what does it take today to be a
modern IDE first of all you have to have
a streamlined workflow these days your
projects are huge you have tons of
resources many hundreds thousands of
source files etc and you need to be able
to focus really quickly on what it is
that you're working on right now and be
able to manage and navigate all those
files really efficiently you also need a
powerful leader that goes without saying
you have to be able to go through your
long files find your methods navigate
through all that source code may be
group files together which you're
working on just having a small working
set you need a fast and flexible build
system fast goes without saying because
your product is so big but it also has
to be flexible you have to be able to
customize it what to do with a C++ file
what to do with a nib file etc so you
need to be able to make it just right
for you you need to have quick
documentation access os10 is really
powerful it has really powerful api's
cocoa and carbon all together they have
numerous thousands of API calls and you
have to have an access to the
documentation of those API calls really
in an efficient way and it should be
integrated with the UI and profiling
tools code that you're writing is just
part of the story right you're also
doing the user interface design maybe
it's not you who's doing that design
maybe there's somebody else doing it but
you better integrate so when you add in
your resource file it gets reflected in
your IDE then profiling you wrote your
app it's finally working it's not
crashing but it's kind of slow so you
need to profile it'll be good if the
profiling tools knew about the source
code and vice-versa
so finally source control management
chances are that if you're writing a
large application in write in on your
own and so there's a large team of you
maybe there's a dozen maybe there's a
hundred of people and you need to
integrate with different people together
through the source control management
and the lost I don't think the batteries
are quite there the last thing that you
need is API awareness in the debugger
source level debugging goes without
saying
but it will be really nice if he had
direct display of your own personal data
types as well in the debugger so now
let's have a quick look at Xcode here we
can see we do have a streamlined
workflow as Steve narf showed yesterday
in 300 you have really quick access to
all of your data and all of your files
you do have a powerful editor it
features code completion today we will
show it to you how it really works you
have access to your methods to
individual methods to files by groups
etc you do have a fast and flexible
build system today we will not go quite
in depth on that there session 303 any
24 hours right here so you can see more
detail about that there you have quick
access to documentation apples previous
tools were actually pretty good at
integrating with documentation but we
have made it much much more efficient
even than what we had so far we're now
using the Safari rendering engine as you
saw maybe in the previous session and
that makes rendering of documentation
much much faster and prettier and it is
integrated with UI and profiling tools
we will see some demos of that later
today it is integrated with source
control management Xcode features
integration with CVS and also with
perforce this screenshot is not
necessarily the most indicative of that
and we do have ap awareness in the
debugger again main is not the best
place to show but it gets even better
these were the of courses speed is
really important so we have
taking great care of improving many
little things which add up to a big
picture first we added zero link which
basically eliminates the need for
linking all together during the
development cycle we have added fix and
continue which eliminates the need to
stop and relaunch your application while
debugging we have an annotated source
editor so that any compiler errors or
warnings are visible right in the editor
as you're there you don't need to have
an extra panel pop up and click between
windows if you choose not to do that we
have code sense which is our way of code
completion but it's actually more than
that and more on that later we have
parallel distributed builds you saw a
demo of that yesterday using all those
beautiful excerpts over there
it works in without exercise works with
just your neighbor's computer or with
when you're at home with your wife's
computer we do have predictive
compilation that kicks off the compiler
in the background while you're still
typing and so when you add it all
together it actually adds up to
something that's really really fast all
of those little things put together are
something very fast so let's have a
closer look at all those things this was
just very superficial now the project
window as you saw before on the left
side you have a view an outline view of
groups you have static and dynamic group
static groups you create the way you
want them to be and dynamic groups we
also call them sometimes smart groups
are generated and maintained for you by
Xcode you can have files filtered or
kept together by type by filename you
also have smart groups for find results
for errors etc you can do searching and
filtering on any of those groups so you
can search on a special variable name
and then you can filter just in which
files you want to look at them
furthermore this is very important when
you when you do a batch find or maybe
even a battery
place and you find yourself in a lot of
trouble you need to narrow down the
search you have an optional integrated
editor you can use the main project
window for text editing as well so that
eliminates the need for having many
windows which is especially helpful when
using a 12-inch PowerBook for instance
and you have inspectors with search
fields we'll see more of that in the
demo but it allows you to search and
find the compiler settings for instance
very quickly the Xcode editor is the
other very important is the key part
we're probably going to spend the most
time because you're writing source it
allows you to apply sources to the
application which is running as it is
running from within the editor you don't
even have to open the debugger window
you can do it right away from the editor
it features code sense again that's code
completion and more the errors are shown
in source code and we'll see that in the
demo you have quick access to
documentation through command clicks
option clicks and through other means
and you of course to have customizable
key bindings you can set up your own key
bindings you can set up we have pre
can't Emacs code warrior and PW and
other key bindings now code sense I
mentioned it a few times before Xcode
stays completely aware of your source
code it parses your code in the
background and as you make changes to it
it knows what you're doing so it offers
you code sensitive context sensitive
code completion it also allows you to do
class browsing yesterday in a demo you
saw briefly search on symbols you can
search just on definitions on many other
things and we'll see that later today in
a demo and there's going to be more
coming based on this technology of code
sense in a future release of code sense
what's important about is it works for
code in progress it doesn't have to be
compiled so as you're typing new code
and even if it has bugs in it like you
forgot some curly brace somewhere it
will still work and that's very powerful
yet it uses the same parser or very
close to the same
horses the compiler so it's taking the
same path as your compiled code which is
also very important when you do if
that's works for C C++ objective-c and
Objective C plus plus and we will be
adding Java support for that in Panther
GM now the inspectors encode sent in
Xcode we have added a new set of
inspectors with a consistent user
interface very simple interface it
allows you to inspect target
dependencies to set compiler options on
a clear text way which is very user
friendly and to view documentation for
your compiler settings and linker
settings etc it allows you to set up to
build rules as I said those are the
rules what to do with a C file what to
do with the nib file etc you can add
your own rules you can change the rules
that we ship project settings which are
more global settings like were to build
but to put the intermediate stuff codes
and settings which is inspector which
needs to be properly applied when you
actually want to use it and source code
settings that would be indentation tab
stops file encodings or using utf-8 or
using just plain mac OS roman and i
talked a lot i would like to invite matt
frolic senior engineer on the xcode team
and he's gonna show us the workflow in
xcode so Matt what do you have for us
Thank You Stan
I haven't done anything yet so hold on
so we're gonna talk about some of the
workflow issues what are the complex
parts about workflow is that we all
spend a great deal of time with workflow
every day we move between files
debugging documentation whole gamut of
things but the complexity comes in we
all do it's just a little bit
differently some people like their
windows in certain places certain sizes
certain keystrokes the important thing
to note about Xcode is that instead of
trying to provide a single idiomatic
approach to workflow instead we take the
approach of providing flexible and
customizable options for navigation and
organization of your projects so that it
works as you expect it or works for
everyone so let's take a look at it
we're gonna take a look at a carbon
example today one that actually ships on
the system
it's called clock view on the left hand
side are the groups and files which
allows you to organize your project
hierarchically so if we expand as you
normally expect we can see some of the
contents of the projects now it's
important to note that groups take one
of three forms as we said earlier they
take static forms that can either
represents the files as they exist on
the file system
so if your project is actually
structured in the same way as the files
look on the file system everything
appears normally however you can also
create abstract groups to organize your
projects in any way you may like so if
your project is actually shipped in a
flat hierarchy you can actually organize
it in folders much of the way you think
are much the way the classes conform to
each other
some of the benefits though come from
things that we call smart groups by
default Xcode ships with three smart
groups one is for errors and warnings
one is for fine results and one is for
project symbols you can think of smart
groups as smart playlists and a good
analogy in iTunes is that they're groups
that show you things based on a rule or
some sort of heuristic in this case the
errors and warnings find results and
project symbols aren't things you manage
directly we take care of those for you
however you can create smart groups of
your own and you have an example right
here of implementation files that shows
you a number of files based on a
particular heuristic in this case it's
extensions looking for dot CP m dot H
showing you those kinds of files we
could also look at nib files in this
case there's only one but we can go
ahead and actually use the context menu
and create a new smart group to go ahead
and allow you to
groups in any way that you may desire to
allow you to look at resources or
particular files in certain ways this
becomes extremely useful since we
represent groups dynamically and
statically in the same manifestation
when we start looking at the detailed
group on the right the detailed group
always shows an aggregate of what's
selected on the left hand side in the
groups and files in this case when I've
clicked on my project and shows me a
list of all the things that are actually
in my project as I navigate down into
source folders it shows me just the
contents of those source folders this
becomes extremely useful when you have a
deep hierarchy in your project when you
want to quickly go to something you're
not sure which grouping it's in or where
it might be you can use the detailed
group to quickly look through the list
or as you've seen in most applications
we can go ahead and just type in for
example at an extension and quickly see
the header files or dot CP and I can see
the object files that I want to work
with allows you to quickly get to the
content however there's an important
distinction here is that as I said
before the detailed view always shows
you an aggregate of what's selected from
the groups and files that means you can
actually go ahead and select one or
maybe it's more than one so it always
shows you an amalgam of that this
becomes extremely useful as Stan
mentioned before when we do something
like find for example if I was going to
bring up the batch fine panel I can
actually go ahead and type in the string
OS I want to find where this string
exists within every single file in my
project click on find and it's gonna go
ahead and show me that list in the
detail group same idea same metaphor
that we use before but it's showing me
fine results and in this case the status
shows me I have 218 selected what if I
did that again and looked for in this
case a chive you I have 32 in this case
if I go ahead and select both of these
together you can see that maybe some of
you can't see but it does really say 250
up there and if I go ahead and type in
Maine dot CP there is every instance of
those two strings in Maine dot CP which
makes it very useful and very quick and
easy to get at the content you want by
looking at things in groups
we can also as Stan said do the same
thing for your project symbols the
information from this comes from the
persistent symbol index that Stan
mentioned before and these are all the
symbols that is in this particular
application the number up here says a
little under eleven thousand I can
actually go through and look for all of
the methods that look for bounds and I
can see all the implementations of those
making it really quick and easy to go
and find the content you're looking for
to go straight to it so we've talked a
little bit about organization let's talk
about navigation how do I actually get
to content how do I work with it this is
one of those things that starts to
become a little bit personal about
editors where is your editor go so in
many kick in some cases people like
editors to be all in one window so we
have this button up here which allows
you to pull up the embedded editor and
look at your content so I can go back to
my sources taking out the little item up
here in my filter click on a file and it
shows up in line so I can go ahead and
take a look at my file using the built
in functionality of the editor I can
scroll down to something that I want to
create to edit or I can use the function
pop-up which lists all the functions in
this particular class and jump to
something that I want to work with as I
select more and more files each file is
put into the particular view and I can
go ahead and work on it but as you see
it takes up a lot of screen and some
people may want a larger detail view so
in some cases you may want to have an
external editor so as one of the main
idioms in Xcode is double clicking
brings up an external editor so go ahead
and double click on a file and there's
my main dot CP I can go ahead and
actually double click on the rest of
these and I can bring up external
editors for all of them which then
brings up the very important question
how many windows is too many in this
case I have three open which starts to
kind of clutter my screen real estate so
there's an actual nice little
customization here or there's in the
upper right-hand corner of the editor is
something called the editing mode for
those where you can see this icon it
looks like there's three windows paned
one and form to the other
if I go ahead and click that it becomes
a single pane that now every time I
double-click on a file it's open in that
editor so it's always open in one
external editor give me the ability to
work in its way you might like
however once I have this external editor
open I have to keep going back and forth
to get more and more files and it kind
of destroys the flexibility of having
this separate window to edit things so
much as I said double-clicking on
something would open up a particular
file in the external editor I could
actually double click on a folder in
this case it actually opens the first
item in that folder but I can go ahead
and click the groups and see the groups
on the left so now you can start
thinking of editors as collections of
things that you want to work on bringing
up and possibly more than one but still
having the flexibility to either click
on the file or just go ahead and drag
into the editor and go ahead and work on
it this of course works the same for the
project where I can click there and now
I have the entire contents of my project
in one external editor which then allows
me to go back and use a feature that we
affectionately call Metro more which is
to double click on these column headers
and get some more workspace back so now
I can start looking at more and more
windows without having to resort to
using expose or something to see all the
windows to give you a little bit more
functionality
so once we've edited or actually let me
take that back once we go onto a
particular file let's talk about things
that we would want to edit so I can go
down and let's scroll down to the bottom
here this particular class I have a
method here H I set invisible let's just
say for whatever sake as I was
developing at this I didn't actually put
that in and I knew that I needed to put
something here if I weren't familiar
with some of the api's or I needed more
information what I would like to do is
use some of the other assets that Xcode
has to provide this information for me
one way of doing that is to go to the
documentation window which provides me a
list of all the information that I can
look at based on a particular topic like
carbon so I can scroll down through the
topics or I could actually use the nice
little API search to go ahead and type
in something like HIV you set find the
function I want click on it and see the
documentation a very quick way to get to
information about things that you use or
you want to use however in some cases
going to the documentation might take a
little bit of time if you're not sure
exactly what you might need this is
where some things like code sense comes
in mind you might want to go back to the
symbols markup and do some filtering
looking for a particular method you
might also want to bring up the class
browser that we ship that also has the
same in
formation showing you the hierarchy of
the information in your classes I can go
through and click on a particular method
actually see the definitions go ahead
and look at those and use one of those
in my particular implementation which is
great for reference information but
while you're in the midst of developing
code what you really want is you want
that information your fingertips you
figure Xcode already knows about it I'm
not really sure what I want yet but why
can't you just give it to me well as
Stannis pointed out we actually have so
what we do is provide it's one of the
features of code sense is code
completion is the ability to figure out
contextually where you are with some
information about potentially what you
want to give you that information so I'm
just going to start typing here I'm
gonna tie it to a chai and I'm gonna go
ahead and hit the completion key what
its gonna do is duction go ahead and
take that information take that prefix
take contextually where I am and go and
try and figure out what it should
provide me in this case it went back and
pulled out all the list of functions
that start with H I actually let me go
ahead and move my window over here a
little bit so that I can show this to
you a little more easily you'll see that
there's a nice little scroller here I
can actually scroll through this
extremely long list of elements which
gets me closer what I want but I'm
looking for more information so I could
actually just go ahead and keep typing I
could actually just type H I've you and
you'll see that the list actually starts
to filter itself down I can back up and
type a and C in this case there are only
four elements that funk that match I
could type B and C some more but in this
case what I'm really looking for is this
list I can actually scroll down using
the cursor keys or the mouse and this is
where the things get really interesting
is I can go ahead and just hit return or
tab and it's gonna put that method
definition into my code with
placeholders so all I need to do now is
actually just go ahead and type in this
case I know it was control use a nice
keystroke to go to the next placeholder
except it was false the first time and
use code completion very very quick and
easy to go and get the information you
want right in line so there are a number
of
thank you it's important to note that
there are a number of preferences and
configurations to a number of
functionality pieces within Xcode
typically to go ahead and edit some of
those you would go to the Preferences
and pull up the Preferences panel in
this case for the code completion and
code sense they're all under the
navigation preferences and you could set
it up so that it automatically pops up
when you dereference a pointer when you
type the period and also filter if it's
context since are case-sensitive when it
brings up information you can also go to
the Preferences and set key bindings an
extremely useful feature for mapping
your keyboard to exactly the
functionality you want in some cases
with code completion people want to
escape
some people want f5 some people want
different keystrokes and we give you the
ability to take code completion and all
the other functionalities and map them
to the key sets that you're most
familiar with when you want to go and
edit things that are particular to the
application itself instead of key
bindings you want to look at things for
information on files I can actually
navigate to a file and bring up the
inspector and in most cases when you
want to edit something the inspector is
where you're going to go and expector is
a context-sensitive way of looking at
different aspects of your project in
this case I'm looking at the in general
information for the main dot CP file but
actually actually go ahead and click up
on the project and now I'm looking at
the information on the project build
styles and other aspects so when you
want to go ahead and edit information
you're gonna do so with the with the
inspectors so that's just a quick
overview of some of the workflow aspects
you'll see more about the inspectors
with the compiling and debugging and
later sessions in this demonstration
thank you
thanks math part a very good demo now
let's move on there's way more to come
okay so now I've written your source
code it's all beautiful you completed
you read the documentation only exactly
what the app will be doing now I need to
build it we need a build system for that
Xcode has a fully integrated build
system that's into the idea what does it
mean well it's not using or relying on
external tools such as make or jam or
ant or things like that it just knows
the state of your project it knows which
files you have touched which headers
maybe you have touched so it has a fast
dependency analysis it knows that when
you change a header it needs to
recompile also this set of source files
and that's immediately reflected in the
user interface you have an up-to-date
status you have also Aaron annotation
which was mentioned before but it's also
shown in the main project window when
there's a compiler error or warning and
you have an optional access to see all
the gory details that is usually hidden
away from you but if you need to if
you're really debugging and pieces are
error that it just says build felt
because of something that you would
expect would be working well maybe it
just ran out of space or something even
more cryptic happens so you can access
those gory details the compiler under
the hood of Xcode is based on GCC 3-3 we
took it from the open source community
but then an apple we have added a lot of
special enhancements to the compiler
that compiler from its own is very fast
in generating code it also generates
very efficient codes not only the or
compile time is fast but also what your
customers will care about the runtime of
your application is very very quick PCH
precompiled headers this is something
that actually GCC doesn't have we have
added that that's an apple add-on so
that even the C++ people who were
complaining about the lack of
precompiled headers so far we now have
something that will suit everybody's
needs and finally we have added support
for inline assembly exactly in the
coworkers
so you can take your code or your style
CFO of an embedded assembly and compile
it right away we have added many other
switches that are to handle pragmas but
it's in more detail than is suitable for
this session batteries getting tired
precompiled headers this is something
new that we added to GCC 33 it's a brand
new mechanism that works for all
languages it works for C C++ objective-c
and the Safari people with option C++
and there's gonna be more coming with
Panther this is just a pre-release so
the PCH mechanism you might find cases
where it's maybe not quite mature but we
are working on more and getting things
more automated now predictive
compilation that's another step to cut
down the compile time it Prime's the
pump most compiles are not they're also
just just syntax checks right you're
trying did I forget a curly brace some
work but even when you're doing a
turnaround debugging then you just go
somewhere to the code you change
something and even if you know exactly
it's this one character that the
time.they takes you to say command s to
save and comment B to build during that
time you know when you're really fast
it's maybe half a second while during
that time the compiler was already
running and it's ahead of you so it cuts
down to the turnaround time so it starts
the compiler as soon as you start
editing something and it goes through
all of your pound includes and pre
processes pre-compiled stat and when you
say actually save and build it will do
just the rest which is usually 1% of the
work then come B story to build
something we demoed yesterday and this
is really not the most mainstream
feature definitely not the most
mainstream feature yet this is something
more for thrill-seekers at this very
moment it takes care of it takes
advantage of raw level it will discover
other computers on the net that have the
same xcode version installed and it will
try to distribute the build to that
computer if the user on that computer
has allowed that it creates complete
self-contained jobs so even if you don't
have the same headers installed there or
even if there's a little bit of a
mismatch you don't have to have a mapped
network file system for instance the
compiled job is this a completely
self-contained and the pre compiling
happens on your machine and then it gets
past one so that's her but it happens
only once so if you compile more than
one file you actually have a great speed
benefit the greatest speed benefit is
around four machines it really varies on
the kind of code that you're doing you
don't really need that set of excerpts
unless you have a huge build production
like at Apple we have built an
integration where having built all of
our Stan and when you have large apps
maybe like Maya having that would make
sense what it requires is really fast
Network hundred megabits or gigabit with
10 megabit or over airport you will not
see any benefits so now I would like to
invite under spurred alert who is the
lead Xcode engineer to show us a little
bit about the build system thanks Sam
so Matt showed you some of the great
features we have for navigating and for
editing source code so I'm gonna go
ahead and show you how to build it and
some of the some of the workflow we have
there so I'm gonna open the same project
and Matt used this is the carbon example
of clock to you and I'm gonna do is to
actually show the embedded editor here
so I'll go ahead and open that and I'm
gonna select one of the files here
called the clock T dot CP and this is
for a lot of a lot of the code in this
little program is so what I'm going to
do now is just to build and we'll see
what happens whoa
it has some errors okay that wasn't
expected so let's go and select the
errors and warnings group as you notice
on the left side there is now the errors
in smart and warning smart group that
shows you any files in your code that
have problems last time you compiled
them in this case we see that there were
a couple of errors and some warnings
you'll also notice that there is an icon
in the margin here and in fact if I go
back up here you'll see both the
warnings and errors are shown here I can
actually if I'm looking at just the
source code
let's say I'm working in this mode I can
actually just click on this error here
and then it will show me what was what
the problem was up in the status field
so what I'm gonna do here is to actually
show you a third way as well we do have
a warnings and errors panel that a Stan
mentioned you almost never have to use
this is only if there's something really
weird that's going on you can actually
see exactly what the what the build
system was trying to do in this case
trying to compile this file if you want
the real details of what was going on
you can actually select entries up here
and it will go down and show you the
transcript including all the command
lines but 97% of the time you don't need
to see that so we're gonna do here is
I'm going to fix a couple of these
errors this one is just a warning so I
just go ahead delete this one we checked
that this is OK and everything's fine in
this case we see that there was actually
an error let's see if I if I go and
click on this we just had a misspelling
so I'll just enter their ID back in
there I click on this one we see
actually we need to pass dot X so these
were just just a couple of warnings that
we put into the code here I'll go ahead
and build again and it asks me if I want
to save so we've already built and
there's still one error in this case
this appears to be a macro that we
haven't defined so what I'm gonna do
here is to just select this and just
copy it and in this case we want to go
to the inspector so I click open the
targets group this is the target that
defines how to build this this app
called clock view I hit the inspector
icon and again we can just go to the
build settings here and define it so
this is a preprocessor macro that that
needs to be defined now there are a lot
of settings here and I'm not quite sure
which one I want to set but I know has
something to do with preprocessor
symbols so I'm just going to type
preprocessor I look they're preprocessor
macros so I can just enter the value in
here I'm just going to paste this will
define that as 0 and then one other
thing of note is you can actually search
here as you noticed and if you need to
see a description
just pull up a textfield down here and
you can see more information about the
particular option and this if I don't
filter anything it just shows the most
common settings that 90% of the time
you'll need to use things like
optimization preprocessor Flags things
like that if you don't see the setting
that you want here odds are that it's
it's still supported it's just you need
to open the drawer so opening the drawer
reveals the different languages that are
being used in this project and you can
actually disclose this to go down and
set particular categories so let's say I
want to change some options about
linking I'll just select this and of
course the filtering works here as well
the current settings smart group is a
special one that shows everything that's
specifically set in this target is
different from the default values so now
define my preprocessor macro I'm
actually just going to build this again
and we see that it'll succeed at this
time and one last thing I want to I want
to note is you can actually do the
single file compile by default it's
bound to command K because that's what a
lot of people use to but you can do you
can of course bind that to anything you
want you can also show the assembly code
or the preprocessor source for any of
the source files you're working on so
with that I will head back to stand
thank you honors there's gonna be a much
more detailed session about it in twenty
four-hour session three oh three right
here so if you want to know more
okay now I've built your application and
contrary to your expectations it's not
quite flawless there are bugs so the
favorite of everybody debugging we found
out from feedback from all of you from
own experience and common sense that the
debug cycle is very important so we
tried to squish it as much as we can we
have a very efficient debug cycle in
Xcode first of all the debugger itself
features a context-sensitive data
display with data view summaries we have
four matters for all-carbon cocoa data
types and as well as some other data
types and you can create your own for
matters for your custom data types you
can do really simple ones which are like
a simple string formatter similar to
printf or if you're displaying something
really bizarre you can actually write
bundles that the IDE will load and it
will display your own data types you can
of course now break on C++ exceptions
yes another way to reduce the turnaround
time is how to get to the debugger in
the first place
zero link we are adding this feature
which basically does away with linking
because linking is time-consuming
usually most of the time your edit just
one file maybe two but not you're over
1500 files in finder right so you do
just away with linking and it makes a
turnaround time go dramatically down it
dynamically loads the object files STR
needed as the application is launched so
this is a very efficient way but not
necessary suitable for final deployment
of the application and then finally we
have fixing continue which completely
reduces the turnaround time to around 3
seconds it allows you to dynamically
modify your application as it is running
in place
it's suitable mainly for logic bugs
places where you put the wrong variable
you're running over an array things like
that infinite loops or my favorite trial
and error code I mean for instance I
can't never get coordinated transforms
right I mean even if it's something like
this is scaled by that or if the
coordinates are rotated I just can't get
it right and for that fixing only is
very very useful and for UI layout for
instance as well what fixin that
continue really excels at is when you're
making changes within functions changing
constants and and modify local variables
maybe call functions or even write new
functions so you can do all of those
things
fixing continue is not so suitable for
changing or actually doesn't work with
things that have global effect like
changing headers or changing Global's
obviously when you modify just one file
to reference and you had a new global
variable all the other ones they don't
know about it right so you would have to
quit and rebuild the application for
that or call signature so it works
pretty well with Objective C but it does
not work so well with the other ones and
there will be a dedicated debugging
session that will be talking great
length about fixing continue and the
other debugging kind of tools that we
have integrated with our performance
your application is now maybe running is
no crashing but it's still kind of slow
and we ship a bunch of apps such a
sampler melech debug object a lock and
thread viewer those are profiling
applications post for speed and for
memory usage because it when your
leaking memory that's not a good user
experience as well now Xcode is
integrated to a certain degree with
those applications the first step so
that Xcode can column as your debug
media and then those applications
message back to Xcode about selections
that you make so that they show you
actually the code that causes all those
memory leaks or spends a lot of time
there will be dedicated session about
this this is
session number 305 and I would recommend
that you go there now this time I would
invite Chris reason on the stage but
that guy he worked so hard he actually
is homesick and so under picked up his
demo just this morning welcome Anders
again thank you
unfortunately Chris unfortunately Chris
can beer so I'll get to demo his really
cool features instead so I'm again I'm
gonna open the clock view example here
and so you've seen it being edited and
you've seen Matt show off some of the
navigation features you've seen us build
it but you actually haven't seen it run
yet so let's do that now I'm gonna go to
one of our pop down toolbar buttons
actually this one and I'm gonna say
building debug first of all and we'll
get the clock view up here and it looks
kind of odd it has a dark grey
background so we're gonna fix that so
I'm gonna go to minimize this and pull
this over here I just want to open up
the embedded editor again I'm gonna go
down to my clock view source code here
and go through this here I know that
there is some place in here where the
shade is being set and so what I'm gonna
do is I'm actually going to go down and
find the fill shade equals statement and
if I can type it right we'll go to it so
there are a couple of one a couple of
parts to this here I see that there's a
fairly dark color here I'm just gonna go
ahead and change this and I'm gonna save
the file and then you notice the check
mark appears here this is the build
system paying attention in the
background and says I need to compile
this file now because you changed it so
there's also tape dispensers so let me
just go and click on that and we noticed
that it's compiling the clock view and
it's going back into the app here and
it's actually changed the code on the
fly so the clock continues running but
now we have a nice white background
so but you may notice there's something
odd going on here I'll make it larger so
you can see it says that this is quarter
past 4:00 in the morning so apparently
we have a logic book so let's try to
find where that where that might be
let's go ahead and search for the string
a.m. here and we see that it's right
here so let me actually go ahead and
look at this and we say ooh greater than
twelve that's that's not good right it
should be less than or equal to so let's
go ahead and change that to less than or
equal to I just make the clock a little
bit smaller here in the background and
let's go ahead and save the file and
we'll fix and continue that again so now
it changes to p.m. so we fixed the logic
here so as you can see this saves a lot
of time if you if it takes a long time
after you start your app to get to the
part where the problem occurs you can
save yourself a lot of time here so so
far we've just changed a constant we've
changed some logic let's call it
function so this white background here
is kind of boring so I'm going to go
ahead and search for the fill shade
again and this time I just want to go
ahead and type something here let's see
that changes over time so let me go
ahead and get a random value here so I'm
calling a function in the library and
let's see how did it maybe compile that
and then we had the error again okay
parser before the parentheses so we'll
fix that we'll do the fix again so now
we see that every second it picks a new
shade of gray so we're calling a
function in our code now all fixing
continue so that's kind of cool so the
next thing I want to show though is what
if you have the problem that's a little
bit gnarlier in this case you just look
at it and see what's wrong right but but
you may actually have to use the
debugger once in a while so we're gonna
get and do that I'm just gonna go ahead
and stop this program right now I'm
actually gonna bring up the debugger
window again I can do that just by
clicking on the hammer here say building
debug again and I'll pop it back up so
we actually have the odd colors here let
me before I do that let me actually stop
this guy I want to set a breakpoint
before it opens the window so I'm going
to
I brought up the breakpoint view here
I'm actually going to go to the
breakpoint at line 196 which is one that
I set up earlier this is a breakpoint
right before the view gets created I'm
just going to enable that I can do that
up here or I can do that through a
control click over here so now I want to
launch it now just a debug the sent and
then it will stop at the breakpoint a
couple of things are noteworthy here you
know obviously stop at the breakpoint it
shows me where the program counter is
all those things up here I see that not
only does it show me my variables and
their values but it actually knows that
in window here is a window ref so we
have a custom formatter that prints the
title of the window and the index in the
window lists and some things like that
also notice that error is an OS air is a
NOAA status here so this is where the
framework specific knowledge comes in so
the debugger knows now that error is a
carbon Oh is there and it can actually
show me the right value for the constant
and also you see here a summary of the
event for the D event ref in this case
so what I'm going to do here is to step
a couple of lines here and I'm gonna
step down to line two of five here and
you notice that route changed here it
was invalid before we highlight the
change value in red this indicates that
have changed in the previous step and we
show a summary for that as well
so that's kind of cool one of the things
I'm going to do now is to gonna go down
and there's another breakpoint here I'm
gonna go to enable this breakpoints I'm
going to resume the debugger I could do
this in either as you notice I go back
to the the text editor here or the debug
window I could actually edit and see the
source code in either one it doesn't
really matter I'm gonna continue here
and now it stops at the breakpoint I
just said so this is where we assigned a
rectangle variable I'm just going to go
ahead and step over this and first let
me go down to Cubans it's here it has
garbage values just on the stack now I'm
just going to step over this and notice
that if formats the rectangle
coordinates
according to the carbon carbon
definition of a rectangle but this is
just for
this is kind of confusing what if I
wanted to edit this myself well let's
say I wanted to put in labels I can
actually see here that if I double click
on it I go to the definition of the
formatter and I can just edit it in
place I can see the left is equal to
this value the top is equal to that
value the right is equal to that value
and then I go actually that was the
bottom and then I say are equals now
when I hit return
it actually formats the string according
to the definition that I typed in so you
can reference any arbitrary sub P notes
of a start anyway and this definition is
now stored for me per user in this
project so you can customize it to your
liking so these are just two of the
features that the debugger provides we
have fix a continue which of course lets
you get back up into your app again
without having to restart it great for
logic errors changes or within the curly
braces of a logic of a function and the
other really powerful feature are the
custom data for matters so depending on
whether you're using carbon or cocoa we
automatically load in custom data for
matters and as you saw you can define
your own or modify the ones that we
provide it for you
so that's all our show today there are
more sessions on debugging and on the
build system as well thanks that and
Condor
[Applause]
unfortunately that clock down there is
lying so let's get through the other
features in Xcode we do not have enough
time to get into gory details here about
everything unfortunately but there are a
few other important features in Xcode we
have support for source trees which
allow you to define the location of your
other sources where is your power plant
live etc that is on a per user basis and
also as an option for the whole project
so you can have somewhat heterogeneous
projects layout where different
developers have it at different places
but when you build the final product at
a central location it still finds
everything fine
we have SDK support so you can build
your application say on Jaguar but you
can target both Puma and Panther or vice
versa
we have perforce SCM integration by
popular request we have support at well
Xcode is Apple scriptable so that you
can automate certain tasks and you have
a very fast and efficient documentation
access which will be shown more tomorrow
in 303 now that's just part of what it
takes to create an application this is
just the code and the debugging however
there's also the other part that's the
user visible part that's user interface
and so it is my pleasure to introduce to
you mr. Eric Seymour who is the lead
engineer on interface builder and he's
going to give you an introduction to IB
thanks Stan okay so so far you've been
listening in dealing with code issues
related to your projects and of course
that's very very important but obviously
a big aspect of your projects are user
interfaces and at Apple we build
interfaces with a tool called you called
interface builder and I think for those
of you who haven't seen it a couple of
slides just to let you know what this
thing is are important so what is
interface builder well interface builder
or IB is Apple's way or is Apple's tool
for building aqua compliant user
interfaces and of course it supports
carbon and cocoa and of course works
with Xcode now just to be clear
interface builder is a graphical tool
you drag things off of a pallet drop
them onto windows resize them set
properties and perhaps most importantly
establish relationships drag connections
between things sometimes and perhaps
most importantly between things in your
interface and in your own source code
very very important so where does
interface builder fit in the grand
scheme of things well Xcode manages all
these resources in your project
especially source code and you've been
hearing over the last couple of days all
sorts of techniques for reducing the
amount of time you need to spend in your
source code right reduce your compile
loop reduce the amount of time it takes
to go find something make changes
well interface builder perhaps is the
best example of this because interface
builder does not actually generate
source code as the artifact of your
interface it produces archives of your
interface objects so it's not creating
source code that you would then have to
compile and build into your application
it's just another resource managed by
Xcode compiled or built in the build
process just simply copied into the
final product of the application so
what's new for carbon with interface
builder well you heard that a chive U is
the future of carbon and interface
builder is constantly evolving to
support that notion
you'll notice right out of the gate that
we support several new HIV view based
objects hims use search field scroll
view and more and also and it's not
written down here but we
now support embedding in custom controls
of course we also we also support all of
the new interesting features of Panther
including many controls and other other
important things such as new metrics and
such and then control properties this is
a new feature that I'd like to spend a
few minutes on in carbon support and
what this allows us to do is add ad hoc
data values to our controls right in a
nib file so to do that I'm actually
going to demo well okay and I'm gonna
quit this application because I need to
restart so for this application I also
am going to use clock view standard
shipped example for carbon and let's
just run this thing real quickly here so
I'm just going to run this app okay
clock view pretty straightforward pretty
boring I need to add a feature to this
so the feature that I've added is I want
an image to show up in the background of
this clock so as any good developer I
have a few options of how I'm gonna do
this well clearly I'm going to write
code to do it because this is a custom
control but how do I make it how do I
manifest it in the interface how do i
trigger its inclusion in the interface
well one way to do it is to write more
code compile it into the app another way
is to write some code and perhaps
leverage fix and continue to maybe speed
up that process but another way is to
abstract the inclusion of the actual
image the triggering of that image into
my nib file and so I'm gonna do that
right now I'll quit the application and
I'm going to bring up interface builder
and here is the nib file so to speak the
out the file that contains my user
interface for clock view and this view
right here represents the custom control
that is the clock view and I'm going to
bring up the inspector for this and in
the control inspector for those of you
who may be familiar with the control
inspector of the past you'll notice this
new table view at the bottom and this is
a place that I can associate add hi
data properties right to this control so
at runtime I can pull them out and do
something interesting so I'm going to
add a new property this I'm going to
give it a creator code of my app and
call this image and it's Unicode string
and I happen to have an image in my
project already included called Panther
and I'll just save my nib file hide
interface builder and quick build and
all that did is copy the nib file into
place
no recompiled code image in the
background of my clock now this is
important because this this is important
because this gives me the ability to be
more than just a viewed editor in
interface builder it gives me the
ability to take attributes that I've
coded into my custom view and make them
available at a level where somebody
doesn't actually have to write code to
do it so for example if I go back into
interface builder say I want to have
another one of these I could duplicate
this or drag it off the pallet basically
just create another custom view and this
one I'm going to change I'll stick
another image in there and I'll add a
new property of this and this one's
going to be rotate and this happens to
be a float value now this editor gives
us the ability to set the actual type of
the data that I can put that I can
retrieve when I get that property this
is a boolean and I'm gonna call that
true to resize my window and I'm gonna
save and hide interface builder quick
compile and run and two objects slightly
different data in the nib file but
effectively I've repurposed that object
without writing any new code okay
so let's go back to the main screen
all right there's my demo all right so
let's talk about cocoa for a few moments
so of course in cocoa we're supporting
just like with carbon all the Panther
controls and sizes and interesting
features one of those of course is a
brand new feature called the controller
layer support as hopefully most of you
saw yesterday there was a we're
supporting WebKit and for those of you
who may be familiar with interface
builder of the past we're trying to
satisfy a long requested feature and
that's adding data cell support the
table columns so you can just drag them
off your pallet drop them on top of your
column and you have your cell and we've
also revamped the connections inspector
so to demo this I actually want to focus
there I only have so much time and I
want to focus on one very important
feature and that's the controller layer
now yesterday hopefully most of you saw
the example where we built a web a web
browser without writing any code and we
didn't just build a web browser then
after we were done building the basics
which is the old ivy demo of target
action we polished it we made it really
clean and hopefully you recognize that
typically to make an application really
clean you got to write code right you
have to take advantage of more than you
can do with just wiring up a few
connections and we did this with this
new feature called the controller layer
now I'm gonna deviate from that demo I'm
not actually going to show that to you
because I think it's important to show
the raw materials of what the controller
layer is giving you inside interface
builder so to do that let's quit out of
this and quit Xcode and just go into IB
and let's get rid of this because I
don't need it anymore I'm going to
create a new application here and I'm
gonna do the staple in of interface
builder demos just to start and that's
the slider text field demo so I can hear
the yawns everybody's seen this before
but this is an important moment in the
history of IB
so there's my slider oh and oh by the
way let's just pop pop a new feature
here let's just make that a mini slider
just so that I can demo yet a new
feature and I'm gonna make my text field
really large another thing that's worth
noting is we've reorganized a lot of the
pallets and the inspectors to
accommodate for new features hopefully
you find them more streamlined and we
appreciate feedback so when I'm doing
this what I need to do is establish a
connection between this slider in this
text field I'd like when my slider moves
I'd like the value in my text field to
change okay so I do that by dragging a
connection in interface builder and when
I do that interface builder gives me a
list of all of the possible things that
that text field can do when it receives
a message so I'm gonna choose take
double value from now by the way I just
want to point out another little feature
that we've added to interface builder
we've added type-ahead support so if
this list we're really long I could just
type start typing keys P take value from
and it'll jump around this is especially
important for instance if you target
first responder and you've got to scroll
and find the thing that you want to that
you want to deal with okay
so let's make sure that I have that
connection take float value from tester
interface right so now when I'm moving
my slider I know it's a mini control
charter to hit I change my value okay so
this is kind of interesting right and
everybody many of you have seen this but
the reality is that text field has a
whole lot more capability than just
showing a value right and we take
advantage of that today in our
interfaces we have colors we have sizes
we enable items we disabled items
sometimes we hide them right and so what
do we do we go to code now what I'd like
to do is unwire this and your will
disconnect that and I'd like to use the
controller layer to solve this problem
for us so to do that I need a controller
and so we have a new palette here it's
the controller palette and I'm going to
use the most basic controller we have
which is an object controller and you
can think of this like a traffic like a
I was going to say traffic cop you could
think of this like a traffic cop it
basically is going to look at all the
pieces of our interface and it's going
to monitor this when it's
a change there it's going to change a
value there it's going to do all the
right things for us so that we don't
have to write that code okay so I have
my controller now I need to make some
bindings to this controller so that this
actually does something interesting so
I'm going to go to a brand new inspector
an interface builder and it's a very
important one so we put it right under
attributes it's called bindings and the
bindings inspector is interface builders
window into all those other properties
you had to go to code for in the past
okay so on my slider which I have
selected now I could enable it or hide
it it has maximum in value and it also
has value and I'm going to choose my
object controller which I just created
and I'm gonna bind to a key called
number just an arbitrary key then I'm
going to go to my text field note that
it has a much longer list of things that
you can do with the text field it's just
a more interesting widget and I'm going
to choose my object controller and I'm
gonna bind to the same value number but
I'm going to do something more here I'm
going to close my value and I'm gonna go
to font size and I'm going to go to my
object controller and I'm gonna bind
font size to that exact same value okay
and when I test my interface now not
only is my value changing but my font
size is changing as well now this is
this is the new slider text field for
interface builder and this is what I
meant when this is kind of a
groundbreaking step for interface
builder because for years we've been
asked how come I can't have more than
one action or how come I can't have more
than one target and the reality is this
that's the wrong way to solve this
problem the right way to solve this
problem is to have a controller one of
them be the controller for all of these
pieces and all you have to do to that
controller is give it its its give it
give it the rule list the roster okay
here's what you need to do controller
you need to monitor this thing and that
thing and these things over here and oh
by the way it'd be really great if you
could persist this data in my data model
too if so controllers also have implied
depending on the controller type the
ability to persist that data in the user
defaults database or perhaps another
database I'm just using a raw object
controller here so it doesn't actually
have persistence but I could have used
the user default controller
so that's what I wanted to show you for
cocoa and I have lost my clicker it just
must be over here now there's one more
thing and that's compatibility checking
so we're on our fourth major release of
Mac OS 10 and that means that they're
all these features trickled into
releases month after month year after
year and you have to support them and we
we recognize that we need to make it
easier on you to support these features
reliably so what we have done an
interface builder has is add better
compatibility checking support so
basically select the format you want
your nib to be in tell it what the
target platform is the oldest target
platform and watch for errors an
interface builder will warn you when it
thinks you're about to do something
wrong for example if you are targeting
Mac OS 10.1 as your oldest target
platform perhaps you shouldn't pull a
spinning progress indicator in because
that wasn't supported on 10.1 and it
just won't work in fact that's a data
loss one so you won't even be able to
save your nib so that's all I have to
talk about today thank you
thank you Eric it was a very interesting
demo there will be more on that summary
Xcode gives you a very efficient
workflow it's fast in all respects it
facets building at debugging and also
helps you to be fast on your end through
profiling we want you to use it install
it both on Jaguar and Panther in your
package there should be two CDs one for
Panther one for Jaguar 99% of all
features are available in Jaguar all
over Mont Panther and please do send us
feedback the product can be only as good
as you help us make it by giving us
feedback so to start with feedback or
who to contact Godfrey de Georgie
there are mailing lists there is an
Xcode specific mailing list at the very
bottom we do read this heck our vice
president has said that he will be
reading that email so and reference
library
the usual yes and the roadmap session
three on three increasing productivity
twenty four hours here there is a
special session about GCC there's a
session about performance tuning with
the performance tools there's a special
session about carbon with Xcode and
there will be the feedback session where
he can give us a earful of feedback and
finally debugging on Mac os10 after the
feedback session
you