Apple Watch App Development - Steven F. Daniel - E-Book

Apple Watch App Development E-Book

Steven F. Daniel

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Build real-world applications for the Apple Watch platform using the WatchKit framework and Swift 2.0

About This Book

  • Find out how to download and install the Xcode development tools before learning about Xcode playgrounds and the Swift programming language
  • Discover everything you need to know about the WatchKit platform architecture, its classes, as well its limitations
  • This book introduces you to the very latest mobile platform with hands-on instructions so you can build your very own Apple Watch apps

Who This Book Is For

This book is for developers who are interested in creating amazing apps for the Apple Watch platform. Readers are expected to have no prior experience of programming.

What You Will Learn

  • Navigate within the WatchKit interface using the page-based, modal, and hierarchical navigation techniques
  • Work with context menus to allow your users to interact with the Apple Watch and respond to their actions to perform a task
  • Use the MapKit framework to display a map within the WatchKit interface to track the user's current location
  • Build effective user interfaces for the WatchKit platform and integrate iCloud capabilities to synchronize data between the iOS app and the WatchKit UI
  • Design your apps for the Apple Watch platform by adhering to the set of User Interface design guidelines set out by Apple
  • Reinforce image caching to display animations within the Apple Watch user interface
  • Explore WatchKit tables, which allow your users to purchase groceries and pay for them using Apple Pay
  • Analyze the new layout system to ensure that your Apple Watch apps work with various screen sizes

In Detail

Wearable are the next wave of mobile technology and with the release of Apple's WatchKit SDK, a whole new world of exciting development possibilities has opened up.

Apple Watch App Development introduces you to the architecture and possibilities of the Apple Watch platform, as well as an in-depth look at how to work with Xcode playgrounds. Benefit from a rapid introduction to the Swift programming language so you can quickly begin developing apps with the WatchKit framework and the Xcode Development IDE. Get to grips with advanced topics such as notifications, glances, iCloud, Apple pay, closures, tuples, protocols, delegates, concurrency, and using Swift Playgrounds, with each concept is backed up with example code that demonstrates how to properly execute it. Finally, discover how to package and deploy your Watch application to the Apple AppStore.

By the end of this book, you will have a good understanding of how to develop apps for the Apple Watch platform, and synchronize data using iCloud between the wearable and the iOS device.

Style and approach

This book takes a step-by-step approach to developing applications for the Apple Watch using the Swift programming language and the WatchKit UI. Each topic is explained in a conversational and easy-to-follow style.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 321

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Apple Watch App Development
Credits
About the Author
Acknowledgements
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introducing the Swift Programming Language
Registering as an Apple developer
Getting and installing Xcode development tools
Introduction to Xcode playgrounds
Introduction to the Swift language
Variables, constants, strings, and semicolons
Variables
Constants
Strings
Semicolons
Numeric types and conversion
Booleans, tuples, and string interpolation
Booleans
Tuples
String interpolation
Controlling the flow
The for…in loops
What's new in Swift 2.0
Error handling
Binding
Protocol extensions
Summary
2. Understanding Apple Watch
Introduction to the WatchKit platform
Introducing the WatchKit application architecture
Introducing the WatchKit application life cycle
Introducing the WatchKit classes
Limitations of the WatchKit platform
Apple Watch Human Interface Guidelines
What's new in watchOS 2
Watch faces
Photos
Time-Lapse
Time travel
Nightstand mode
Activation Lock
FaceTime audio
Social features
Summary
3. Exploring WatchKit Controls
Building the Guessing Game application
Using Interface Builder to create the watch user interface
Adding our user interface controls – text and labels
Creating Outlets to our Interface Builder objects
Creating Actions that respond to user actions
Building and running the Guessing Game application
Summary
4. Using the Core Location and Watch Connectivity Frameworks
Creating the navigation tracking application
Building the Watch Tracker application – iPhone
Adding and removing annotation placeholders
Handling requests for background location updates
Building and running the Watch Tracker application
Building the Watch Tracker application – WatchKit
Limitations of using Core Location within watchOS 2
Using Interface Builder to create the Watch Tracker UI
Creating the Outlets for our Interface Builder objects
Creating an Action event to handle our map zooming
Using Core Location with the WatchKit extension
Communicating between the iPhone app and the WatchTracker WatchKit extension
Integrating the Watch Connectivity framework – iPhone app
Integrating the Watch Connectivity framework – WatchKit extension
Building and running the Watch Tracker application
Summary
5. Navigating Around in WatchKit
Building the Health Monitor application
Understanding page-based interfaces and navigation
Understanding modal interfaces and navigation
Understanding hierarchical interfaces and navigation
Integrating the HealthKit framework to handle updates
Integrating the HealthKit framework – iPhone app
Building the Health Monitor application – WatchKit
Creating the profile details interface controller's WatchKit class
Creating the Outlets for our Interface Builder objects
Creating an Action event to handle our Start Monitoring button
Using HealthKit to obtain heart rate and pedometer information
Using HealthKit to obtain biological personal information
Building and running the Health Monitor application
Summary
6. Implementing Tables within Your App
Building the Shopping List application
Setting up and provisioning your app for Apple Pay
Configuring our Shopping List app to work with Apple Pay
Understanding the WatchKit table object
Building the Shopping List application – WatchKit
Creating the table row interface controller's WatchKit class
Configuring our product table row controller class
Creating the product class structure to hold product items
Creating the ProductsList property list
Populating our WatchKit table controller with row information
Responding when a row has been selected within our table
Running the Shopping List application – WatchKit
Handling payment requests with the PassKit framework
Building and running the Shopping List application
Summary
7. Adding Menus to Your App
Introduction to gestures and the menu interface
Understanding WatchKit context menu gestures
Understanding the WatchKit context menu interface
Design considerations for WatchKit context menu icons
Understanding the default WatchKit context menu actions
Adding a menu to our Shopping List application – WatchKit
Establishing the WatchKit context menu connections
Design considerations when using Taptic Engine
Learning how to integrate Apple Watch haptics within an app
Running the Shopping List application – WatchKit
Summary
8. Incorporating the Glance Interface in Your App
Introduction to working with WatchKit glances
Understanding the glance controller life cycle
Adding a glance to our Shopping List application – WatchKit
Creating a glance build scheme for our Shopping List app
Creating the glance interface controller WatchKit class
Configuring our glance controller using templates
Establishing glance interface controller connections
Storing information to show within your glance controller
Displaying information within your glance controller
Understanding the glance interface guidelines
Running the Shopping List application – WatchKit
Summary
9. Incorporating Notifications within Your App
Working with WatchKit notifications
Understanding the notification controller life cycle
Configuring the notification scheme for our Shopping List app
Adding Action buttons to your dynamic notifications
Responding to actions within your custom notifications
The difference between static and dynamic interface controllers
Configuring our Shopping List app's dynamic notification controller
Establishing our notification controller connections
Configuring a category for our static interface controller
Scheduling notifications with your notification controller
Displaying messages within the notification interface
Understanding the notification interface guidelines
Running the Shopping List application – WatchKit
Summary
10. Image Compression and Animation
Building the animation application – WatchKit
Setting up and adding images to the assets catalog
Configuring our app to use App Transport Security
Using Interface Builder to create the watch user interface
Establishing connections to our interface controller
Establishing our Action events that respond to user actions
Animating your images within the WatchKit interface
Loading and compressing images within the WatchKit interface
Building and running the Animation Example application
Summary
11. Packaging and Deploying Your App
Creating and setting up your iOS development team
Creating the iOS development certificate
Obtaining the development certificate from Apple
Creating App IDs for your WatchKit applications
Creating development provisioning profiles
Profiling your application using Xcode Instruments
Preparing your app for submission using iTunes Connect
Submitting an app to iTunes Connect using Xcode
Summary
Index

Apple Watch App Development

Apple Watch App Development

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2016

Production reference: 1250416

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78588-636-2

www.packtpub.com

Credits

Author

Steven F. Daniel

Reviewer

Dylan Marriott

Commissioning Editor

Amarabha Banerjee

Acquisition Editor

Reshma Raman

Content Development Editor

Priyanka Mehta

Technical Editor

Taabish Khan

Copy Editor

Shruti Iyer

Project Coordinator

Izzat Contractor

Proofreader

Safis Editing

Indexer

Rekha Nair

Graphics

Abhinash Sahu

Production Coordinator

Melwyn Dsa

Cover Work

Melwyn Dsa

About the Author

Steven F. Daniel is the CEO and founder of GENIESOFT STUDIOS, a software development company that is based in Melbourne, Victoria, which focuses primarily on developing games and business applications for iOS, Android, and Mac OS X. Steven is a software developer with more than 14 years of experience developing desktop and web-based applications for a number of companies, including ANZ, Department of Justice, BP Australia, and AXA Australia.

Steven is always interested in emerging technologies, and he is a member of the SQL Server Special Interest Group (SQLSIG), Melbourne CocoaHeads, and the Java Community. He was the co-founder and Chief Technology Officer (CTO) of SoftMpire Pvt Ltd., a company that focused primarily on developing business applications for the iOS and Android platforms.

Steven is the author of various book titles: Xcode 4 iOS Development Beginner's Guide, iOS 5 Essentials, iPad Enterprise Application Development Blueprints, Xcode 4 Cookbook, and Android Wearable Programming.

Check out his blog at http://www.geniesoftstudios.com/blog/, or follow him on Twitter at http://twitter.com/GenieSoftStudio.

Acknowledgements

No book is the product of just the author; he just happens to be the one with his name on the cover. A number of people have contributed to the success of this book, and it would take more space than I have to thank each one individually.

I would personally like to thank two special people who have been an inspiration and who have provided me with so much support during the writing of this book. The first is Reshma Raman, my Senior Acquisition Editor, who is the reason that this book exists, and the second is Priyanka Mehta for her understanding and support as well as her brilliant suggestive approaches during the chapter rewrites. I would like to thank both of you for everything and making the writing process enjoyable.

To my reviewers, thank you so much for your valued suggestions and improvements to make this book what it is, I am truly grateful to each and every one of you.

Thank you to the entire Packt Publishing team for working so diligently to help bring out a high quality product. A big shout out to the engineers at Apple for creating the Apple Watch and the WatchKit Platform to provide developers with the tools to create fun and sophisticated applications.

Finally, I would like to thank all of my friends for their support, understanding, and encouragement during the book writing process. I am extremely grateful to have you as my friends, and it is a privilege to know each and every one of you.

About the Reviewer

Dylan Marriott is a young iOS developer from Switzerland. At the start of his career, he worked with web technologies, but he soon got involved with mobile and never went back. He started off with Android and then transitioned toward iOS. He currently works at Evernote, where he gets to work with the newest iOS technologies. In his free time, he has published a number of iOS and Apple Watch apps.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

This book is dedicated to:

My favorite uncle Benjamin Jacob Daniel, thank you for always making me smile and for inspiring me to work hard and achieve my dreams. You are a true inspiration, and I couldn't have done this without your love, support, and guidance. Thank you.

Chan Ban Guan, for the continued patience, encouragement, and support, and most of all, for believing in me during the writing of this book.

I would like to thank my family for their continued love and support and for always believing in me throughout the writing of this book. This book would not have been possible without your love and understanding, and I would like to thank you from the bottom of my heart.

Preface

With the increasing amount of new wearable devices hitting the market, wearables are the next wave of mobile computing technology. After the release of Apple's WatchKit SDK, a whole new world of exciting development possibilities awaits us.

Apple Watch App Development provides you with a practical approach that shows you how to develop and build Apple Watch apps using the Xcode Integrated Development Environment. You will be introduced to the architecture and limitations of the Apple Watch platform, followed by an in-depth look at the Swift programming language, where we talk about closures, tuples, protocols, delegates, and how to work with Xcode playgrounds.

We also discuss more advanced topics, such as notifications, glances, Apple Pay, as well as the Core Location and Watch Connectivity frameworks to synchronize data between the Apple Watch and the iPhone using the WatchKit platform. By the end of this book, you will have a good understanding of how to build real-world applications for the Apple Watch platform using the WatchKit framework and Swift 2.0.

In this book, I have tried my best to keep the code simple and easy to understand by providing a step-by-step approach with lots of screenshots at each step to make it easier to follow. You will soon be mastering the different aspects of Apple Watch wearable programming, as well as mastering the technology and skills that are needed to create your own applications for the Apple Watch platform.

Feel free to contact me at <[email protected]> for any queries, or just drop me an e-mail to say "Hello".

What this book covers

Chapter 1, Introducing the Swift Programming Language, focuses on how to go about signing up to the Apple Developer program, as well as downloading and installing the Xcode development tools. We will cover Xcode playgrounds before moving on to learning the basics of the Swift programming language and some of the new additions to Swift with Swift 2.

Chapter 2, Understanding Apple Watch, introduces you to the WatchKit platform architecture and the application life cycle, as well as a list of the WatchKit classes that make up the WatchKit platform. You'll learn about some of the limitations behind the WatchKit platform architecture, as well as some of the new additional features that are a part of watchOS 2. You will then go on to learn about the Apple Watch Human Interface Guidelines.

Chapter 3, Exploring WatchKit Controls, introduces you to some of the controls that come as a part of the WatchKit platform. You will learn how to work with Xcode's Interface Builder to build the visual interface for our first WatchKit application. You will also learn how to use Outlets to bind objects to the Interface Builder objects and create some Action events to respond to these objects when tapped by the user to provide visual feedback.

Chapter 4, Using the Core Location and Watch Connectivity Frameworks, delves deeper into learning more about the WatchKit framework and the new layout system using groups. You'll learn about the MapKit and WKInterfaceMap frameworks. You will also learn how you can use these to incorporate mapping capabilities within your WatchKit apps using the Watch Connectivity framework to send geographical location-based coordinates between your iOS app and WatchKit to display the user's current location on the Apple Watch.

Chapter 5, Navigating Around in WatchKit, introduces you to some of the ways that you can navigate within the watch face user interface. You'll learn the differences between page-based, modal, and hierarchical navigation, and when to use them. You will then learn how to use the HealthKit framework to access health-related information and share this information between the iOS device and the WatchKit extension to display a user's current heart rate, blood type, and number of steps taken for a particular day.

Chapter 6, Implementing Tables within Your App, focuses on teaching you how to create applications that handle Apple Pay payments using the PassKit framework. You will learn how to pass information between the iOS device and the WatchKit extension. You will also learn how to use the WKInterfaceTable controller, how to set it up and configure it, as well as how to display information from a JSON file.

You will learn how to use the WKInterfaceTable methods to determine when a row has been selected by the user and respond to this action.

Chapter 7, Adding Menus to Your App, introduces you to WatchKit menus, and how you can incorporate them into your own applications, as well as respond to them based on what the user has chosen. We end the chapter by covering how you can use the Taptic Engine to integrate haptic feedback in your own applications.

Chapter 8, Incorporating the Glance Interface in Your App, shows you how to effectively incorporate WatchKit glances within an existing WatchKit application by creating a custom GlanceInterfaceController class to display information within the glance interface. You'll learn about the glance interface guidelines, which outline the guidelines and principles that you need to follow when designing your layouts for the different Apple Watch screen sizes.

Chapter 9, Incorporating Notifications within Your App, explains how to incorporate and configure local and remote notifications within an existing Apple Watch application. You will learn about the notifications life cycle and the differences between static and dynamic interfaces.

You will learn about the Apple Push Notification service (APNs) and how you can use this to send and receive information by responding to button actions when a user taps on the button. You will learn about the notification interface guidelines, which outlines the guidelines and principles that you need to follow when designing your notifications.

Chapter 10, Image Compression and Animation, shows you how to add images to the image assets catalog, and then start to build a simple WatchKit application that showcases how to animate a series of images within the WatchKit user interface.

You'll learn about the Application Transport Security (ATS) protocol that Apple introduced with the release of iOS 9, which forces developers to provide secure connections between your Apple Watch apps that communicate over HTTPS. We will also be covering how to properly configure our Apple WatchKit extension, as well as learn the best ways of handling and compressing large image files when these are downloaded from an external website so to increase performance.

Chapter 11, Packaging and Deploying Your App, focuses on how to submit your application to the Apple App Store, and share your creations with the rest of the community. You'll learn how to set up your iOS development team as well as the development and distribution certificates.

Finally, you will learn how to use the Instruments application to profile your application to eliminate performance bottlenecks. You will also learn how to package your application using Xcode and deploy this to iTunes Connect so that you can download and test on your Apple Watch device.

What you need for this book

The minimum requirement for this book is an Intel-based Macintosh computer running OS X El Capitan 10.11. We will be using Xcode 7.3, which is the Integrated Development Environment (IDE) that is used to create applications for iOS, watchOS, and tvOS. Almost all projects that you will create with the help of this book will work and run on the iOS Simulator. However, some projects will require an Apple Watch and an iPhone to work correctly.

You can download the latest version of Xcode from http://developer.apple.com/xcode/.

Who this book is for

This book is intended for developers who have a working experience of application development principles on the Mac OS X and/or iOS platforms and wish to expand their knowledge to develop applications for the Apple Watch using the Swift programming language and the WatchKit framework. It is assumed that you are familiar with object-oriented programming (OOP) and have some experience with Swift.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Introducing the Swift Programming Language

At WWDC 2014, Apple introduced a brand new programming language called Swift. The Swift programming language brings concise syntax, type safety, and modern programming language features to Mac and iOS developers.

Since its release, the Apple developer community has responded with great excitement, and developers are rapidly starting to adopt this new language within their own applications. The Swift language is the future of developing on Apple's platforms.

This chapter includes the following topics:

Learning how to register as an Apple developerLearning how to download and install Xcode development toolsIntroduction to the Swift programming languageLearning how to work with Xcode playgroundsIntroduction to the newest additions in Swift 2.0

Registering as an Apple developer

Before you can begin building iOS applications for your iOS devices, you must first join as a registered user of Apple Developer Program in order to download all of the necessary components to your computer. The registration process is free and provides you with access to the iOS SDK and other developer resources that are really useful to get you started.

The following short list outlines some of the things that you will be able to access once you become a registered member of Apple Developer Program:

It provides helpful "Getting Started" guides to help you get up and running quicklyIt gives you helpful tips that show you how to submit your apps to App StoreIt provides the ability to download the current releases of iOS softwareIt provides the ability to beta test the releases of iOS and the iOS SDKIt provides access to Apple Developer Forums

Note

Whether you develop applications for the iPhone or iPad, these use the same OS and iOS SDK that allows you to create universal apps that will work with each of these devices. On the other hand, Apple Watch uses an entirely different OS called watchOS.

To prepare your computer for iOS development, you need to register as an Apple developer. This free process gives you access to the basic levels of development that allow you to test your app using iOS Simulator without the ability to sell your app on the Apple App Store. The steps are as follows:

To sign up to Apple Developer Program, you will need to go to https://developer.apple.com/programs/ and then click on the Enroll button to proceed, as shown in the following screenshot:Next, click on the Start Your Enrollment button, as shown in the following screenshot:Once you sign up, you will then be able to download the iOS SDK and proceed with installing it onto your computer.

You will then become an official member of Apple Developer Program. You will then be able to download beta software so that you can test them on your actual device hardware as well as having the freedom to distribute your apps to your end users.

In the next section, we will look at how to download and install Xcode development tools.

Getting and installing Xcode development tools

In this section, we will take a look at what Integrated Development Environments (IDEs) and Software Development Kits (SDKs) are needed to develop applications for the iOS platform, which is Apple's operating system for mobile devices. We will explain the importance of each tool's role in the development cycle and the tools required to develop applications for the iOS platform, which are as follows:

An Intel-based Mac computer running OS X Yosemite (10.10.2) or later with the latest point release and security patches installed is required. This is so that you can install the latest version of the Xcode development tool.Xcode 6.4 or later is required. Xcode is the main development tool for iOS. You need Xcode 6.4 minimum as this version includes Swift 1.2, and you must be registered as an Apple developer. The iOS SDK consists of the following components:

Component

Description

Xcode

This is the main IDE that enables you to develop, edit, and debug your native applications for the iOS and Mac platforms using the Objective-C or Swift programming languages.

iOS Simulator

This is a Cocoa-based application that enables you to debug your iOS applications on your computer without the need of having an iOS device. There are many iOS features that simply won't work within Simulator, so a device is required if an application uses features such as the Core Location and MapKit frameworks.

Instruments

These are the analysis tools that help you optimize your applications and monitor memory leaks during the execution of your application in real time.

Dashcode

This enables you to develop web-based iOS applications and dashboard widgets.

Once you are registered, you will need to download and install Xcode developer tools by performing the following steps:

Begin by downloading and installing Xcode from Mac App Store at https://itunes.apple.com/au/app/xcode/id497799835?mt=12.Select either the Free or Install button on the App Store page. Once it completes the installation process, you will be able to launch Xcode.app from your Applications folder.

Note

You can find additional development tools from the Apple developer website at https://developer.apple.com/.

In the next section, we will be looking at what, exactly, Xcode playgrounds are and how you can use them to experiment with designing code algorithms prior to incorporating the code into your project. So, let's get started.

Introduction to Xcode playgrounds

A playground is basically an interactive Swift coding environment that displays the results of each statement as updates are made without having the need to compile and run a project. You can use playgrounds to learn and explore Swift, prototype parts of your app, and create learning environments for others. The interactive Swift code environment lets you experiment with algorithms, explore system APIs, and even create your very own custom views without the need to create a project. Once you perfect your code in the playground, simply move this code into your project. Given that playgrounds are highly interactive, they are a wonderful vehicle for distributing code samples with instructive documentation and can even be used as an alternative medium for presentations.

With the new Xcode 7 IDE, you can incorporate rich text comments with bold, italic, and bulleted lists with the addition of having the ability to embed images and links. You can even embed resources and support Swift source code in the playground to make the experience incredibly powerful and engaging, while the visible code remains simple.

Playgrounds provide you with the ability to do the following:

Share curriculum to teach programming with beautiful text and interactive codeDesign a new algorithm and watch its results every step of the wayCreate new tests and verify that they work before promoting them into your test suiteExperiment with new APIs to hone your Swift coding skillsTurn your experiments into documentation with example code that runs directly within the playground

Let's begin by opening the Xcode IDE and explore how to create a new playground file for the first time. Perform the following steps:

Open the Xcode.app application either using the finder in your Applications directory or using Apple's Launchpad. If you've never created or opened an Xcode project before, you will be presented with the following screen:In the Welcome to Xcode dialog, select the Get started with a playground option. If this dialog doesn't appear, you can navigate to File | New | Playground… or simply press Shift + Option + Command + N.Next, enter SwiftLanguageBasics as the name of your playground.Then ensure that you choose iOS as the platform that we will target.Click on the Next button to proceed to the next step in the wizard.Specify the location where you would like to save your project.Then click on the Create button to save your playground at the specified location.

Once your project is created, you will be presented with the default playground template, as shown in the following screenshot:

In the next section, you will begin learning about some of the Swift language basics, start adding lines of code within this playground file, and see the results that we get when they are executed.