Bruce Wade
Bruce Wade
Suite No. 1408, North Vancouver, British Columbia, Canada
Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com . For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/ .
ISBN 978-1-4842-1879-2
e-ISBN 978-1-4842-1880-8
DOI 10.1007/978-1-4842-1880-8
Library of Congress Control Number: 2016941345
© Bruce Wade 2016
OS X App Development with CloudKit and Swift
Managing Director: Welmoed Spahr
Lead Editor: Louise Corrigan
Development Editor: James Markham
Technical Reviewer: Charlie Cruz
Editorial Board: Steve Anglin, Pramila Balen, Louise Corrigan, James DeWolf, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing
Coordinating Editor: Nancy Chen
Copy Editor: April Rondeau
Compositor: SPi Global
Indexer: SPi Global
For information on translations, please e-mail [email protected] , or visit www.apress.com .
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales .
Standard Apress
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Printed on acid-free paper
Over the years, applications have required more and more data that couldn’t possibly fit onto a single computer. Not only that, but with mobile devices developers needed to find a way to ensure the same data can be shared between all devices. Apple also saw this need and invented CloudKit, which allows data storage to be infinitely scaled to meet user demand. CloudKit also works across all Apple products, and Apple even recently opened up JavaScript APIs that allow us to develop web applications that access the same data as our desktop, TvOS, and iOS devices.
In this book we are going to work through creating an OS X application from prototype to fully functional, data-driven app using CloudKit. When you are finished with this book you will be able to leverage CloudKit for your own OS X or iOS applications. We will not be covering iOS development in this book; however, the APIs you use for OS X and iOS are identical.
This will provide an overview of this book, what software is required, what you are expected to know, and an overview of what we will be creating.
In this chapter we will really start to dive into the planning of our dog parks app. We will primarily be using Sketch 3 in this chapter; however, we will also learn how to use Keynote for basic animations to get a feel for our app before we start coding or even open Xcode.
In this chapter we will take a closer look at our prototype from the previous chapter to dissect what data we really need in order to turn this prototype into a data-driven application. We will also determine which data should be public and which should be private for only your eyes.
In this chapter we are going to be taking a closer look at CloudKit and how it works. We will cover user authentication, public and private databases, record types, security roles, subscription types, and zones. While we cover these topics we will be taking a closer look at the CloudKit dashboard.
In this chapter we will start adding test data that we will use to display in a working app in subsequent chapters. We will cover how to create public data and how to edit and delete data through the dashboard.
Finally, in this chapter we will start migrating our prototype to Xcode so we can have a working app. We will only write enough code to handle authentication and retrieving and displaying our test data in our running app.
In chapter 5 we learned how to create/edit/delete data using the CloudKit dashboard. In this chapter we will learn how to update our test data from our app. Then we will implement security roles so users cannot edit data that they have not created themselves.
Finally, in this last chapter we will look at improving performance using a local cache of our data. This will both save server resources and allow the basics of the app to still work, even when there are network connectivity issues.
Bruce Wade is a software engineer from British Columbia, Canada. He started in software development when he was sixteen years old by coding his first website. He went on to study computer information systems at DeVry Institute of Technology in Calgary. To further enhance his skills, he studied visual and game programming at The Art Institute Vancouver. Over the years he has worked for large corporations as well as several startups. His software experience has led him to utilize many different technologies, including C/C++, Python, Objective-C, Swift, Postgres, and JavaScript. In 2012 he started the company Warply Designed to focus on mobile 2D/3D and OS X development. Aside from hacking out new ideas, he enjoys spending time hiking with his boxer Rasco, working out, and exploring new adventures.
Charles Cruz is a mobile application developer for the iOS, Windows Phone, and Android platforms. He graduated from Stanford University with B.S. and M.S. degrees in engineering. He lives in Southern California and runs a photography business with his wife ( www.bellalentestudios.com ). When not doing technical things, he plays lead guitar in an original metal band ( www.taintedsociety.com ). Charles can be reached at [email protected] and @CodingNPicking on Twitter.