Encontre seu próximo livro favorito

Torne'se membro hoje e leia gratuitamente por 30 dias.
Building Apple Watch Projects

Building Apple Watch Projects

Ler amostra

Building Apple Watch Projects

Comprimento:
685 página
3 horas
Lançado em:
Feb 29, 2016
ISBN:
9781785887055
Formato:
Livro

Descrição

Discover exciting and fun projects by building brilliant applications for the Apple Watch

About This Book

- Explore the opportunities opened up to developers by Apple’s latest device: the Apple Watch
- Be a crackerjack at developing software across a broad range of watch app categories
- From an eminent author, master all stages of development, from the first stage through to a completed project

Who This Book Is For

If you have some basic knowledge of programming in Swift and are looking for the best way to get started with Apple Watch development, this book is just the right one for you!

What You Will Learn

- Understand the concept of the Apple Watch as an autonomous device as well as it being paired with the iPhone
- Get your app up and running
- Design exciting, inspiring, and attractive layouts for your apps
- Make your user interface more engaging using images and animation
- Enable your Watch and iPhone apps to transport and share data
- Leverage the feature-rich set of WatchKit technologies provided by Apple
- Connect your apps to the Internet
- Submit your app to the App Store

In Detail

With Apple’s eagerly anticipated entry into the wearable arena, the field is wide open for a new era of app development. The Apple Watch is one of the most important technologies of our time.
This easy-to-understand book takes beginners on a delightful journey of discovering the features available to the developer, right up to the completion of medium-level projects ready for App Store submission. It provides the fastest way to develop real-world apps for the Apple Watch by teaching you the concepts of Watch UI, visual haptic and audio, message and data exchange between watch and phone, Web communication, and finally Visual, haptic as well as audio feedback for users.
By the end of this book, you will have developed at least four fully functioning apps for deployment on watchOS 2.

Style and approach

This is a step-by-step guide to developing apps for the Apple Watch with the help of screenshots and fully coded working examples.
Lançado em:
Feb 29, 2016
ISBN:
9781785887055
Formato:
Livro

Sobre o autor


Relacionado a Building Apple Watch Projects

Livros relacionados
Artigos relacionados

Amostra do Livro

Building Apple Watch Projects - Grimshaw Stuart

Table of Contents

Building Apple Watch Projects

Credits

About the Author

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

Downloading the color images of this book

Errata

Piracy

Questions

1. Exploring the New Platform

Wide open future

A closer look at the watch

Building on success

A look under the hood

Vital statistics

watchOS

WatchKit

One App, four interfaces

The Main app

Glances

Correction

Notifications

User Input Hardware

Digital Crown

Force Touch

Taptic Engine

Audio in out

♥ It

Extension of the iPhone, but more

Opportunity knocks

Summary

2. Hello Watch

Setting it all up

Creating a new Xcode project

Check out what's new

Building and running the app

Looking over the project

Three apps?

iOS app

WatchKit app

WatchKit extension

Three targets

Two storyboards

Adding some content on screen

Preparing the interface

Adding a button

Give the UI some visual appeal

Adding a group

Creating a group object

Tweaking the button

Done

Adding some animation magic

Getting user input

Ideas for self study

Summary

3. C-Quence – A Memory Game

Plan the app

Mission statement

User story

App requirements

Setting up the project

Create the Xcode project

Create Required Classes

Building the interface

Set up the Group hierarchy

Add a button

Copy and paste

GameLogic

Create the GameLogic class

Plan the class

Create the class's interface

Define some enums

Stub the methods

Extend the sequence

Evaluate

Clear

Define properties

Check your code

Interface Controller

Planning the interface

Define Outlets to the View

Connect the UI with the Outlets

Stub some preliminary methods

Start the game

Accept guess

Game over!

Check your code

Hook up the UI with the Outlets

Run the app

Summary

4. Expanding on C-Quence

Implementing the methods

The InterfaceController class

awakeWithContext

playButtonTapped

Declare additional constants

playSequence

timerFired

flashColor

redButtonTapped & Co

colorButtonTapped

endGame

GameLogic

Init the sequence array

Extend the sequence

Evaluating the user's input

clearGame

Test it

Build and run the app

Testing and tweaking

The first test

The first bug

The first fix

Test again

Fix again

Test

Fix

Test again

Communicating with the phone

Make it personal

Getting the message across

Requirements

What classes will we need?

Preparing both apps to communicate

Create a Constants.swift file

Define the constants

Create the iPhone Connectivity Manager

Instantiate the class in AppDelegate

Getting the user name

ViewController

Prepare the UI

Hook up the UI

Creating the Watch Connectivity Manager

Instantiate the class in ExtensionDelegate

Modify the InterfaceController class

Run and test

Summary

5. On Q – A Productivity App

Download the project template

Plan the Watch app

Mission statement

User story

The Watch app

Launch view:

Prompts view:

Menu:

The iPhone app

App requirements

Setting up the project

Create the required watchOS classes

Writing the code

WatchConnectivity

WatchConnectivityManager class

WatchData

WatchDataManager class

Interface Controllers

PromptsInterfaceController

DetailsInterfaceController

The Storyboard

Preparing the images

Using xcassets

Designing the user interface

PromptsInterfaceController

Prompts Group

PromptLabelGroup

Buttons Group

Start Group

Other UI elements

DetailsInterfaceController

Implementing the methods

ExtensionDelegate

WatchConnectivityManager

WatchDataManager

Interface Controllers

PromptsInterfaceController

DetailsInterfaceController

Build and run

Test and Tweak

Testing with the iPhone and real data

Unstub the WatchDataManagerinit method

Challenges for further growth

Summary

6. Watching the Weather

Adding a Glance to an app

Plan the App

Mission Statement

User Story

Setting up the project

Requirements

Weather data structure

Getting the data

Welcome to openweathermap.org

Introducing JSON

JSON data structure 101

Making the data more readable

Introducing NSURLSession

Disabling App Transport Security

Using NSURLSession

Interface Controllers

Testing in the console

Completing InterfaceController

Coding InterfaceController

Building the Interface

WeatherTableInterfaceController

The simplicity of WatchKit tables

Coding WeatherTableInterfaceController

Parsing the JSON data

Building the WeatherTable UI

Run the app

DetailsInterfaceController

Coding the DetailsInterfaceController

Creating the DetailsInterfaceController UI

Run the complete app

Glances

Coding the GlanceController

Building the GlanceController UI

Building the Glance interface

Running and testing the Glance

Challenges for expansion

Summary

7. Plot Buddy – All about Location

Planning the app

Mission Statement

User Story

Setting up the project

Requirements

Data structure

Shared constants

Getting location data

Modifying the iPhone's Info.plist

Creating PBLocationManager

Create the Class

Delegates and Protocols

Define the protocol

Implement PBLocationManager

The Interface Controllers

Create the InterfaceController class

Test in the console

Beware of the glitches

Code

Interface

Test your code

PlotsSceneInterfaceController

CodingPlotsSceneInterfaceController

Creating the UI

Run the app

WatchConnectivity

Final test

Challenges for expansion

Summary

8. Images, Animation, and Sound

Adding an icon

Icon requirements

Technical requirements

Design considerations

Using third-party utilities

Complete icon set

Graphics apps

Sizes

Understanding points and pixels

Importing images into the project

Animation

Creating AnimationInterfaceController

Create a new project

Extending AnimationInterfaceController

Add Outlets to AnimationInterfaceController

Creating the UI

Adding code to AnimationInterfaceController

Some Constants

Setting the UI layout in code

Run the code

Tweak the code

Completing the animation code

Less is more

Run the app

Audio and Video

Adding a media file

Adding the code

Summary

9. Wear It, Test It, Tweak It, Ship It

Installation on a physical device

What if you don't have an Apple Watch?

Registering your device

Pair your Apple Watch and iPhone

Select the device in Xcode

Running on the device

Installation troubleshooting

Restarting, really?

Restart just the app

Restart the Simulator

Delete the app from the Watch Simulator

Delete the app from the iPhone Simulator

Delete the Derived Data directory

Reload the Xcode project

Restart Xcode

Restart Xcode

Read the error messages

Help online

Stack Overflow

Apple developer forums

Testing in the field

Wear it all day

Scenarios not to be forgotten

Beta testers

Iterate testing and tweaking

When testing is done

Before you submit

App Store submission process overview

Phone Functionality

Apple's guidelines

Keep up to date

Membership and certificates

Preparing for submission

Apple Developer Member Center

Xcode distribution settings

Using iTunes Connect

Requirements for iTunes Connect

App description

Support URL

App Store Icon

Screenshots

iTunes Connect optional data

App Preview

App Review Information

The iTunesConnect process

Submit for review

Uploading the build with Xcode

Upload

Uploaded!

Summary

10. This Is Only the Beginning

Using animation to the fullest

Advanced custom navigation

Onboarding

Making use of code snippets

Post release maintenance

Support

Analytics

Google Analytics

Fabric/Crashlytics

Expanding your skills

HTTP

Swift

Program design topics

Programming paradigms

Object orientated programming

Imperative programming

Declarative

Where Swift fits in

Program design patterns

Tools

Terminal

Help from afar

Command line development

Using cURL

Creating a local server

Xcode's Instruments app

Application Loader

Version control

What is version control?

Git and repos

Git and Xcode

GitHub

BitBucket

Which one to choose

Personal favorites

Graphics

Graphic

iConeer

Bezel

HTTP traffic

Charles

Wireshark

Sites to be aware of

Swift

Open source Swift

Swift blog

Apple developer resources

watchOS developer library

WWDC vids

Online help

Stack Overflow

Stack Exchange

Apple forums

My sites

Support

GitHub

Best of the blogs

NSHipster

Erica Sadun

Natasha the robot

Stay in touch

Follow the buzz

Open source

Real-world encounters

Meet-Ups

DevCons

Summary

One last word from the author

Index

Building Apple Watch Projects


Building Apple Watch Projects

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: February 2016

Production reference: 1250216

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78588-736-9

www.packtpub.com

Credits

Author

Stuart Grimshaw

Reviewer

Fito Toledano Carmona

Commissioning Editor

Kunal Parikh

Acquisition Editor

Ruchita Bhansali

Content Development Editor

Mehvash Fatima

Technical Editor

Gebin George

Copy Editor

Shruti Iyer

Project Coordinator

Kinjal Bari

Proofreader

Safis Editing

Indexer

Tejal Daruwale Soni

Graphics

Kirk D'Penha

Production Coordinator

Manu Joseph

Cover Work

Manu Joseph

About the Author

Stuart Grimshaw has programmed for Apple computers since the days before OS X and has been involved with developing for Apple Watch since its release. Born in the UK and having lived in Germany and the Netherlands, he is currently an iOS developer in Auckland, New Zealand, where he works on some of Australia–New Zealand's largest video and TV delivery apps and heads the research and development of both watchOS and tvOS applications. He is passionate about the potential of the Apple Watch and Apple TV as well as Apple's Swift programming language and is a keen proponent of beach coding.

I'd like to thank Mehvash Fatima for her months of hard work on this book, and her patient answers to a thousand questions.

Thanks also to Ruchita, Fito and Gebin for their hard work and help on the project.

About the Reviewer

Fito Toledano Carmona is a relentless learner. He started coding at the age of 12. He quit medicine to start his own software business at 20, following which he successfully sold his business to start a career at Apple Inc. At 21, he's building a whole new project and a YouTube blog to tell his story.

Stay tuned on Twitter @fito_tc

To my family, for giving me the tools to become who I am today.

To my mentor Francisco, who always believed in me.

To Enrique and Jim, who are helping me put a dent on the universe.

To my friends Adrian, Gabriel, Joan and José Ascanio, Jesús Manuel, Gonzalo, Salo, Alex, and Pedro who always stood up for me no matter what.

To Jack Coyne, Casey Neistat, Phil Toronto, Gary Vaynerchuk, Rafael Nadal, and Steve Jobs for inspiring me.

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 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 Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Preface

Building Apple Watch Projects provides you with end-to-end guidance on creating a range of apps for the Apple Watch, covering such essential topics as location frameworks, data storage, communication with the iPhone, and animation, to name just a few. It applies the reader's basic Swift knowledge to real-world programming challenges in an easy, step-by-step manner, starting with a simple animated version of the ubiquitous Hello World app, progressing to apps that are Internet connected, location-aware, and fascinating to use, spanning the genres of productivity, games, and lifestyle apps.

The book contains many tips around making the best use of your coding skills, the tools that surround app development, and the many resources and utilities that exist to make your progress as a developer as smooth and enjoyable as it can be.

By the end of this book, you will have taken apps from the earliest conceptual stages right up to the Store submission.

What this book covers

Chapter 1, Exploring the New Platform, introduces the reader to the Apple Watch itself and the many design features that set the context in which the rest of the book is presented.

Chapter 2, Hello Watch, covers the setup of a new Xcode project and the creation of an uncomplicated but attractive take on the Hello World theme, including a little animation eye candy.

Chapter 3, C-Quence – A Memory Game, presents a minimalist version of a common memory game and covers the planning and design of an app that will involve more than one screen.

Chapter 4, Expanding on C-Quence, builds on the preparations of Chapter 3 to complete a colorful and functional working app, which will also be able to communicate with its paired iPhone to gather textual input from the user.

Chapter 5, On Q – A Productivity App, makes use of image assets to add a little sophistication to the user interface of a cue-card app, introduces an interactive menu screen, and makes use of the Taptic Engine to provide feedback to the user.

Chapter 6, Watching the Weather, adds Internet connectivity into the mix to create a weather app that fetches its live data from the Web and presents it using a table-based interface. This chapter also introduces the Glance screen, making a portion of the data available to the user without launching the app.

Chapter 7, Plot Buddy – All about Location, presents a location-aware app, with which the user can store sets of location data, with or without its paired iPhone. We also see the introduction of Swift protocols and custom initialization methods.

Chapter 8, Images, Animation, and Sound, adds icons to the app as well as introducing sequential animations and audio/video media playback. We also look at configuring an app's UI almost purely in code, in addition to class extensions and Xcode asset catalogs.

Chapter 9, Wear It, Test It, Tweak It, Ship It, is all about the steps to be taken after coding is finished, including installation and testing on a physical device as well as preparation of everything that is necessary for submission to the App Store.

Chapter 10, This Is Only the Beginning, takes a look at some more advanced techniques to make your apps stand out from the crowd, introduces some techniques for improving your workflow, and covers a range of topics that any watchOS/iOS developer will want to add to his or her programming skills, including a number of peripheral tools essential to professional work in a team environment, in order to set the stage for the reader's progress beyond the ground covered by this book.

What you need for this book

To create and build the code presented here, you will need nothing more than Apple's Xcode software package, which you can download for free in the App Store, and a Mac to run it on. A number of other tools are introduced, such as the OS X Terminal app, which are already installed on your Mac.

Testing the code can be done using Xcode's Simulator app, though the reader is encouraged to run the apps on a physical device, which is important when testing production-ready code (and is much more fun).

Who this book is for

If you have some basic knowledge of programming in Swift and are looking for the best way to get started with Apple Watch development, this book is just the right one for you!

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, dummy URLs, and user input are shown as follows:

We can include other contexts through the use of the include directive.

A block of code is set as follows:

var sequence: [Color] = []

var nextAnswerIndex: Int = 0

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

func clearGame() {     sequence = []     nextAnswerIndex = 0

 

    }

Any command-line input or output is written as follows:

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample     /etc/asterisk/cdr_mysql.conf

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: You will be presented with the Play button.

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

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

To send us general feedback, simply send an e-mail to <feedback@packtpub.com>, and mention the book title via 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 on 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 all Packt books you have purchased 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.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/BuildingAppleWatchProjects_ColoredImages.pdf.

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 would 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright 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 <copyright@packtpub.com> 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

You can contact us at <questions@packtpub.com> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Exploring the New Platform

There couldn't have been a more exciting time to be a software developer. A bold claim, undeniably, but if we take a look at the seemingly limitless range of contexts in which we have come to use smart mobile technology for both work and play, it is hard to imagine a more fertile environment in which employ both our creative and technical skills in shaping the next generation of mobile devices.

Wide open future

It is a rare moment indeed in which developers have the opportunity to use a new programming language, for developing on a new platform, for a new genre of device. Whether relatively new to programming, or with decades of experience across a multitude of platforms and languages, we are, in a sense, all very much beginners, and it is this that many will find the most thrilling part of engaging with the Apple Watch as a developer. We are all in at the ground floor, so to speak, and none of us knows where it will lead us, what users will expect from wearable devices as they become established as mainstream products, what previously unimagined uses will evolve, and what challenges we will face as developers.

As someone who is developing for the Apple Watch, you are truly at the center of this digital revolution. The company that revolutionized our attitudes to computing in general, and mobile devices in particular, is revolutionizing both its hardware and the ways in which developers are able to engage their users, offering them an ever more immersive experience, while the boundaries between hardware and software become increasingly blurred. More than any device before it, the Apple Watch blends into this new landscape, at once a small part in the larger context of mobile computing, and a radical step forward, into a realm of wearable devices that accompany us throughout the day in closest possible proximity.

So before we get down to any coding, we will take a brief look over the concepts, an important undertaking, as we need to understand what users will expect from a device that in some respects resembles others they know already, in order to delight them with things they have never experienced.

In this chapter, we will cover the following

A closer look at the watch

A look under the hood

One app, four interfaces

User input hardware

The Watch as extension of the iPhone

A closer look at the watch

Just as the iPhone presented a revolutionary step in user interface design, so the Watch brings with it a way of thinking about interacting with the user that goes beyond the simple shrinking down of screen content to fit the new device and instead gives us a reimagining of how we both read and input information, while effectively leveraging our previous experience and expectations of using a touchscreen.

The following image shows the Watch's home screen and its older sibling on the iPhone (not to scale):

Você chegou ao final desta amostra. Inscreva-se para ler mais!
Página 1 de 1

Análises

O que as pessoas pensam sobre Building Apple Watch Projects

0
0 avaliações / 0 Análises
O que você acha?
Classificação: 0 de 5 estrelas

Avaliações de leitores