Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SwiftUI Essentials - iOS Edition

You're reading from   SwiftUI Essentials - iOS Edition Learn to Develop iOS Apps using SwiftUI, Swift 5 and Xcode 11

Arrow left icon
Product type Paperback
Published in Nov 2018
Publisher Packt
ISBN-13 9781951442057
Length 813 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Neil Smyth Neil Smyth
Author Profile Icon Neil Smyth
Neil Smyth
Arrow right icon
View More author details
Toc

Table of Contents (373) Chapters Close

1. Start Here. 1 FREE CHAPTER
1.1 For Swift Programmers 1
1.2 For Non-Swift Programmers. 2
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 11 and the iOS 13 SDK. 3
2.2 Apple Developer Program.. 3
2.3 When to Enroll in the Apple Developer Program?. 4
2.4 Enrolling in the Apple Developer Program.. 4
2.5 Summary. 5
3. Installing Xcode 11 and the iOS 13 SDK. 7
3.1 Identifying Your macOS Version. 7
3.2 Installing Xcode 11 and the iOS 13 SDK. 8
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. An Introduction to Xcode 11 Playgrounds. 11
4.1 What is a Playground?. 11
4.2 Creating a New Playground. 11
4.3 A Basic Swift Playground Example. 13
4.4 Viewing Results 15
4.5 Adding Rich Text Comments. 16
4.6 Working with Playground Pages 18
4.7 Working with UIKit in Playgrounds 18
4.8 Adding Resources to a Playground. 20
4.9 Working with Enhanced Live Views 21
4.10 Summary. 23
5. Swift Data Types, Constants and Variables. 25
5.1 Using a Swift Playground. 26
5.2 Swift Data Types 26
5.2.1 Integer Data Types 26
5.2.2 Floating Point Data Types. 27
5.2.3 Bool Data Type. 27
5.2.4 Character Data Type. 27
5.2.5 String Data Type. 28
5.2.6 Special Characters/Escape Sequences 29
5.3 Swift Variables 30
5.4 Swift Constants. 30
5.5 Declaring Constants and Variables 30
5.6 Type Annotations and Type Inference. 30
5.7 The Swift Tuple. 31
5.8 The Swift Optional Type. 32
5.9 Type Casting and Type Checking. 36
5.10 Summary. 38
6. Swift Operators and Expressions 39
6.1 Expression Syntax in Swift 39
6.2 The Basic Assignment Operator 39
6.3 Swift Arithmetic Operators 39
6.4 Compound Assignment Operators. 40
6.5 Comparison Operators 41
6.6 Boolean Logical Operators 42
6.7 Range Operators 42
6.8 The Ternary Operator 43
6.9 Bitwise Operators 44
6.9.1 Bitwise NOT. 44
6.9.2 Bitwise AND. 45
6.9.3 Bitwise OR. 45
6.9.4 Bitwise XOR. 45
6.9.5 Bitwise Left Shift 46
6.9.6 Bitwise Right Shift 46
6.10 Compound Bitwise Operators 47
6.11 Summary. 47
7. Swift Control Flow.. 49
7.1 Looping Control Flow.. 49
7.2 The Swift for-in Statement 49
7.2.1 The while Loop. 50
7.3 The repeat ... while loop. 51
7.4 Breaking from Loops 51
7.5 The continue Statement 52
7.6 Conditional Flow Control 52
7.7 Using the if Statement 53
7.8 Using if ... else … Statements 53
7.9 Using if ... else if ... Statements 54
7.10 The guard Statement 54
7.11 Summary. 55
8. The Swift Switch Statement 57
8.1 Why Use a switch Statement?. 57
8.2 Using the switch Statement Syntax. 57
8.3 A Swift switch Statement Example. 58
8.4 Combining case Statements. 58
8.5 Range Matching in a switch Statement 59
8.6 Using the where statement 60
8.7 Fallthrough. 60
8.8 Summary. 61
9. An Overview of Swift 5 Functions, Methods and Closures 63
9.1 What is a Function?. 63
9.2 What is a Method?. 63
9.3 How to Declare a Swift Function. 63
9.4 Implicit Returns from Single Expressions 64
9.5 Calling a Swift Function. 65
9.6 Handling Return Values 65
9.7 Local and External Parameter Names 65
9.8 Declaring Default Function Parameters 66
9.9 Returning Multiple Results from a Function. 67
9.10 Variable Numbers of Function Parameters. 67
9.11 Parameters as Variables 68
9.12 Working with In-Out Parameters 68
9.13 Functions as Parameters 69
9.14 Closure Expressions. 71
9.15 Closures in Swift 73
9.16 Summary. 73
10. The Basics of Object-Oriented Programming in Swift 75
10.1 What is an Instance?. 75
10.2 What is a Class?. 75
10.3 Declaring a Swift Class 75
10.4 Adding Instance Properties to a Class 76
10.5 Defining Methods 76
10.6 Declaring and Initializing a Class Instance. 78
10.7 Initializing and Deinitializing a Class Instance. 78
10.8 Calling Methods and Accessing Properties 79
10.9 Stored and Computed Properties. 80
10.10 Lazy Stored Properties 81
10.11 Using self in Swift 82
10.12 Understanding Swift Protocols 84
10.13 Opaque Return Types. 85
10.14 Summary. 86
11. An Introduction to Swift Subclassing and Extensions 87
11.1 Inheritance, Classes and Subclasses. 87
11.2 A Swift Inheritance Example. 87
11.3 Extending the Functionality of a Subclass 88
11.4 Overriding Inherited Methods 89
11.5 Initializing the Subclass 90
11.6 Using the SavingsAccount Class. 91
11.7 Swift Class Extensions 91
11.8 Summary. 92
12. An Introduction to Swift Structures. 93
12.1 An Overview of Swift Structures 93
12.2 Value Types vs. Reference Types 94
12.3 When to use Structures or Classes 96
12.4 Summary. 96
13. An Introduction to Swift Property Wrappers 97
13.1 Understanding Property Wrappers 97
13.2 A Simple Property Wrapper Example. 97
13.3 Supporting Multiple Variables and Types 99
13.4 Summary. 102
14. Working with Array and Dictionary Collections in Swift 103
14.1 Mutable and Immutable Collections 103
14.2 Swift Array Initialization. 103
14.3 Working with Arrays in Swift 104
14.3.1 Array Item Count 104
14.3.2 Accessing Array Items 105
14.4 Random Items and Shuffling. 105
14.5 Appending Items to an Array. 105
14.5.1 Inserting and Deleting Array Items. 105
14.6 Array Iteration. 106
14.7 Creating Mixed Type Arrays. 106
14.8 Swift Dictionary Collections 107
14.9 Swift Dictionary Initialization. 107
14.10 Sequence-based Dictionary Initialization. 108
14.11 Dictionary Item Count 108
14.12 Accessing and Updating Dictionary Items 109
14.13 Adding and Removing Dictionary Entries 109
14.14 Dictionary Iteration. 109
14.15 Summary. 110
15. Understanding Error Handling in Swift 5. 111
15.1 Understanding Error Handling. 111
15.2 Declaring Error Types 111
15.3 Throwing an Error 112
15.4 Calling Throwing Methods and Functions. 113
15.5 Accessing the Error Object 114
15.6 Disabling Error Catching. 114
15.7 Using the defer Statement 114
15.8 Summary. 115
16. An Overview of SwiftUI 117
16.1 UIKit and Interface Builder 117
16.2 SwiftUI Declarative Syntax 118
16.3 SwiftUI is Data Driven. 118
16.4 SwiftUI vs. UIKit 119
16.5 Summary. 120
17. Using Xcode in SwiftUI Mode. 121
17.1 Starting Xcode 11. 121
17.2 Creating a SwiftUI Project 122
17.3 Xcode in SwiftUI Mode. 122
17.4 The Preview Canvas 123
17.5 Preview Pinning. 125
17.6 Modifying the Design. 125
17.7 Editor Context Menu. 129
17.8 Previewing on Multiple Device Configurations 129
17.9 Running the App on a Simulator 131
17.10 Running the App on a Physical iOS Device. 132
17.11 Managing Devices and Simulators. 134
17.12 Enabling Network Testing. 135
17.13 Dealing with Build Errors. 135
17.14 Monitoring Application Performance. 135
17.15 Exploring the User Interface Layout Hierarchy. 136
17.16 Summary. 139
18. The Anatomy of a Basic SwiftUI Project 141
18.1 Creating an Example Project 141
18.2 UIKit and SwiftUI 141
18.3 The AppDelegate.swift File. 141
18.4 The SceneDelegate.swift File. 142
18.5 ContentView.swift File. 144
18.6 Assets.xcassets. 144
18.7 Info.plist 144
18.8 LaunchScreen.storyboard. 144
18.9 Summary. 144
19. Creating Custom Views with SwiftUI 145
19.1 SwiftUI Views. 145
19.2 Creating a Basic View.. 145
19.3 Adding Additional Views 146
19.4 Working with Subviews. 148
19.5 Views as Properties 149
19.6 Modifying Views 150
19.7 Working with Text Styles 150
19.8 Modifier Ordering. 152
19.9 Custom Modifiers 153
19.10 Basic Event Handling. 153
19.11 The onAppear and onDisappear Methods 154
19.12 Building Custom Container Views. 155
19.13 Summary. 156
20. SwiftUI Stacks and Frames 157
20.1 SwiftUI Stacks. 157
20.2 Spacers, Alignment and Padding. 159
20.3 Container Child Limit 161
20.4 Text Line Limits and Layout Priority. 162
20.5 SwiftUI Frames 164
20.6 Frames and the Geometry Reader 166
20.7 Summary. 167
21. Working with SwiftUI State, Observable and Environment Objects 169
21.1 State Properties 169
21.2 State Binding. 171
21.3 Observable Objects. 172
21.4 Environment Objects 174
21.5 Summary. 176
22. A SwiftUI Example Tutorial 177
22.1 Creating the Example Project 177
22.2 Reviewing the Project 178
22.3 Adding a VStack to the Layout 180
22.4 Adding a Slider View to the Stack. 180
22.5 Adding a State Property. 181
22.6 Adding Modifiers to the Text View.. 182
22.7 Adding Rotation and Animation. 183
22.8 Adding a TextField to the Stack. 185
22.9 Adding a Color Picker 185
22.10 Tidying the Layout 187
22.11 Summary. 190
23. SwiftUI Observable and Environment Objects – A Tutorial 191
23.1 About the ObservableDemo Project 191
23.2 Creating the Project 191
23.3 Adding the Observable Object 191
23.4 Designing the ContentView Layout 192
23.5 Adding the Second View.. 194
23.6 Adding Navigation. 195
23.7 Using an Environment Object 196
23.8 Summary. 198
24. SwiftUI Stack Alignment and Alignment Guides. 199
24.1 Container Alignment 199
24.2 Alignment Guides. 201
24.3 Using the Alignment Guides Tool 205
24.4 Custom Alignment Types 206
24.5 Cross Stack Alignment 209
24.6 ZStack Custom Alignment 212
24.7 Summary. 215
25. SwiftUI Lists and Navigation. 217
25.1 SwiftUI Lists 217
25.2 SwiftUI Dynamic Lists 219
25.3 SwiftUI NavigationView and NavigationLink. 221
25.4 Making the List Editable. 223
25.5 Summary. 226
26. A SwiftUI List and Navigation Tutorial 227
26.1 About the ListNavDemo Project 227
26.2 Creating the ListNavDemo Project 227
26.3 Preparing the Project 227
26.4 Adding the Car Structure. 228
26.5 Loading the JSON Data. 229
26.6 Adding the Data Store. 230
26.7 Designing the Content View.. 230
26.8 Designing the Detail View.. 233
26.9 Adding Navigation to the List 235
26.10 Designing the Add Car View.. 236
26.11 Implementing Add and Edit Buttons 239
26.12 Adding the Edit Button Methods. 241
26.13 Summary. 242
27. Building Tabbed Views in SwiftUI 243
27.1 An Overview of SwiftUI TabView.. 243
27.2 Creating the TabViewDemo App. 244
27.3 Adding the TabView Container 244
27.4 Adding the Content Views 244
27.5 Adding the Tab Items. 244
27.6 Adding Tab Item Tags. 245
27.7 Summary. 246
28. Building Context Menus in SwiftUI 247
28.1 Creating the ContextMenuDemo Project 247
28.2 Preparing the Content View.. 247
28.3 Adding the Context Menu. 248
28.4 Testing the Context Menu. 249
28.5 Summary. 250
29. Basic SwiftUI Graphics Drawing. 251
29.1 Creating the DrawDemo Project 251
29.2 SwiftUI Shapes 251
29.3 Using Overlays 254
29.4 Drawing Custom Paths and Shapes 254
29.5 Drawing Gradients. 257
29.6 Summary. 260
30. SwiftUI Animation and Transitions 261
30.1 Creating the AnimationDemo Example Project 261
30.2 Implicit Animation. 261
30.3 Repeating an Animation. 264
30.4 Explicit Animation. 264
30.5 Animation and State Bindings 265
30.6 Automatically Starting an Animation. 266
30.7 SwiftUI Transitions. 269
30.8 Combining Transitions 270
30.9 Asymmetrical Transitions 271
30.10 Summary. 271
31. Working with Gesture Recognizers in SwiftUI 273
31.1 Creating the GestureDemo Example Project 273
31.2 Basic Gestures. 273
31.3 The onChange Action Callback. 275
31.4 The updating Callback Action. 276
31.5 Composing Gestures 278
31.6 Summary. 280
32. Integrating UIViews with SwiftUI 281
32.1 SwiftUI and UIKit Integration. 281
32.2 Integrating UIViews into SwiftUI 282
32.3 Adding a Coordinator 283
32.4 Handling UIKit Delegation and Data Sources. 284
32.5 An Example Project 286
32.6 Wrapping the UIScrolledView. 286
32.7 Implementing the Coordinator 287
32.8 Using MyScrollView.. 288
32.9 Summary. 289
33. Integrating UIViewControllers with SwiftUI 291
33.1 UIViewControllers and SwiftUI 291
33.2 Creating the ViewControllerDemo project 291
33.3 Wrapping the UIImagePickerController 291
33.4 Designing the Content View.. 293
33.5 Completing MyImagePicker 294
33.6 Completing the Content View.. 296
33.7 Testing the App. 297
33.8 Summary. 297
34. Integrating SwiftUI with UIKit 299
34.1 An Overview of the Hosting Controller 299
34.2 A UIHostingController Example Project 300
34.3 Adding the SwiftUI Content View. 300
34.4 Preparing the Storyboard. 301
34.5 Adding a Hosting Controller 302
34.6 Configuring the Segue Action. 304
34.7 Embedding a Container View.. 306
34.8 Embedding SwiftUI in Code. 308
34.9 Summary. 310
35. Preparing and Submitting an iOS 13 Application to the App Store. 311
35.1 Verifying the iOS Distribution Certificate. 311
35.2 Adding App Icons 313
35.3 Designing the Launch Screen. 314
35.4 Assign the Project to a Team.. 314
35.5 Archiving the Application for Distribution. 315
35.6 Configuring the Application in iTunes Connect 316
35.7 Validating and Submitting the Application. 317
35.8 Configuring and Submitting the App for Review.. 320
An Introduction to Swift Playgrounds
Working with Array and Dictionary Collections in Swift
The Swift Switch Statement
Swift Control Flow
The Basics of Object-Oriented Programming in Swift
Creating Custom Views with SwiftUI
Integrating UIViews with SwiftUI
Installing Xcode 11 and the iOS 13 SDK
SwiftUI Stacks and Frames
Joining the Apple Developer Program
An Overview of Swift 5 Functions, Methods and Closures
SwiftUI Stack Alignment and Alignment Guides
A SwiftUI Example Tutorial
SwiftUI Observable and Environment Objects – A Tutorial
SwiftUI Lists and Navigation
The Anatomy of a Basic SwiftUI Project
SwiftUI Animation and Transitions
Working with SwiftUI State, Observable and Environment Objects
A SwiftUI List and Navigation Tutorial
Integrating UIViewControllers with SwiftUI
Integrating SwiftUI with UIKit
35.6 Configuring the Application in iTunes Connect

Before an application can be submitted to the App Store for review it must first be configured in iTunes Connect. Enrollment in the Apple Developer program automatically results in the creation of an iTunes Connect account using the same login credentials. iTunes Connect is a portal where developers enter tax and payment information, input details about applications and track the status of those applications in terms of sales and revenues.

Access iTunes Connect by navigating to https://itunesconnect.apple.com in a web browser and entering your Apple Developer program login and password details.

First time users should click on the Agreements, Tax, and Banking option and work through the various tasks to accept Apple’s terms and conditions and to input appropriate tax and banking information for the receipt of sales revenue.

Once the administrative tasks are complete, select the My Apps option and click on the + button followed...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image