Mastering iOS 14 Programming - Mario Eguiluz Alebicto - E-Book

Mastering iOS 14 Programming E-Book

Mario Eguiluz Alebicto

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Mastering iOS 14 development isn’t a straightforward task, but this book can help you do just that. With the help of Swift 5.3, you’ll not only learn how to program for iOS 14 but also be able to write efficient, readable, and maintainable Swift code that reflects industry best practices.
This updated fourth edition of the iOS 14 book will help you to build apps and get to grips with real-world app development flow. You’ll find detailed background information and practical examples that will help you get hands-on with using iOS 14's new features. The book also contains examples that highlight the language changes in Swift 5.3. As you advance through the chapters, you'll see how to apply Dark Mode to your app, understand lists and tables, and use animations effectively. You’ll then create your code using generics, protocols, and extensions and focus on using Core Data, before progressing to perform network calls and update your storage and UI with the help of sample projects. Toward the end, you'll make your apps smarter using machine learning, streamline the flow of your code with the Combine framework, and amaze users by using Vision framework and ARKit 4.0 features.
By the end of this iOS development book, you’ll be able to build apps that harness advanced techniques and make the best use of iOS 14’s features.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 652

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Mastering iOS 14 Programming

Fourth Edition

Build professional-grade iOS 14 applications with Swift 5.3 and Xcode 12.4

Mario Eguiluz Alebicto

Chris Barker

Donny Wals

BIRMINGHAM—MUMBAI

Mastering iOS 14 Programming

Fourth Edition

Copyright © 2021 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Associate Group Product Manager: Pavan Ramchandani

Publishing Product Manager: Rohit Rajkumar

Senior Editor: Hayden Edwards

Content Development Editor: Aamir Ahmed

Technical Editor: Deepesh Patel

Copy Editor: Safis Editing

Project Coordinator: Manthan Patel

Proofreader: Safis Editing

Indexer: Manju Arasan

Production Designer: Aparna Bhagat

First published: December 2016

Second Edition: October 2017

Third Edition: October 2018

Fourth Edition: March 2021

Production reference: 1170321

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-83882-284-2

www.packt.com


To my mother, Rosa; my sister, Laura; and my lovely Jasmine. Thanks for pushing me to improve every day, thanks for helping me, and thanks for supporting me along the way. Keep making everyone around you shine with your positivity, energy, and inspiration.

– Mario Eguiluz Alebicto

For my partner, Mandy, who is the strongest and bravest woman I have ever met, and to our beautiful daughter, Madeleine – thank you both for your love and support.

– Chris Barker

Contributors

About the authors

Mario Eguiluz Alebicto is a software engineer with over 15 years of experience in development. He started developing software with Java, later switched to Objective-C when the first iPhone delighted the world, and now, he is working with Swift and involved in backend technologies. He loves to code, build exciting projects, and learn new languages and frameworks.

Apart from software development, Mario loves to travel, learn new hobbies, practice sports, and considers himself a hardcore gamer, which he has been since he was a child.

I want to thank my mother, my sister, and my girlfriend, for their love and unconditional support. Also, I want to thank Divij, Aamir, and all the team at Packt for their guidance and work on this book. You all are awesome!

Chris Barker is an iOS developer and tech lead for fashion retailer N Brown (JD Williams, SimplyBe, Jacamo), where he heads up the iOS team. Chris started his career developing .NET applications for online retailer dabs.com (now BT Shop) before he made his move into mobile app development with digital agency Openshadow (now MyStudioFactory Paris). There, he worked on mobile apps for clients such as Louis Vuitton, L'Oréal Paris, and the Paris Metro. Chris often attends and speaks at local iOS developer meetups and conferences such as NSManchester, Malaga Mobile, and CodeMobile.

Donny Wals is a passionate, curious, iOS developer from the Netherlands. With several years of experience in building apps and sharing knowledge under his belt, Donny is a respected member of the iOS development community. Donny enjoys delivering talks on small and large scales to share his knowledge and experiences with his peers. In addition to sharing knowledge, Donny loves learning more about iOS, Apple's frameworks, and development in general. This eagerness to learn has made him a versatile iOS developer with knowledge of a significant number of Apple's frameworks and tools. During WWDC, you will often find Donny binge-watching the talks that Apple engineers deliver to introduce new features and frameworks.

About the reviewers

Juan Catalan is a software developer with more than 10 years of experience, having started learning iOS almost from the beginning. He has worked as a professional iOS developer in many industries, including industrial automation, transportation, document management, fleet tracking, real estate, and financial services. Juan has contributed to more than 30 published apps, some of them with millions of users. He has a passion for software architecture, always looking for ways to write better code and optimize a mobile app.

Gareth Hallberg is an experienced mobile solutions architect with a demonstrated history of working in the information technology and services industry, skilled in mobile applications, iOS and Android development, and social media.

He's been writing software for over 20 years, focusing mostly on iOS and Android apps since the days of iOS 3 and Android Froyo, using Objective-C and Java before embracing Swift and Kotlin. He doesn't miss the days of retain, release, and auto release but likes to get down close to the metal to create apps that work efficiently and elegantly.

Table of Contents

Preface

Chapter 1: What's New in iOS 14?

Technical requirements

Introducing App Clips

App Clip user journey

App Clips invocation methods

App Clips guidelines

Introducing WidgetKit

Widgets options

Widget guidelines

Improvements in augmented reality

Improvements in machine learning

Core ML Model Deployment, collections, and targeted deployments

Model encryption

Improvements in user privacy

Introducing Swift 5.2

Key path expressions as functions

Callable values of user-defined nominal types

Subscripts can now declare default arguments

Lazy filtering order is now reversed

New and improved diagnostics

Introducing Swift 5.3

Multi-pattern catch clauses

Multiple trailing closures

Synthesized comparable conformance for enum types

Increase availability of implicit self in escaping closures when reference cycles are unlikely to occur

Type-based program entry points – @main

Use where clauses on contextually generic declarations

Enum cases as protocol witnesses

Refine didSet semantics

Float16

Summary

Further reading

Chapter 2: Working with Dark Mode

Technical requirements

What is Dark Mode?

Understanding why we would need Dark Mode

Core developer concepts of Dark Mode

Dark mode from inside Xcode

Working with views in Dark Mode

What are adaptive colors?

What are semantic colors?

Using the programmatic approach

Working with the asset catalog for Dark Mode

Using custom adaptive colors

Using custom adaptive images

Further exploring Dark Mode

Using Dark Mode with SwiftUI

Programatically handling changes with trait collection

Specifying an appearance for views, ViewControllers, and windows

Accessibility in Dark Mode

Summary

Further reading

Chapter 3: Using Lists and Tables

Technical requirements

Working with UITableView

Setting up the project

Fetching contacts data

Prepping UITableView to display our contacts

Understanding protocols and delegation

Conforming to the UITableView protocols

Understanding the custom UITableViewCell override and the reuse identifier

Exploring UITableView further

Further understanding reuse identifiers

Prefetching in table views

Cell selection in table views

Working with UICollectionView

Setting up our collection view

Implementing layout with UICollectionViewDelegateFlowLayout

Exploring UICollectionView further

Implementing a custom UICollectionViewLayout

Cell selection in collection views

Working with lists in SwiftUI

Creating our first SwiftUI project

Building a list in SwiftUI

The equivalent to creating a custom cell in SwiftUI

Summary

Further reading

Chapter 4: Creating a Detail Page

Technical requirements

Implementing navigation with segues

Creating our new details view

Implementing and understanding segues

Creating a manual segue

Creating our layouts with UIStackView

Containing labels in a stack view

Passing data between view controllers

Updating the data loading

Passing the model to the details page

Updating our outlets

Best practices – creating a view model

Summary

Further reading

Chapter 5: Immersing Your Users with Animation

Technical requirements

Using UIView.animate and UIViewPropertyAnimator

Creating our first animation

Working with multiple animations

Refactoring with UIViewPropertyAnimator

Understanding and controlling animation progress

Interactions with a pan gesture recognizer

Adding vibrancy to animations

Adding dynamism with UIKit Dynamics

Customizing view controller transitions

Implementing a custom modal presentation transition

Summary

Chapter 6: Understanding the Swift Type System

Technical requirements

Understanding available types in Swift

Working with reference types

Working with value types

Understanding structs

Understanding enums

Understanding differences in types

Comparing value types to reference types

Differences in usage

Deciding which type to use

When should I use a reference type?

When to use a value type

Summary

Chapter 7: Flexible Code with Protocols, Generics, and Extensions

Technical requirements

Understanding and implementing protocols

Defining your own protocols

Checking for traits instead of types

Extending your protocols with default behavior

Improving your protocols with associated types

Adding flexibility with generics

Summary

Chapter 8: Adding Core Data to Your App

Technical requirements

Understanding the Core Data stack

Adding Core Data to an existing application

Creating a Core Data model

Creating the models

Defining relationships

Using your entities

Persisting data and reacting to data changes

Understanding data persistence

Persisting your models

Refactoring the persistence code

Reading data with a simple fetch request

Filtering data with predicates

Reacting to database changes

Understanding the use of multiple instances of NSManagedObjectContext

Refactoring the persisting code

Summary

Further reading

Chapter 9: Fetching and Displaying Data from the Network

Technical requirements

Fetching data from the web with URLSession

Understanding the basics of URLSession

Working with JSON in Swift

Updating Core Data objects with fetched data

Implementing the fetch logic

Updating a movie with a popularity rating

Visualizing multiple threads

Summary

Chapter 10: Making Smarter Apps with Core ML

Technical requirements

Understanding machine learning and Core ML

Understanding what machine learning is

Understanding Core ML

Combining Core ML and computer vision

Understanding the Vision framework

Implementing an image classifier

Training your own models with Create ML

Training a Natural Language model

Training a Vision model

Updating models remotely with Model Deployment

Using the Core ML API to retrieve collections of models

Preparing and deploying the model

Encrypting Core ML models

Summary

Chapter 11: Adding Media to Your App

Technical requirements

Playing audio and video

Creating a simple video player

Creating an audio player

Playing media in the background

Recording video and taking pictures

Taking and storing a picture

Recording and storing video

Manipulating photos with Core Image

Summary

Chapter 12: Improving Apps with Location Services

Technical requirements

Requesting a user's location

Asking for permission to access location data

Obtaining a user's location

Subscribing to location changes

Setting up geofences

Summary

Chapter 13: Working with the Combine Framework

Technical requirements

Understanding the Combine framework

Understanding Publisher

Understanding Subscriber

Understanding Operators

Understanding Subject

Combining Publishers, Subscribers, and Operators

Using Operators to build error-proof streams

Summary

Chapter 14: Creating an App Clip for Your App

Technical requirements

Introducing App Clips

App Clip User Journey

App Clips Invocation Methods

Developing your first App Clip

Creating the App Clip's Target

Sharing resources and code with the App Clip

Using Active Compilation Conditions

Configuring, linking, and triggering your App Clip

Testing your App Clip Experiences

Summary

Chapter 15: Recognition with Vision Framework

Technical requirements

Introduction to the Vision framework

Recognizing text in images

Region of interest

Recognizing hand landmarks in real time

Understanding hand landmarks

Implementing hand detection

Summary

Chapter 16: Creating Your First Widget

Technical requirements

Introducing widgets and WidgetKit

Widget options

Widget guidelines

Developing your first widget

Creating a widget extension

Implementing multiple-size widgets

Providing the widget with data and configuration

Refreshing the widget's data

Summary

Chapter 17: Using Augmented Reality

Understanding ARKit

Understanding how ARKit renders content

Understanding how ARKit tracks the physical environment

Using ARKit Quick Look

Implementing the ARKit Quick Look view controller

Exploring SpriteKit

Creating a SpriteKit scene

Exploring SceneKit

Creating a basic SceneKit scene

Implementing an Augmented Reality gallery

Adding image tracking

Preparing images for tracking

Building the image tracking experience

Placing your own content in 3D space

Summary

Chapter 18: Creating a macOS app with Catalyst

Technical requirements

Discovering Mac Catalyst

Exploring new Mac Catalyst features

Building your first Mac Catalyst app

Exploring the iPad app

Scaling your iPad app for Mac

Optimizing your iPad app for Mac

Summary

Chapter 19: Ensuring App Quality with Tests

Testing logic with XCTest

Understanding what it means to test code

Setting up a test suite with XCTest

Optimizing code for testability

Introducing the question loader

Mocking API responses

Using models for consistency

Gaining insights through code coverage

Testing the user interface with XCUITest

Making your app accessible to your tests

Recording UI tests

Passing launch arguments to your app

Making sure the UI updates as expected

Summary

Chapter 20: Submitting Your App to the App Store

Adding your application to App Store Connect

Packaging and uploading your app for beta testing

Preparing your app for launch

Summary

Why subscribe?

Other Books You May Enjoy

Packt is searching for authors like you

Leave a review - let other readers know what you think

Chapter 2: Working with Dark Mode

We all love it…well most of us do anyway, and those who do have been asking for it for a while now too. Apple first took the plunge into Dark Mode with macOS Mojave back in 2018, not only changing the way users interacted with the OS but also paving the way for developers to build native dark-themed apps for the first time.

Dark mode for iPhone wasn't announced until WWDC 2019, but we all knew it was coming, and with everything that AppKit had offered, we knew we were in for a treat with what UIKit would have to offer.

In this chapter, we'll cover everything you need to know to get up and running with dark mode in iOS and iPadOS; everything from taking an existing app and making the necessary adjustments to support dark mode, to all the little hidden extras that we can add in when building our app to ensure we give the user the best possible experience. We'll also touch on best practices too – taking note of the little things we can do that allow Dark Mode in UIKit to make our lives so much easier from the start.

The following topics will be covered in this chapter:

What is Dark Mode?Working with views in Dark ModeWorking with assetsFurther exploring Dark Mode

Technical requirements

For this chapter, you'll need to download Xcode version 11.4 or above from Apple's App Store.

You'll also need to be running the latest version of macOS (Catalina or above). Simply search for Xcode in the App Store and select and download the latest version. Launch Xcode and follow any additional installation instructions that your system may prompt you with. Once Xcode has fully launched, you're ready to go.

Download the sample code from the following GitHub link: https://github.com/PacktPublishing/Mastering-iOS-14-Programming-4th-Edition.

What is Dark Mode?

In this section, we'll