New way to declare environment variables

Asked on 2024-08-03

1 search

In the session What’s new in SwiftUI, Apple introduced a new way to declare environment variables using the entry macro. This simplifies the process by allowing you to write a simple property instead of having to write out a full conformance to EnvironmentKey and an extension on EnvironmentValues. The entry macro can also be used with focus values, transactions, and the new container values.

For more details, you can refer to the chapter "Framework foundations: Ease of use" in the session What’s new in SwiftUI.