Join John Nastos for an in-depth discussion in this video Creating a new project, part of Building an iOS Address Book App.
- [Voiceover] It's time to start building our project. So the first thing I'll do is open Xcode. If you don't have Xcode, you can find it in the Mac app store. It's a simple install process, and you can get started right away writing code, and running your app in the simulator. I'm using Xcode version 7.3.1 for this course. Before you start, you may want to check to see that you have the most recent version installed on your machine. I'm going to create a new Xcode project.
Then, under iOS and Application, from all the available choices I'm going to choose Master Detail Application. I'll name it CustomAddressBook. You can choose whatever name you want, as well as whatever organization name, and organization identifier that you want. Then, I'll make sure that the language is set to Swift, and the devices are set to Universal. I'll end up using tests later on in this course, so I'll make sure that include unit tests, and include UI tests are both checked.
Because I won't be using core data, I can leave the use core data check box, unchecked. Then, I can choose where to save the project. Once the project is open, you can see that Xcode has created a fair amount of structure to the project. Let's look at what's here already. First, there's the project info screen. Here, you can see some of the settings that Xcode uses to identify, build, and run your project. For example, you can see that the bundle identifier that I chose is listed here as well as the fact that the app is set up for Universal device sizes.
In the left-hand column, you can see that there are targets set up for the app. As well as for the unit and UI tests. In the Project Navigator on the far left of the Xcode window, I can see some of the other files that the project has in it. Let's take a quick look at some of these. First, AppDelegate.Swift. Every iOS Swift application has an application delegate. By looking at the names of some of the methods and the comment and descriptions that Xcode has provided, you can get an idea of some of the responsibilities that an app delegate generally has.
For example, the app delegate will get notified if the application enters the background, or comes back to the foreground and can execute code when one of these events happens. Next, let's take a quick look at the main.storyboard file. This file is where we'll later build most of the user interface to the application. Including placement of some UI elements like buttons and labels. And we will manage transitions between screens and the connections between those screens and the code behind them.
Because we chose Master Detail Application when setting up the project, there's already a fair amount going on in this file. I'll describe more of what's going on later in the videos. Lastly, let's look at MasterViewController.Swift. In the story board, there was a split view controller, and one of the view controllers was called the MasterViewController. That screen is connected to this Swift file, which contains the actual code in charge of that screen. As you can see, there's already a lot of code here.
Xcode provides it in a template, with methods that will get called for this view controller. During the course, we'll edit this template to fit the needs of our specific app.
Build the project step-by-step and then use what you've learned to explore your own app ideas.
- Creating the project in Xcode
- Using Auto Layout to design the UI
- Attaching the interface to the code
- Creating the data model, including a Person class
- Adding stored data to the UI
- Displaying a contact's address with MapKit
- Linking contact info to other iOS apps
- Adding persistence
- Working with table views
- Writing tests
- Preparing to publish the app in the App Store