preface
Swift.org has made some very nice improvements recently, including support for Dark mode. For users using Dark Mode on iOS, the site will automatically switch modes to match.
In order to continuously release and update the Swift community weekly, we hope to invite Swift fans to participate in editing the weekly and also invite sponsors to support our platform.
An introduction to the task
Sr-15271 [Compiler] Improves coding-diagnostics when CodingKeys do not match attributes
News and Community
Ted Kremenek wrote an article about Swift 5.5.
Bruno Rocha has published an excellent article explaining how AsyncSequence works inside Swift.
Lee Kah Seng wrote an article describing the Actor Reentrancy problem in Swift.
Amritpan Kaur explains how she participated in the inaugural Swift Mentor and worked on compiler development and language design.
Commits and pull requests
Michael Ilseman incorporated a pull request that implements native normalization for strings.
Doug Gregor has created a pull Request that is backward compatible with @objc Actor types.
Agreed proposal
Se-0322 Temporary uninitialized buffer has been accepted for modification.
Se-0323 Asynchronous Main semantics accepted.
Se-0324 accepted the diagnostic proposal to relax pointer parameters for C functions.
A proposal under review
Sswg-0017: MultipartKit is under review.
MultipartKit provides low-level parsing and serialization of Multipart data, and advanced Codable support for encoding and decoding Multipart form data.
Swift BBS
1. Karoy Lorentey asked when will ManagedAtomic/UnsafeAtomic marked the Sendable?
Question #45 was just submitted requesting that UnsafeAtomic, ManagedAtomic, and friends be marked as Sendable, reflecting that they can be safely transferred across concurrent domains.
Kavon Farvardin proposes defining how actor initializers work in Swift.
Currently, suggested solutions to some of the issues described in this proposal are reflected in Swift 5.5 via alerts, but it is important to review these changes to Swift 6. In addition, the proposal adds additional functionality to the Deinit of the MainActor isolated class, which can be easier and safer to write. If you have new ideas and comments, please feel free to post them here.
3. Kelvin Ma found a serious stack corruption error in Swift 5.5.
I found several stack corruption errors related to async/await that could be reproduced in a simple test program compiled using the recent night toolchain. I have confirmed that there are two, three or four of these errors in the 5.5-Release toolchain.
I found several stack corruption errors related to async/await and can reproduce the problem in a simple test program of Recent Nightly ToolChains. I have identified multiple errors in the 5.5-Release Toolchain.
4. Becca Royal-Gordon proposed adding staging to Sendable checks.
A few weeks ago, @douglas_Gregor proposed some changes that attempt to address some of the issues involved in using Sendable checking in modules when some clients or dependencies may not have been updated. This approach can lead to problems and hidden bugs when the module is eventually updated, and how the Objective-C library can control the sendability of its types.
5. YR Chen started to discuss resolving the inconsistency in the Swift 6 release.
Some language designs with broken apis can be fixed in the Swift 6 release 3 years later. That’s a long time, and with Swift 3.2 and Swift 4.2 the transition to Swift breakthrough releases has proved much smoother.
It is recommended that we select some delayed breakpoints in order to eliminate inconsistencies in the language. These ideas have received positive feedback from the community, but have yet to be implemented.
6. Philippe Hausler proposed the definition of Clock, Instant, Date and Duration.
The concept of time can be divided into three distinct parts:
- Items that provide present concepts plus a way to wake up after a given point in time, * the concept of point in time
- The concept of time measurement
These are the clock, the moment and the duration. The measurement of time can be used for many types of apis, from the advanced concept of network connection timeouts to the amount of time spent sleeping tasks. Currently, the API for measuring time types uses NSTimeInterval also known as TimeInterval, DispatchTimeInterval, and even types like timespec.
7. Michael Ilseman came up with the idea of implementing a declarative string handling API.
String handling is difficult, and the Swift standard library currently provides insufficient functionality. We recommend adding two new declarative string processing apis, the familiar Regex text and a more powerful Pattern result generator, to make Swift string processing faster and easier.
This is a large feature that will eventually be divided into multiple Swift Evolution proposals. The main purpose is to advance the high-level discussion and introduce the key points of the functionality and their interrelationships.
8. Kelvin Ma started to discuss the long term support (” LTS “) version.
For those not following development topics, @Mickeyl, @Timdecode, I recently found a surprisingly high number of dangerous stack corruption bugs in the Swift 5.5 release toolchain.
Leaving aside the technical aspects of the stack corruption issue in Swift 5.5, is it worth adopting some form of “long term support” (LTS) version 8 concept in our release cycle, as Ubuntu has been doing all along?
9. Anders Bertelrud proposed an extension to the SwiftPM plugin API to provide more context.
Se-0303 introduced the SwiftPM plug-in with a special focus on build tool plug-ins (especially those that generate source code). To keep the boundaries of this proposal, the type and amount of information available to plug-ins is specific to the task of generating build commands.
Before you start thinking about new types of plug-ins, it seems sensible to extend the information available for all types of plug-ins. Future proposals may add specific apis for specific types of plug-ins, but until then, a good starting point seems to be to give all plug-ins access to a refined form of the package diagram they already have inside SwiftPM. This should allow a great deal of freedom for any particular plug-in.
I have a draft proposal to extend the API available for the SwiftPM plug-in and would like to hear your thoughts. There is an implementation of PR in the SwiftPM repository.
10. Guillaume Lessard has a proposal to expand the availability of withMemoryRebound.
The withMemoryRebound(to: Capacity :_ body:) function performs a closure that temporarily binds a range of memory to a different type than the one bound to the caller.
We recommend lifting some significant limitations on withMemoryRebound and enabling rebinding to a larger set of types, as well as rebinding from raw memory Pointers and buffers.
11. Tim Condon introduced the future of Async /await and Vapor to us.
12. Drew McCormack proposed a proposal that would create a standard library data structure for handling shared data in concurrent systems.
I’d like to suggest one type here: branch resources.
BranchingResource will be a type that carries a payload (that is, a resource) with common parameters. The resource will start with a single branch, called “main” or “trunk” or “truth.” The application can add any number of auxiliary named branches.
13. Pavel Yaskevich proposed the idea of enabling multi-statement Closure Parameter/Result Type inference.
I suggest improving the reasoning behavior of multi-statement closures by enabling parameter and result type inference from the closure body.
This makes type inference for developers less surprising and eliminates the problem of adding one more expression or statement to a closure that could cause a compilation failure.
Recommend the blog
IOS series
Baidu side summary (including the answer)
Use Swift to implement promises
I’ve been looking for information on how to use Swift to implement promises, and I haven’t found a good article, so I want to write one myself. In this article, we’ll implement our own Promise types to understand the logic behind them.
Using Swift to implement lightweight attribute monitoring system
The main purpose of this article is to solve the problem of “one model change, multiple UI updates” in client development. Of course, we need to know the details and thought process of the solution and see what it can achieve. We’ll use the idea of functional programming, and the great idea of generics.
SwiftUI series
3D Scroll effect with SwiftUI
After this tutorial, you can add this 3D effect to any custom SwiftUI view in your App.
How to make SwiftUI’s list more flexible
List is probably the most commonly used of the built-in views that ship with SwiftUI, enabling us to render a “table-view-like” user interface on any Apple platform. This year, List received a number of very important upgrades to make it more flexible and easy to customize. Let’s take a look at what’s new.
Use SwiftUI to create a ruler
To get some real graphing done, I’ll take you through creating a simple Spirograph with SwiftUI. “Spirograph” is the trade name for a toy in which you place a pencil in one circle and rotate it around the circle of another to create geometric patterns called roulette — like a casino game.
About us
We are jointly maintained by Swift enthusiasts. We will share technical content based on Swift combat, SwiftUI and Swift foundation, as well as collect excellent learning materials.
Thanks to SwiftWeekly for cooperating with us to launch the Chinese edition of SwiftWeekly.
Weekly warehouse: github.com/SwiftCommun…
The follow-up will also translate a large number of information to our public account, interested friends, can join us