Join Todd Perkins for an in-depth discussion in this video Introduction to Xcode, part of Cocoa with Swift Essential Training.
Let's take a tour of Xcode. Now of course if you're already familiar with Xcode and objective C and you're just watching this course to learn Swift you might want to skip this movie. Let's create a new Xcode project and under OS X application for the template I'm going to choose Cocoa application and click Next. For the product name. I'll call this XCodeDemo. For the language I'm going to choose Swift and I'll leave the other settings as they are and click Next. And before I save this project on my desktop I'm going to uncheck create get repository and then I'm going to click create to save the project onto my desktop.
And now we've successfully created an Xcode project. In Xcode, a project is a named group of files and folders. Let's look at those files and folders on the desktop. I'll minimize XCode and open up the XCodeDemo folder. In the XCodeDemo folder, I'll see a subfolder called XCodeDemo that contains files and folders relevant to my project. I'll see the Xcode project file, called xcodedemo.xcodeprog. This is the file that if you double click, will launch Xcode and open up your project.
And then there's the X code demo test folder. So let's look inside of X code demo sub-folder, and compare it's files and folders to what we have in X code. So I'll open back up Xcode. So here's out project. And we can files and folders laid out here. And if I tab over to Finder, you'll see that the files and folders and the desktop don't quite line up to those in Xcode. The reason for that is that Xcode has more complex organizations for files, than simply files and folders.
For example, you can create groups of files that don't necessarily change your folder structure on your computer. The interface for Xcode can be customized at the top right of the screen. There are two sets of three buttons. The set on the left shows options for editing code files and the set on the right shows options for editing the layout of Xcode. The blue options are the ones that are highlighted so if I click I can toggle hiding or showing. The element on the left.
So I want that element there. Then I can click the bottom one to show and hide options on the bottom or the right one to show and hide options on the right. This is about as far as you can go to customize the appearance of Xcode. Let's move over to the left side of the screen and talk about what is known as the Navigator. The Navigator has different options. For browsing through your project. You can search your project. You can look for errors. But right now since we haven't compiled any code yet we don't see much information here.
So the place where you're going to be spending most of your time is the project navigator which is the icon that looks like a folder. When I am in the Project Navigator, I can single click files to view their contents. For example, AppDelegate.swift is a code file and MainMenu.xib is a user interface file. Note that if you double click these files, a separate window opens up. For me, this feels cluttered and so I prefer not to use the double click option.
So I am always single clicking files in this course. Of course you can hide and show contents of folders by clicking the arrows to the left of the folder names. The editor is the center portion of the screen and you'll notice that it has been changing with what content I have selected. It allows me to edit that content. So I can edit the code file by single clicking on AppDelegate.swift, or the user interface by single clicking MainMenu.zip. Let's look at the right side of the screen. The right side of the screen is context sensitive so depending on what I have selected I'll see different options for modifying code or for modifying a user interface.
Just like the navigator on the left side of the screen, the right side of the screen has different options that you can select as well. Notice that the options change when I'm looking at a code file versus a user interface file. We'll explore these options more later on. The right side of the screen is also broken up into a top and a bottom section. The bottom section includes options including the object library which enables us to drag and drop elements onto the screen for our user interface. Again, we'll be exploring this more in detail later on.
If you saw my code, you may have noticed few different things like I have line numbers and my font is a different size and font face than the default that ships with Xcode. We looked at how to modify this in a previous movie but as a reminder you can modify these settings under Xcode > Preferences > Fonts and Colors, and Text Editing. So while Xcode can be an intimidating application as you get used to working in it throughout this course. It'll become more and more familiar and intuitive to find what you need to work on.
- Creating your first Cocoa app
- Understanding the relationship between Cocoa and Swift
- Creating a playground
- Working with variables, functions, arrays, and loops
- Creating basic interactions and quick connections
- Building custom controller classes
- Using delegates
- Creating and arranging interface elements
- Using data controls
- Debugging and troubleshooting
- Distributing a Cocoa application
Skill Level Beginner
Q: This course was updated on 5/03/2016. What changed?
A: We added one new tutorial explaining how the Swift 2 and Xcode 7 updates affect the training in this course (which was recorded using Swift 1 and Xcode 6). The changes are minor, so Todd provides some short tips for using optionals, coding with NSDate() and NSURL(string:), and working with other smaller changes in the framework.