Ios 12 App Development Essentials
Total Page:16
File Type:pdf, Size:1020Kb
iOS 12 App Development Essentials iOS 12 App Development Essentials – First Edition © 2018 Neil Smyth / Payload Media, Inc. All Rights Reserved. This book is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights reserved. The content of this book is provided for informational purposes only. Neither the publisher nor the author offers any warranties or representation, express or implied, with regard to the accuracy of information contained in this book, nor do they accept any liability for any loss or damage arising from any errors or omissions. This book contains trademarked terms that are used solely for editorial purposes and to the benefit of the respective trademark owner. The terms used within this book are not intended as infringement of any trademarks. Rev: 1.0 Table of Contents 1. Start Here ................................................................................................................................................ 1 1.1 For New iOS Developers .......................................................................................................................... 1 1.2 For iOS 11 Developers .............................................................................................................................. 1 1.3 Source Code Download ............................................................................................................................ 2 1.4 Feedback .................................................................................................................................................. 2 1.5 Errata ....................................................................................................................................................... 2 2. Joining the Apple Developer Program ..................................................................................................... 3 2.1 Downloading Xcode 10 and the iOS 12 SDK ............................................................................................ 3 2.2 Apple Developer Program........................................................................................................................ 3 2.3 When to Enroll in the Apple Developer Program? .................................................................................. 3 2.4 Enrolling in the Apple Developer Program .............................................................................................. 4 2.5 Summary .................................................................................................................................................. 5 3. Installing Xcode 10 and the iOS 12 SDK ................................................................................................... 7 3.1 Identifying Your macOS Version .............................................................................................................. 7 3.2 Installing Xcode 10 and the iOS 12 SDK ................................................................................................... 7 3.3 Starting Xcode .......................................................................................................................................... 7 3.4 Adding Your Apple ID to the Xcode Preferences ..................................................................................... 8 3.5 Developer and Distribution Signing Identities ......................................................................................... 9 4. A Guided Tour of Xcode 10 .................................................................................................................... 11 4.1 Starting Xcode 10 ................................................................................................................................... 11 4.2 Creating the iOS App User Interface ...................................................................................................... 15 4.3 Changing Component Properties ........................................................................................................... 18 4.4 Adding Objects to the User Interface .................................................................................................... 18 4.5 Building and Running an iOS 12 App in Xcode 10 .................................................................................. 21 4.6 Running the App on a Physical iOS Device ............................................................................................. 22 4.7 Managing Devices and Simulators ......................................................................................................... 22 4.8 Enabling Network Testing ...................................................................................................................... 23 4.9 Dealing with Build Errors ....................................................................................................................... 23 4.10 Monitoring Application Performance .................................................................................................. 24 4.11 An Exploded View of the User Interface Layout Hierarchy.................................................................. 25 4.12 Summary .............................................................................................................................................. 25 5. An Introduction to Xcode 10 Playgrounds ............................................................................................. 27 5.1 What is a Playground? ........................................................................................................................... 27 5.2 Creating a New Playground ................................................................................................................... 27 5.3 A Basic Swift Playground Example ......................................................................................................... 28 5.4 Viewing Results ...................................................................................................................................... 30 5.5 Adding Rich Text Comments .................................................................................................................. 32 5.6 Working with Playground Pages ............................................................................................................ 33 5.7 Working with UIKit in Playgrounds ........................................................................................................ 33 5.8 Adding Resources to a Playground ........................................................................................................ 35 5.9 Working with Enhanced Live Views ....................................................................................................... 36 5.10 When to Use Playgrounds ................................................................................................................... 38 5.11 Summary .............................................................................................................................................. 38 i 6. Swift Data Types, Constants and Variables ............................................................................................ 39 6.1 Using a Swift Playground ....................................................................................................................... 39 6.2 Swift Data Types .................................................................................................................................... 39 6.2.1 Integer Data Types ......................................................................................................................... 40 6.2.2 Floating Point Data Types .............................................................................................................. 40 6.2.3 Bool Data Type ............................................................................................................................... 41 6.2.4 Character Data Type....................................................................................................................... 41 6.2.5 String Data Type ............................................................................................................................. 41 6.2.6 Special Characters/Escape Sequences ............................................................................................ 42 6.3 Swift Variables ....................................................................................................................................... 43 6.4 Swift Constants ...................................................................................................................................... 43 6.5 Declaring Constants and Variables ........................................................................................................ 43 6.6 Type Annotations and Type Inference ................................................................................................... 43 6.7 The Swift Tuple ...................................................................................................................................... 44 6.8 The Swift Optional Type ........................................................................................................................ 45 6.9 Type Casting and Type Checking ..........................................................................................................