1. Got Tools?
If you want to build something, you are probably going to need some tools: hammer, nails, laser, crane, and one of those IKEA hex wrenches. Building iOS apps requires a collection of tools called Xcode .
This chapter will show you how to get and install Xcode and give you a brief tour of it, so youll know your way around. If youve already installed and used Xcode, check the Requirements section to make sure you have everything you need, but you can probably skip most of this chapter.
Requirements
In this book, you will create apps that run on iOS version 8. Creating an app for iOS 8 requires Xcode version 6. Xcode 6 requires OS X version 10.9 (a.k.a. Mavericks), which requires an Intel-based Mac. Did you get all of that? Heres your complete checklist:
Intel-based Mac
OS X 10.9 (or newer)
A few gigabytes of free disk space
An Internet connection
At least one iOS device (iPad Touch, iPhone, or iPad) running iOS 8.0 (or newer)
Make sure you have an Intel-based Mac computer with OS X 10.9 (Mavericks), or newer, installed, enough disk space, and an Internet connection. You can do all of your initial app development right on your Mac, but at some point youll want to run your apps on a real iOS device (iPhone, iPod Touch, or iPad), and for that youll need one.
Note
As a general rule, newer versions are better. The examples in this book were developed for iOS 8.0, built using Xcode 6.1, running on OS X 10.10 (Yosemite). By the time you read this, there will probably be a newer version of all of these, and thats OK. Read the Xcode and iOS release notes to see what has changed.
Installing Xcode
Apple has made installing Xcode as easy as possible. On your Mac, launch the App Store applicationnot to be confused with the App Store for iOS, which you find in iTunes. Find the Developer Tools category or just search for Xcode . Figure show the Xcode app in the Mac App Store.
Figure 1-1.
Xcode in the App Store
Click the Install button to start downloading Xcode. This will take a while (see Figure ). You can monitor its progress from the Purchases tab of the App Store. Be patient. Xcode is huge, and even with a fast Internet connection, it will take some time to install.
Figure 1-2.
Downloading Xcode
While Xcode is downloading, lets talk about it and some related topics.
What Is Xcode?
So, what is this huge application youre downloading?
Xcode is an integrated development environment (IDE). Modern software development requires a dizzying number of different programs. To build and test an iOS app, youre going to need editors, compilers, linkers, syntax checkers, cryptographic signers, resource compilers, debuggers, simulators, performance analyzers, and more. But you dont have to worry about that; Xcode orchestrates all of those individual tools for you. All you have to do is use the Xcode interface to design your app, and Xcode will decide what tools need to be run and when. In other words, Xcode puts the I in IDE.
As well as including all of the tools youll need, Xcode can host a number of software development kits (SDKs). An SDK is a collection of files that supply Xcode with what it needs to build an app for a particular operating system, like iOS 8. Xcode downloads with an SDK to build iOS apps and with an SDK to build OS X apps, for the most recent versions of each. You can download additional SDKs as needed.
An SDK will consist of one or more frameworks . A framework tells Xcode exactly how your application can use an iOS service. This is called an application programming interface (API). While its possible to write code in your app to do just about anything, much of what it will be doing is making requests to iOS to do things that have already been written for you: display an alert, look up a word in the dictionary, take a picture, play a song, and so on. Most of this book will be showing you how to use those built-in services.
Note
A framework is a bundle of files in a folder, much like the app bundles youll be creating in this book. Instead of containing an app, however, a framework contains the files your app needs to use a particular segment of the operating system. For example, all of the functions, constants, classes, and resources needed to draw things on the screen are in the Core Graphics framework. The AVFoundation framework contains classes that let you record and playback audio. Want to know where you are? Youll need the functions in the CoreLocation framework. There are scores of these individual frameworks.
Wow, thats a lot of acronyms! Lets review them.
IDE : Integrated development environment. Xcode is an IDE.
SDK : Software development kit. The supporting files that let you build an app for a particular operating system, like iOS 8.
API : Application programming interface. A published set of functions, classes, and definitions that describe how your app can use a particular service.
You dont need to memorize these. Its just good to know what they mean when you hear them or talk to other programmers.
Becoming an iOS Developer
The fact that youre reading this book makes you an iOS developerat least in spirit. To become an official iOS developer, you need to join Apples iOS Developer program.
You must be an iOS developer if you want to do any of the following:
Sell, or give away, your apps through Apples App Store
Gain access to Apples Developer Forums and support resources
Give your apps to people directly (outside of the App Store)
Develop apps that use Game Kit, in-app purchases, push notifications, or other technologies that depend on Apple-operated services
Test your apps on a real iOS device
The first reason is the one that prompts most developers to join the program and is probably the reason youll join. You dont, however, have to join to build, test, and run your apps in Xcodes simulator. If you never plan to distribute your apps through the App Store or run your app on an iOS device, you may never need to become an official iOS developer. You can get through most of this book without joining.
Another reason for joining is to gain access to the iOS Developers community and support programs. Apples online forums contain a treasure trove of information. If you run into a problem and cant find the answer, theres a good chance someone else has already bumped into the same problem. A quick search of the Developer Forums will probably reveal an answer. If not, post your question and someone might have an answer for you.
Even if you dont plan to sell or give away your masterpiece on the App Store, there are a couple of other reasons to join. If you want to install your app on a device, Apple requires that you become a registered developer. Apple will then generate special files that will permit your app to be installed on an iOS device.