Actors are reference types, but why classes?
The recently announced Swift Concurrency Roadmap includes the proposal of an Actor reference type, similar to a class type. In this whitepaper, Chris Lattner explores the behavior and requirements of actors and proposes that Actor types be modeled as a new kind of nominal reference type in Swift.
Posted on December 16, 2020
#concurrency
#evolution
#actor
HTTP in Swift, Part 6: Chaining Loaders
In part 6 of his series on building a Swift HTTP framework, Dave Delong looks at adding the ability to chain HTTP loading requests. To achieve this, Dave adapts his HTTPLoading protocol, formalizing his concept of a next loader.
Posted on December 10, 2020
#http
#network
Swift Concurrency Proposal Dependencies
The Swift Concurrency Roadmap was recently published, which outlined proposed additions and changes to the language to support concurrent programming. It's a great read, and very informative. However, if you are looking for a quick overview of the dependencies relating to the concurrency roadmap, this diagram from Doug Gregor is a good place to start.
Posted on December 9, 2020
#concurrency
#diagram
Codable synthesis for enums with associated values
Swift 4 introduced support for automatically synthesizing conformance to the Encodable and Decodable protocols. It's a useful feature, most likely used by any application which handles JSON-based network requests. This Swift evolution pitch from Dario Rexin proposes extending auto-synthesis of these conformances to enums with associated values. I'm sure we will see this in an upcoming Swift version.
Posted on December 8, 2020
#evolution
#enum
#codable
Statically computed default property values
As John Sundell writes in the introduction to this short post, defining default values for our API properties can improve the usability of our APIs while still enabling customization when needed. With that in mind, John shares a tip for setting a default property value while also reminding us of a crucial difference between a lazy property and a non-lazy one.
Posted on December 7, 2020
#property
#lazy
Testing the UI without UI Testing in Swift
Testing the user interface is an essential part of software development. Unfortunately, UI testing frameworks such as Apple's XCUITest are often unreliable and slow. However, there are other methods of testing the user interface, and in this post, Joe Masilotti shows us how to write UI tests using XCTest, Apple's unit testing framework.
Posted on December 6, 2020
#testing
HTTP in Swift, Part 5: Testing and Mocking
Dave Delong's blog series on building a Swift HTTP framework is full of useful tips, and this particular entry is no different. In this part, Dave looks at testing and mocking and shows us how using an interface rather than a concretion enhances the utility and testability of his code.
Posted on December 3, 2020
#network
#http
What went wrong with the libdispatch. A tale of caution for the future of concurrency.
Apple's Grand Central Dispatch (GCD or libdispatch) provides support for concurrent code execution on multicore hardware. It aims to remove the need for developers to directly manage threads, enabling them to instead think in terms of queues of work. In this very interesting post, Thomas examines some of the problems of using libdispatch, offering words of caution for the future of concurrency in Swift.
Posted on December 2, 2020
#concurrency
SwiftUI’s Grid Views
SwiftUI's grid views arrange their child views in a horizontal or vertical grid. However, how they layout their child views can be surprising, and in this post, Florian Kugler from Objc.io examines three particular grid view layout scenarios and explains how the layout algorithm works.
Posted on December 1, 2020
#swiftui
#layout
Availability checking for protocol conformances
Swift's availability checking feature currently allows us to check if a referenced declaration is available at runtime. In this post from the official Swift forums, Slava Pestov details an extension to this feature which provides the ability to check the availability of protocol conformances.
Posted on November 30, 2020
#evolution
#protocol