Backward compatibility is inevitable. Unless you build an app for the latest version of iOS and plan to support that – and only that – version of iOS, you're going to have to handle backward compatibility at some point. In this recipe, we'll take a look at what Apple offers in terms of building for APIs that have been built with older versions of Swift.
We'll also take a look at migration options from previous versions of Swift and if and how legacy projects can be updated to their latest versions.
How to do it...
We all want to use the latest shiny features in our app. Luckily, Apple makes this relatively easy for us to handle with the use of the #available check. So, how does this work? Well, primarily, it can work in three ways: at the function level, at the class level, and at the inline API level.
Let's start with the latter and have a look at how we would do this at the API level:
- Here is an example of setting maskedCorners...