Another exciting day at WWDC as we took a deeper dive into the new software updates and features in Swift. Swift 4.2 came packed with new build optimizations, APIs, and features. There were some new performance updates that should result in faster debug builds (2x). Some runtime optimizations included the new 16-byte string as well as no memory allocations for small strings. There were also some improvements for reduced code size. Projects now have a new optimization method in which code size is reduced about 10% to 30% when using the new Optimize for Size [-Osize] build configuration setting. It should be noted however that this will result in a runtime performance of about 5% slower.

Other updates included a new CaseIterable protocol that automatically generates an array from all the cases in an enum. This means no more extensions with static variables. All you need to do is make your enum conform to the ‘CaseIterable’ protocol (eg: Car.allCases)! We also can’t forget about the improvements to hashes. With the updated Hashable protocol conformance, you can create a hash from multiple values hasher.combine(var). You can also create your own hash using the new func hash(into hasher: inout Hasher) function. There were also some updates to the Equatable protocol. Now, arrays of an equatable type are now equatable. One of my favorite updates was the new RandomNumberGenerator protocol! This brings all new ways to generate random numbers in Swift 4.2! All numeric types includes a new random method Int.random(in: 1..<22).

There were much much more updates to Swift and the ecosystem that you should definitely take a look at! Some other improvements were in Cocoa Touch. There were some great improvements to scrolling in iOS. We had a good reminder to use the table view’s prefetch APIs for improved performance. In iOS 12, the CPU received a performance update where it will ramp up much more quickly to deliver the performance needed when a cell needs to be drawn. So look forward to buttery smooth scrolling in iOS 12! There were also some new Auto Layout updates. Auto Layout now is faster by default. It includes some improved algorithms for handling dependent sibling views as well as nested views. Dependent sibling and nested views will now have a linear asymptotic complexity instead of an exponential. There were updates to notifications, automatic passwords, safe areas, Siri shortcuts, Research Kit, Health Kit, and more!