Modal Title
DevOps Tools / Frontend Development / Software Development

Apple Highlights Swift Enhancements at WWDC22

At Apple’s Worldwide Developers Conference, new developer tools were released for Swift, giving it a more extensive list of features.
Jun 9th, 2022 8:50am by
Featued image for: Apple Highlights Swift Enhancements at WWDC22

Apple’s Worldwide Developers Conference took place this week, which included the unveiling of new iOS features and machinery like the M2 chip. The majority of the conference is about features and benefits for users, but there was a portion that contained a rollout specifically for the development community.

Swift is a programming language that Apple developed for building apps across their products. The open sourced language has undergone a few major updates since its announcement (and subsequent release) at the 2014 WWDC Conference — most recently in March of this year. Apple doesn’t seem to have any intention of easing off the gas pedal when it comes to expanding Swift. It’s not surprising. The app market is on fire, and other companies (see Microsoft’s recent collaborative app announcement) are also angling to be the authority in app building.

At WWDC, new developer tools were released — giving Swift a more extensive list of features. During the keynote presentation, Apple Engineer Manager Ben Cohen noted, “Over the last year, Swift has gotten even better with enhancements to concurrency, upgrades to make swift code easier to read and write, tooling to customer your workflow, and under-the-hood improvements.”

What’s New with Swift

One of the main points of the Swift update was concurrency. “It’s now possible to deploy code with Swift Concurrency to all operating systems released in the last three years,” said Cohen. It’s clear that Apple put a lot of effort into making it easy to read and write code that runs in parallel. “A big part of that is Swift’s actor model,” Cohen said. “Actors allow you to isolate your data using thread-safe, concurrently executing code. Swift prevents you from accidentally sharing that state between parallel threads, defining away a major source of bugs.”

Cohen added that the new update is taking it a step further with “distributed actors.” “Distributed actors can communicate across multiple processes or devices,” he said. “The ‘distributed’ keyword marks these efforts and methods that can be accessed remotely, whether that’s separate processes on your Mac, peer to peer between different devices, or from a device talking to your backend written with Swift on server.”

A related announcement was the new source package being released that “brings concurrency to Swift’s existing set of sequence algorithms,” according to Cohen. “For example,” he explained, “where Swift sequence protocols supports a zip algorithm to combine to sequences, async algorithms brings a version for zipping together two asynchronous sequences.”

Actors communicate through async/await.

Also wrapped up in the Swift update is an upgraded string processing capability. Regular expressions, which are used to help describe patterns you’re expecting to see in your string and pinpoint specific information, are being enhanced. The new ‘regular expression literal’ is “built directly into the language, allowing the Swift compiler to check for correctness,” said the engineering manager of Apple’s XCode, Ken Orr.

Custom Layouts with SwiftUI 

SwiftUI, Apple’s framework for building user interfaces across their platforms, received layout options a bit more complex than what’s been available in the past. There’s a new Grid container feature that allows developers to build layouts that are multidimensional and dynamic. You can also create your own containers that will have fully customizable behavior.

Chart building tools have also come to SwiftUI in the form of Swift Charts. Its features include reflecting the style of your app on the chart, offering the ability to code for portrait and landscape views, previewing the results of your data, and other visualization tools that make it easier to make sense of your data.

It could be argued that the Swift Charts tool has been a long time coming. After all, data is at the forefront of everyone’s minds these days.

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.