Swift iOS Programming for Kids
上QQ阅读APP看书,第一时间看更新

Xcode

If you were to send a text to a friend from your mobile phone, what steps would you take? What would you say? You would open up the messages application and write out a message to your friend telling them that you're learning how to code. After typing out your message on the screen, you think twice about adding a few pizza emojis to it.  After sending the message, your mobile phone is able to interpret that information and send it over to your friend, all within a few seconds-how amazing!

Tip

All related source code for this chapter can be found here: https://github.com/swift-book-projects/swift-3-programming-for-kids/tree/master/Chapter-2

Powering the messages application that you're using to text your friend is code. This code is a list of instructions that is processed by a computer, written by developers like yourself. But where does a developer write code? It is written in an application that is known as an Integrated Development Environment (IDE).  An IDE is a piece of software that combines the basic tools developers need to write, test, and run their applications. Xcode is a specific IDE that includes everything you need to create amazing apps for iPhone, iPad, Mac, Apple Watch, and Apple TV. It is shown in the following screenshot:

This is a screenshot of Xcode. We've begun working on an iOS app that displays a red heart on a blue background. After showing our friends how gorgeous our iOS app looks, one told us how we're going about it all wrong and that we should have a blue heart on a red background. Xcode allows us to easily make these changes:

Downloading Xcode

In order for you to be able to install the latest version of Xcode (at the time of writing, it is version 8.2.1), you need to be on a Mac. You need to be running OS X 10.11.5 or later to install Xcode (at the time of writing).

The following are the instructions to download Xcode:

  1. Open the App Store application on your Mac:

     

  2. When in the App Store application, in the upper right-hand corner, search for Xcode, as illustrated:
  3. Download Xcode; as of version 8.1, it's 4.47 GB:

Playground

After Xcode has finished installing, open the Finder application, which you should find on your toolbar (it looks like a smiling face). Within Finder, you should see that you have access to various directories. Select the applications directory, which should then list all of the available applications on your Mac. You should find Xcode in that list of applications. Considering, you might be working with Xcode a lot, you should drag this application down to your Dock for easy access. After doing so, launch Xcode.

After launching Xcode, you will be met with the following launch screen:

We are given three options. For now, we are most interested in Get started with a playground. Its description states, Explore new ideas quickly and easily. What exactly is a playground? 

A playground is a place where we can write Swift code and see the results immediately. You won't be building apps in a playground, but they are a great place to learn:

Writing Swift code in a playground is very simple. As you're writing code, you will see the results in the right-hand pane, updated in real time, as illustrated:

In subsequent chapters, you will be tasked with writing code in a playground file. This will make your learning experience more interactive. You will be able to see, in real time, whether or not your code (list of instructions) is doing what you expect.

You are now equipped with the necessary tools to begin your journey; We wish you luck!