Modern
Concurrency
in Swift
By Marin Todorov
Modern Concurrency in Swift
By Marin Todorov
Copyright 2021 Razeware LLC.
Notice of Rights
All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner.
Notice of Liability
This book and all corresponding materials (such as source code) are provided on an as is basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software.
Trademarks
All trademarks and registered trademarks appearing in this book are the property of their own respective owners.
Book License
By purchasing Modern Concurrency in Swift, you have the following license:
You are allowed to use and/or modify the source code in Modern Concurrency in Swift in as many apps as you want, with no attribution required.
You are allowed to use and/or modify all art, images and designs that are included in Modern Concurrency in Swift in as many apps as you want, but must include this attribution line somewhere inside your app: Artwork/images/designs: from Modern Concurrency in Swift, available at www.raywenderlich.com.
The source code included in Modern Concurrency in Swift is for your personal use only. You are NOT allowed to distribute or sell the source code in Modern Concurrency in Swift without prior authorization.
This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends, coworkers or students; they would need to purchase their own copies.
All materials provided with this book are provided on an as is basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
All trademarks and registered trademarks appearing in this guide are the properties of their respective owners.
Before You Begin
This section tells you a few things you need to know before you get started, such as what youll need for hardware and software, where to find the project files for this book, and more.
What You Need
To follow along with this book, youll need the following:
A Mac running macOS Monterey (12.0) or later. Big Sur should work, but this book was written and tested on macOS Monterey, so your mileage may vary.
Xcode 13 or later. Xcode is the main development tool for iOS. Youll need Xcode 13 or newer for the tasks in this book. If youre using Xcode 13.2 and above, the new async
/await
syntax and the rest of the modern concurrency features will work starting with iOS 13 / macOS 10.15 SDK (or later). If youre using an older version of Xcode 13, youll only get modern concurrency support when targeting iOS 15 / macOS 12. You can download the latest version of Xcode from Apples developer site (https://apple.co/2asi58y)
An intermediate level of Swift. Concurrency in general is a relatively advanced topic, so you need to have at least an intermediate-level knowledge of Swift and its existing concurrency features. This book wont teach pre-Swift 5.5 Concurrency features such as Grand Central Dispatch, but you should still be able to follow the contents of this book, even if youre not entirely proficient with them.
This book does not require a physical device. However, you might want to try some of the advanced concurrency features on a real device, so you can truly feel how it works in the real world.
Book Source Code & Forums
Where to download the materials for this book
The materials for this book can be cloned or downloaded from the GitHub book materials repository:
Forums
Weve also set up an official forum for the book at https://forums.raywenderlich.com/c/books/modern-concurrency-in-swift. This is a great place to ask questions about the book or to submit any errors you may find.
Dedications
Dedicated to my daughter and family. Warm thanks to everyone on the extended team that made this book possible.
Marin Todorov
About the Authors
Marin Todorov is a developer, speaker and author. He works for high-profile clients, most often doing Swift development.Besides crafting code, he enjoys blogging, writing books, teaching and speaking. He sometimes open-sources his code.More about Marin at: https://www.underplot.com
About the Editors
Rich Turton is a tech editor for this book. Hes been developing apps for Apple platforms since before it was cool. He lives in the UK with his wife, daughters and terrible cat.
Felipe Laso Marsetti is a tech editor for this book. Hes a Technical Lead working at Lextech Global Services. In his spare time, Felipe enjoys learning new languages and frameworks, playing violin and guitar, cooking and also video games. You can follow him on Twitter as @iFeliLM (https://twitter.com/iFeliLM) or on his blog at https://programmer.pink.
Sandra Grauschopf is the editor of this book. Shes a freelance writer, editor, and content strategist as well as the Editing Team Lead at raywenderlich.com. She loves to untangle tortured sentences and to travel the world with a trusty book in her hand. You can follow her on Twitter at https://twitter.com/sgrauschopf or learn more about her at https://grauschopf.com.
Shai Mishali is the final pass editor on this book. Hes an experienced, award-winning iOS specialist, an international speaker and a highly active open-source contributor and maintainer on several high-profile projects. He works on the RxSwift Community and RxSwift projects, but also releases many open-source endeavors around Combine such as CombineCocoa, RxCombine and more. As an avid enthusiast of hackathons, Shai took first place at BattleHack Tel-Aviv 2014, BattleHack World Finals San Jose 2014 and Fords Developer Challenge Tel-Aviv 2015. You can find him on GitHub (https://github.com/freak4pc) and Twitter as @freak4pc (https://twitter.com/freak4pc).