Beginning iOS 10 Programming with Swift

Chapter 1
Getting Started with Xcode 8 Development

So you want to create your own app? That's great! Creating an app is a fun and rewarding experience. But before we begin to dive into iOS programming, let's go through the tools you need to build an app.

1. Get a Mac

First, you need a Mac. It's the basic requirement for iOS development. To develop an iPhone (or iPad) app, you need to get a Mac with an Intel-based processor running on Mac OS X version 10.10 (or later). If you now own a PC, the cheapest option is to purchase the Mac Mini. As of this writing, the retail price of the entry model is US$499. You can hook it up with the monitor of your PC. The basic model of Mac mini comes with a 1.4GHz dual-core Intel Core i5 processor and 4GB memory. It should be good enough to run the iOS development tools smoothly. Of course, if you have a bigger budget, get the higher model or an iMac with better processing power.

2. Register Your Apple ID

You will need an Apple ID to download Xcode, access iOS SDK documentation, and other technical resources. Most importantly, it will allow you to deploy your app to a real iPhone/iPad for testing.

If you have downloaded an app from the App Store, it is quite sure that you already own an Apple ID. In case you haven't created your Apple ID before, you have to get one. Simply go to Apple's website (https://appleid.apple.com/account) and follow the procedures for registration.

3. Install Xcode

To start developing iOS apps, Xcode is the only tool you need to download. Xcode is an integrated development environment (IDE) provided by Apple. Xcode provides everything you need to kick start your app development. It already bundles the latest version of the iOS SDK (short for Software Development Kit), a built-in source code editor, graphic user interface (UI) editor, debugging tools and many more. Most importantly, Xcode comes with an iPhone (and iPad) simulator so you can test your app without the real devices.

You have two ways to install Xcode: 1. Download it through Mac App Store. 2. Manually download it from Apple's developer website.

Download Xcode from Mac App Store

To download Xcode, launch the Mac App Store on your Mac. If you're using the latest version of Mac OS, you should be able to open the Mac App Store by clicking the icon in the dock. In case you can't find it, you may need to upgrade your Mac OS.

Figure 1-1. App Store icon in the dock
Figure 1-1. App Store icon in the dock

In the Mac App Store, simply search "Xcode" and click the"Get" button to download it.

Figure 1-2. Download Xcode 8
Figure 1-2. Download Xcode 8

Once you complete the installation process, you will find the Xcode folder in the Launchpad.

Figure 1-3. Xcode icon in the Launchpad
Figure 1-3. Xcode icon in the Launchpad

At the time of this writing, the latest version of Xcode is 8.0. Throughout this book, we will use this version of Xcode to create the demo apps. Even if you have installed Xcode before, I suggest you upgrade to the latest version. This should make it easier for you to follow the tutorials.

Download Xcode 8 from Developer's website

Normally you can download Xcode from the Mac App Store, which is the recommended way for beginners. For any reason you don't want to use Mac App Store, you can download Xcode 8 manually. To get a copy of it, you have to sign into the Apple Developer website (http://developer.apple.com/register/). Select Download Tools and then click Download Xcode 8 GM.

Once the file is downloaded, double-click and install it.

4. Enroll in the Apple Developer Program (Optional)

A common question about developing an iOS app is whether you need to enroll in the Apple Developer Program (https://developer.apple.com/programs/). The short answer is optional. First, Xcode already includes a built-in iPhone and iPad simulator. You can develop and test out your app on your Mac, without enrolling in the program.

Starting from Xcode 7, Apple has changed its policy regarding permissions required to build and run apps on devices. Before that, the company required you to pay $99 per year in order to deploy and run your apps on a physical iPhone or iPad. Now, program membership is no longer required. Everyone can test their apps on a real device without enrolling into the Apple Developer Program. Having that said, if you want to try out some advanced features such as in-app purchase and CloudKit, you still need to apply for the program membership. Most importantly, you're not able to submit your app to App Store without paying $99 annually.

So, should you enroll into the program now? The Apple Developer Program costs US$99 per year. It's not big money but it's not cheap either. As you're reading this book, you're probably a newcomer and just start exploring iOS development. The book is written for beginners. We will first start with something simple. You are not going to tap into the advanced features yet.

Therefore, even if you do not enroll into the program, you will still be able to build an app and test it on your device. So save your money for now. I will let you know when you need to enroll into the program. At that time, you're encouraged to join the program as you're ready to publish the app to the App Store!

5. What You Need to Learn

Now that you have configured everything you need to start iOS app development, let me answer another common question from beginners before moving on. A lot people have asked about what skills you need to learn in order to develop an iOS app. In brief, it comes down to three things:

  • Learn Swift - Swift is now the recommended programming language for writing iOS apps.
  • Learn Xcode - Xcode is the development tool for you to design the app UI, write Swift code, and build your apps.
  • Understand the iOS software development kit - Apple provides the software development kit for developers to make our lives simpler. This kit comes with a set of software tools and APIs that empowers you to develop iOS apps. For example, if you want to display a web page in your app, the SDK provides a built-in browser that lets you embed right in your application.

You will have to equip yourself with knowledge on the above three areas. That's a lot of stuff. But no worries. You'll learn the skills as you read through the book.

That's all for the introduction. Take some time to register as an Apple developer and install Xcode 8. When we move onto the next chapter, we will start programming in Swift. So get ready!