iOS 16 App
Development
Essen�als
UIKit Edi�on
Cover
iOS 16 App Development
Essentials
UIKit Edition
Title
iOS 16 App Development Essentials – UIKit Edition
ISBN-13: 978-1-951442-62-0
© 2023 Neil Smyth / Payload Media, Inc. All Rights Reserved.
is book is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly
prohibited. All rights reserved.
e content of this book is provided for informational purposes only. Neither the publisher nor the author oers
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.
is book contains trademarked terms that are used solely for editorial purposes and to the benet of the
respective trademark owner. e terms used within this book are not intended as infringement of any trademarks.
Rev: 1.0
Copyright
i
Contents
Table of Contents
1. Start Here .................................................................................................................................................... 1
1.1 Source Code Download ...................................................................................................................... 1
1.2 Feedback ............................................................................................................................................... 1
1.3 Errata..................................................................................................................................................... 1
2. Joining the Apple Developer Program ....................................................................................................... 3
2.1 Downloading Xcode 14 and the iOS 16 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 14 and the iOS 16 SDK ................................................................................................... 7
3.1 Identifying Your macOS Version ...................................................................................................... 7
3.2 Installing Xcode 14 and the iOS 16 SDK .......................................................................................... 7
3.3 Starting Xcode ..................................................................................................................................... 8
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 14 ...................................................................................................................... 11
4.1 Starting Xcode 14 .............................................................................................................................. 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 App in Xcode................................................................................. 22
4.6 Running the App on a Physical iOS Device ................................................................................... 22
4.7 Managing Devices and Simulators .................................................................................................. 23
4.8 Enabling Network Testing ................................................................................................................ 24
4.9 Dealing with Build Errors ................................................................................................................24
4.10 Monitoring Application Performance .......................................................................................... 24
4.11 Exploring the User Interface Layout Hierarchy .......................................................................... 25
4.12 Summary .......................................................................................................................................... 27
5. An Introduction to Xcode 14 Playgrounds .............................................................................................. 29
5.1 What is a Playground? ...................................................................................................................... 29
5.2 Creating a New Playground ............................................................................................................. 29
5.3 A Swi Playground Example ........................................................................................................... 30
5.4 Viewing Results ................................................................................................................................. 32
5.5 Adding Rich Text Comments .......................................................................................................... 34
5.6 Working with Playground Pages ..................................................................................................... 35
5.7 Working with UIKit in Playgrounds ............................................................................................... 35
5.8 Adding Resources to a Playground ................................................................................................. 36
5.9 Working with Enhanced Live Views ............................................................................................... 38
5.10 When to Use Playgrounds ..............................................................................................................40
5.11 Summary .......................................................................................................................................... 40
Contents
ii
Table of Contents
6. Swi Data Types, Constants and Variables ............................................................................................. 41
6.1 Using a Swi Playground ................................................................................................................. 41
6.2 Swi Data Types ................................................................................................................................ 41
6.2.1 Integer Data Types ..................................................................................................................... 42
6.2.2 Floating Point Data Types ......................................................................................................... 42
6.2.3 Bool Data Type ........................................................................................................................... 42
6.2.4 Character Data Type .................................................................................................................. 42
6.2.5 String Data Type ......................................................................................................................... 43
6.2.6 Special Characters/Escape Sequences ..................................................................................... 44
6.3 Swi Variables .................................................................................................................................... 44
6.4 Swi Constants .................................................................................................................................. 45
6.5 Declaring Constants and Variables ................................................................................................. 45
6.6 Type Annotations and Type Inference ........................................................................................... 45
6.7 e Swi Tuple .................................................................................................................................. 46
6.8 e Swi Optional Type ................................................................................................................... 47
6.9 Type Casting and Type Checking.................................................................................................... 50
6.10 Summary .......................................................................................................................................... 52
7. Swi Operators and Expressions ............................................................................................................. 53
7.1 Expression Syntax in Swi ............................................................................................................... 53
7.2 e Basic Assignment Operator ...................................................................................................... 53
7.3 Swi Arithmetic Operators .............................................................................................................. 53
7.4 Compound Assignment Operators ................................................................................................. 54
7.5 Comparison Operators .....................................................................................................................54
7.6 Boolean Logical Operators...............................................................................................................55
7.7 Range Operators ................................................................................................................................ 55
7.8 e Ternary Operator ....................................................................................................................... 56
7.9 Nil Coalescing Operator ................................................................................................................... 56
7.10 Bitwise Operators ............................................................................................................................ 57
7.10.1 Bitwise NOT .............................................................................................................................57
7.10.2 Bitwise AND ............................................................................................................................. 57
7.10.3 Bitwise OR ................................................................................................................................. 58
7.10.4 Bitwise XOR .............................................................................................................................. 58
7.10.5 Bitwise Le Shi ....................................................................................................................... 58
7.10.6 Bitwise Right Shi ....................................................................................................................59
7.11 Compound Bitwise Operators ....................................................................................................... 59
7.12 Summary .......................................................................................................................................... 60
8. Swi Control Flow .................................................................................................................................... 61
8.1 Looping Control Flow ...................................................................................................................... 61
8.2 e Swi for-in Statement ................................................................................................................ 61
8.2.1 e while Loop .......................................................................................................................... 62
8.3 e repeat ... while loop ................................................................................................................... 62
8.4 Breaking from Loops ........................................................................................................................ 63
8.5 e continue Statement ................................................................................................................... 63
8.6 Conditional Control Flow ................................................................................................................ 64
8.7 Using the if Statement ...................................................................................................................... 64
8.8 Using if ... else … Statements ......................................................................................................... 64
8.9 Using if ... else if ... Statements ........................................................................................................ 65