Last time we saw how to create a C program in Visual Studio. Even if you plan to use Xcode in this class, you should go watch that video, because we cover ideas behind creating a C program. Once you've watched that video, come back here, and we'll go through how to create a C program using Xcode. So before we can actually use Xcode to write a C program, we actually have to start it up, and I've provided a document with these instructions, but I'll walk you through them here as well. We can go to the "Finder" down here on the lower left, and click on it, and select applications in the paint on the left, and then we can find Xcode, it's all alphabetical. So this with the hammer and the blueprint is Xcode. So if you were to click that, you'd start up Xcode. You can also come down here to the Launchpad, and you can click the "Launchpad", and you might have to swipe left and right, but my XCode is down here on the bottom right. So I could click that to start up Xcode. The way I usually do it, is I've actually added it to the doc, and I give you instructions in the document for how you do that, so I can just click it from the dock to open up Xcode. Now that we're here, we can create a new Xcode project. So that's the middle choice over here in the left. So I will click that. The kind of project that we want to build, make sure you've selected macOS up here on the top. In the application section, Command Line Tool is the thing we're developing. So select that, and click "Next". Here's where you put your project name. So I'll call this PrintMessage just like we did in the previous lecture. This drop-down down here probably defaults to Swift, the very first time you use Xcode, that is not what we're programming in here in this course. So be sure to change that to C, and it will always have C in there from that point on until you change it to some other language, which you won't have to do for this course. Now I'll say "Next", and then I decide where I'm going to save it, and you don't care where I'm going to save it. So I'll do that and we'll move on, and here's our project. Over here on the left, I've been already provided a main.c file. So I'll click that, and here you go. Xcode actually gives us a template for our C program, and even prints Hello World but we want to have the same message that we had before. I'm going to add a blank line here, and of course, I usually have my curly brace on the next line rather than on that first line. So you can choose to do that or not. Of course, I'll change this comment, to say print a message, and I'll change the message that it prints. To build this I say command B, and as you can see down here on the bottom I got a build succeeded message. That's good, I didn't have any errors in my code. To run it, I use command R, and when I do that, it does rebuild it, and then I see my output down here on the bottom. So that's how we can write, build, and run our program. The next thing I want to show you is how to actually Debug in X code, and even though you probably won't need to do that at this point in the course, later on you'll probably need to use the debugger to figure out problems in your code. When that happens you can come back to this video lecture and remind yourself how to use the debugger. So here are the big ideas; on the left next to the line number, if I left click, I've added what's called a breakpoint, and we can tell that because of this blue flag that's added on that line. So we add breakpoints so that when we run our code, when it reaches a breakpoint it will stop running, it breaks, it doesn't actually break into pieces, it breaks the execution of the program and stops there. I'm going to now that I've added a breakpoint, I'm going to command R, and it runs up to that breakpoint, and as you can see it's highlighted, so it tells us it has stopped here, and you can also see down in the output window that it hasn't printed that message yet, because it hasn't executed this line of code. It executes this line of code when we continue, and we can continue by clicking "Debug", continue, or we can step over. Let's actually step over which will just execute this line of code, and eventually you'll remember that's F6. But for now, I'll click "Step Over", and that just executed this single line of code. So the next line of code is highlighted, and if you look down here, you can see that it did in fact print out that message in the output. So now at this point, I'm all done demonstrating debugging, so I'll say continue, and that goes all the way to the end of the program and stops. You probably don't want to leave your breakpoint sitting in your program forever. So to remove it, we come over here, put your mouse over the blue flag and you can right click and delete it. That's all there is to building a small C program in Xcode. One final comment before I end this lecture. You may see warnings in Xcode that you're not seeing in the Visual Studio lectures, don't worry about that, lots of different development environments have lots of different settings for which warnings to provide and which warnings to not provide. For the purposes of this course, I'm providing you with sufficiently robust code that we can solve the problems we have in this particular course. So don't worry about that, in general as programmers we care about warnings, and you should as the programmer care about warnings, but if your warnings don't exactly match the warnings that we see or don't see in the video, don't worry about it. As a reminder, I'll be providing Xcode projects for all of the video lectures in the course. So if you choose to use Xcode, you're fine, you don't have to worry that you're missing out on something.