23rd Jun 2022

What’s new in swift? | WWDC 2022

Mobile App

Written By, Abhishek Bakhai

Overview

Early in this month of June was WWDC 2022. After a huge update in iOS 16, Now, let’s talk about the some technical updates about the SWIFT 5.7.

Swift Playgrounds

Swift playground allows users to create applications directly from Swift playground and submit it to the App-Store.

Swift Packages update

  1. Trust on First User (TOFU)
    • New security protocol where the fingerprint of a package is now being recorded when the package is first downloaded.
    • Report an error if the fingerprint is mismatched.

Plugins

  1. Command Plugins
    • Providing more secure build tools and extensible
    • Used for documentation generation, source code re-formatting, etc
    • Tool Ex: SwiftLint
  2. Build tool Plugins
    • Can implement additional build steps
    • Ex: Source Code Generation, Resource processing
    • Tool Ex: Sourcery
      Swift Build Tool

      Source

Performance Improvements

  1. Build Time
    • Faster type-checking for generics
  2. Run Time
    • Optimized protocol conformance checking

Concurrency

Can be deployed and used with all OS.Update in Actors, this year introduces Distributed Actors.

  1. Actors
    • Actors allow you to isolate your data using thread-safe, and concurrently executing code.
    • Actors allow you to isolate your data using thread-safe, and concurrently executing code.
  2. Distributed Actors
    • Similar to (local) actors bcz they encapsulate their state with communication exclusively through asynchronous calls
    • Ex.:

      Distributed Actor

  3. Actors Prioritization
    • Actors now execute the highest-priority work first

Async Algorithms

  • New open-source package that brings concurrency to a set of existing sequence algorithms.
  • Ex:

  • Also, we can use a try/catch pattern to handle things like network failures, data streaming etc.
  • Ex:

  • Merge
    Ex:

Regex Builder

  • Huge improvement to the developer experience around regex.
  • With RegexBuilder, we can use an expressive specific language to build regular expressions.
  • Ex:
    Regex

Updates in Swift 5.7

  • Important update of optional unwrapping
    Ex. => if let x now, became if let x
  • No need to manually specify a closures result type
  • Update scope of some and any keywords
    Ex:
    For Any

  • For more : Changelog.md

Written By,

iOS Developer at Yudiz Solutions Pvt. Ltd