Book Image

Swift Essentials - Second Edition

By : Alex Blewitt
Book Image

Swift Essentials - Second Edition

By: Alex Blewitt

Overview of this book

Swift was considered one of the biggest innovations last year, and certainly with Swift 2 announced at WWDC in 2015, this segment of the developer space will continue to be hot and dominating. This is a fast-paced guide to provide an overview of Swift programming and then walks you through in detail how to write iOS applications. Progress through chapters on custom views, networking, parsing and build a complete application as a Git repository, all by using Swift as the core language
Table of Contents (17 chapters)
Swift Essentials Second Edition
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Watch applications


A watch application consists of code that can execute on the watch itself. A watch application is developed in Swift and run as a watch extension and a watch app. For watchOS 2, both run on the watch. (On watchOS 1, the watch extension ran on the companion iPhone.) This chapter will assume watchOS 2 is being used in order to run Swift-compiled code directly on the watch.

Note

As the first version of watchOS did not allow code to be executed on the watch, the code was bundled up into a watch extension, which ran as part of the companion application on the iPhone. The watch app contained resources and other images which were presented directly on the watch. With watchOS 2, the separation became less relevant. A future version of Xcode or watchOS may result in the two concepts becoming combined.

Adding a watch target

To add watch support for an existing application, a new target must be created for the watch. Open the existing Repository Browser application, navigate to File...