If you been using Xcode heavily for a while, you may find this movie a bit of a do over and you're welcome to skip it. But if you're fairly new to Apple Development. Or it's been a while since you last used Xcode, let's take a couple of minutes to go over the basics. We will spend most of our time here. Xcode is our IDE, our Integrated Development Environment. Like Visual Studio, or Eclipse, or Aptana. And being an IDE just means it does more than one thing. We don't just write our code in Xcode, we design our user interfaces here. We compile our applications here.
We use it to test and debug. We use it to browse documentation and find help. But at its core, Xcode is here to organize all the files in our application. And it groups them together into projects, as we've seen. Projects are just a way of collecting a bunch of files together and giving them a name. And when you create a new project in Xcode. Either from the welcome screen, or by saying File > New Project. We get our selection of templates. Now Xcode has a lot of templates. Although in this course, we are almost always interested in the iOS application section.
Once again, I'm just going to create a Single View application. We'll get into the others later. And give this one a simple name. And as I mentioned earlier, I don't use spaces in my product names. So I'll call this one Demo Xcode. It's going to ask me for all this same naming info. But the organization name and company identify, it will keep from the last time. Coming down I'll make sure that the device is set to iPhone. Click Next. And tell it where to save it. I'm just going to save this Demo XCode project to my Desktop.
So the project is now created. But before we go exploring within XCode, I'm going to go and take a quick look at what was created when we did that. So here's the folder that we got, Demo Xcode. If I go into that, and I'm just going to change it so we can view it a little better. We'll see that Xcode gave us quite a few different things here. But what you might see is that some of them match what I see in Xcode itself, and some of them don't. If I expand the folders in Xcode, I can see that I have a main.m. If I look in my finder, I can also see that I have a main.m.
But the folders that I see in Xcode don't exactly match the ones I'll see in the finder. Like, I've got a Supporting Files folder in Xcode that doesn't seem to exist over here in the finder. Don't worry too much about that. Xcode allows us more ways of grouping these files than the actual folders on the drive. However, there is one important one that I'll see in finder. One very useful one, which is this guy. The Demo Xcode.xcode project. Or Xcode project file. This is the file that contains all the settings for this particular project.
And if Xcode was closed, double clicking this will be the quickest way to open up Xcode, with all these project files loaded. Okay, so let's talk about the best way around the Xcode 5 interface. We are of course in a programming environment. So everything is oriented around this editing section in the middle. Whether that's letting us edit code, or letting us edit a user interface. Now the toolbar up at the top as you've no doubt guessed, lets you run the application. We've got the play and stop buttons. This central section here that looks like a small LCD display, will show messages about anything that Xcode is doing as we work with our project.
It's a little like how iTunes displays messages when you're copying or syncing. Over on the top right, you should have two groups of three buttons. Right now, in the first group we've got the first one highlighted. This means we're using what's called the standard editor. There are different ways to edit your code files, and your user interface files. But we'll see these other ones later. Then the second section we have these three separate buttons. Dock left section, a dock bottom section, dock right. All these buttons do is toggle the different areas of Xcode on and off.
Now unlike some other applications, in Xcode you do not and cannot rearrange or detach or drag and drop panes from one area to another. This is an Apple Development Environment. The layout is the layout. So this section on the left stays on the left. You can choose to make it visible or not. But that's the only options that you have with it. And this left hand section over here is called the navigator. The navigator is the way to navigate. To get around everything in and everything about the project. All my files, all my settings, all my different options.
I can expand folders. And by single clicking, I can focus on a single code file. If I wanted to double click that, it would open up in a separate window. Most of the time in this course, I'll just be single clicking the files. Now this left section actually contains eight different navigators. Each with these buttons along the top here. You can move between them by clicking the buttons. At the moment with a simple project like this, there's not much to see apart from in that first section. But you will be able to view things like issues and log messages using these.
Sometimes Xcode will switch you to a different navigator section if useful. But you don't need to memorize them all right now. The most important navigator is the first one, the project navigator. The one that looks like a folder. A useful shortcut for this is Cmd + 1. Even if you have that section closed. Hitting Cmd+1, will open it back up again. This is a view, not just of all the files in your project. And things that you can switch between. But also the project settings itself. Clicking this very top icon here, with the name of the project.
Will let us view the top level settings, and not just work on one single file in the project. And we'll get more into this a little later on. But the same as the left hand side can be turned on and off. So can the right hand side. And this side contains two separate parts. The inspectors at the top, and some libraries in the bottom section. Now the arrangement here is not random. There is a point to the whole overall layout of Xcode. We can think of the navigators on the left as showing, everything about the project. As the central section is showing, the one thing that I'm working on.
And then the inspectors on the right, are context sensitive. Like many IDEs, these change based on the one file that I am working on, or whatever I have selected. So with one of these highlighted, I can see that it actually shifts as I click around to different files in that section. Like the navigators, there are different sections to the inspectors that can be highlighted with these buttons up at the top. But these change a little bit. If I've clicked on a code file, I'll typically see two different sections to it. If I'm editing an iOS user interface, I'll typically see eight different sections to it.
Once again, don't worry too much right now but memorizing these. We will explore all of them as we go. Now the libraries below, in the lower section here, are really the simplest. These really do not change based on what I have selected. They're always the same. Libraries contain different selections. Try that again. Libraries contain collections of things you might want to add to your project. Like a library of user interface elements in the object library. Or a libaray of code snippets. Things here can be dragged and dropped into my project or into my code files.
Now Xcode like most other IDEs has preferences. Things that you can customize about this application, to make it work better for you. I've made two small changes to it, just to make my code easier to read. I've increased the size of the code font. And I've added line numbers to it. If you wanted to add those yourself, you'd just find it in the Preference section. Fonts and colors allows me to select from different themes. I've just selected the Presentation one. The only other option I've changed is in the Text Editing section. I've turned on Line Numbers, so they show up here when I'm talking about certain lines of code during the course.
Now when we're editing text in Xcode. Like most modern IDEs, we will get automatic indentation. We'll get color coding of the different pieces of syntax. Showing the difference between comments here in green. Keywords and classnames and so on. We also get Code Sense, which is Xcodes auto completion feature. If I start typing and I'll start typing say, the letters u i, I'll get this popup appear, I can use the cursor keys to move up and down, and just hit return for anything that I'd like to select. And that helps us a lot because there are a lot of long names for objective c classes and methods in iOS development.
Now notice I already have this exclamation mark appearing in the left hand side here. That's because XCode does try to highlight issues with your code as you're typing it. And it's often quite quick about this. You haven't even finished a line before it starts complaining about it. So you will see that a lot. I don't actually need that line of code, so I'm just going to go ahead and delete it. Now, there is a lot more to Xcode. Options to connect to source control repositories, debugging. Performance tools, code snippets, ways to help you manage your projects. But this should be enough to let us move forward.
View More iOS Tutorials at Lynda.com