Issue #194 23 Sep 2021
Written by: Kristaps Grinbergs
How many of you have pre-ordered the new iPhone 13? Tomorrow is the big day, when we can see the new device hit the store shelves. Apple claims that the new iPhone has a brand new dual-camera system, a super-fast A15 chip and a massive leap in battery life.
But we are here not only for the new and pretty iPhone colors – Xcode 13.0 was released just a couple of days ago along with Swift 5.5. Here’s a listing of Swift 5.5 updates. This is a big release, and it includes quite a few new features. The iOS 13.0 release notes can be found here. And the work to back-deploy concurrency features to older Swift versions has begun.
To keep running this project and send you this newsletter, we are inviting sponsors to reach out. Your support is very much appreciated and helps us cover the platform costs.
Thanks to everyone involved and let’s get straight to the news.
Interested in sponsoring Swift Weekly Brief? Learn more here.
News and community
Cory Benfield informed us that Swift Crypto 2.0.0 was released.
Starter tasks
SR-15218 [Compiler] Enhance interchangeable CGFloat/Double to allow interchange between optional
Commits and pull requests
salinas-miguel’s PR that removes the Swift project’s dependency on Foundation on macOS was merged.
Doug Gregor created a pull request to back-deploy concurrency.
Proposals in review
SE-0323: Asynchronous Main Semantics is under review.
Program setup generally occurs in the main function where developers expect to perform operations before other parts of the program are run. Objective-C, C++, and C have initializers that are run before the main entrypoint runs and can interact with Swift’s concurrency systems in ways that are hard to reason about. In the Swift concurrency model, the developer-written asynchronous main function is wrapped in a task and enqueued on the main queue when the main entrypoint is run. If an initializer inserts a task on the main queue, that task may be executed before the main function, so setup is performed after initializer tasks are run.
SE-0324: Relax diagnostics for pointer arguments to C functions is under review.
C has special rules for pointer aliasing, for example allowing
char *
to alias other pointer types, and allowing pointers to signed and unsigned types to alias. The usability of some C APIs relies on the ability to easily cast pointers within the boundaries of those rules. Swift generally disallows typed pointer conversion. See SE-0107 UnsafeRawPointer API. Teaching the Swift compiler to allow pointer conversion within the rules of C when invoking functions imported from C headers will dramatically improve interoperability with no negative impact on type safety.
Swift Forums
Ashley Garland introduced some experimental work for a new Swift Package Manager feature for snippets.
We all know that learning by example is great, especially for code. I wanted to create the smallest, simplest method of providing example code for Swift packages, and I’ve just landed some work in progress in the Swift Package Manager.
Filip Sakel pitched a proposal to refine property wrapper related initialization.
SE 0258 introduced property wrappers and SE 0293 expanded them with function-like declarations. Today, property wrapper initialization exhibits inconsistencies due to its growing versatility. Specifically, memberwise initializers use complex, poorly documented rules and projection initialization remains limited. This proposal will simplify synthesized memberwise initialization for types with wrapped properties and extend projection value initialization to include global, type, and local wrapped properties.
Jordan Rose started a discussion about removing the implicit initialization of Optional variables.
In Swift 6, optional variables become uninitialized by default, like all other variables. Locals and globals get a fix-it to add
= nil
. Properties only get that fix-it in a note attached to the error about leaving the variable uninitialized, since it’s not obviously the right thing to do, only the Swift 5 thing to do. A migrator could auto-apply that fix too though.