Swift 5.4 | New Features and Updates

Swift is the preferred programming language for the Apple ecosystem. It’s a safe, fast, and interactive option that combines the best in Apple’s engineering culture and the contributions from its open-source community. 

With the Swift 5.4 update, there is a significant improvement in the compilation, result builders entry, better code completion in expressions, and so on. Let’s see all the major updates that this new release has in store for us. 

Result builders

Function builders were unofficially a part of Swift 5.1. With this update, they are now formally here named as result builders. 

New result builders can now be defined with the help of new structs via @resultBuilder. This attribute informs SwiftUI which type to be considered as a result builder. However, all result builders need to define at least one static function.  

Implicit member syntax extension

There is an improved way of using implicit member expressions. There is now support for chains of static functions as opposed to a single static member earlier. The compiler can comprehend multiple chained members and act accordingly. 

Multiple variadic parameters in functions

Before this update, you had just one variadic parameter. To elaborate, there is now the possibility to use multiple variadic parameters in functions, subscripts, initializers, and methods. The only condition here is that all these parameters should have labels.  

For example, now one can create a function that will store which team won a particular football match and followed by a second parameter that will store the names of the players that scored the maximum touchdowns. 

Changes in local functions

Local functions now have overloading support. Meaning, nested functions can be overloaded and Swift can select which one gets to run based upon the types that are in use. 

Support for property wrappers

Introduced in 5.1, property wrappers were implemented to attach extra functionality to properties easily. This is now extended to include support for local variables too. 
All the changes mentioned above are well-received in the developers’ community so far. Do let us know which upgrade are you liking the best and which updates/ features are missing in your opinion.


Stay up to date with latest happenings in our space