What's new in macros for 2024?

Generated on 8/2/2024

1 search

In 2024, Apple introduced several new features and improvements to macros in Swift. Here are the key updates:

  1. Previewable Macro: This new macro can be attached to property wrappers like @State, allowing you to use them directly within a preview block. This reduces the need to write wrapper views and simplifies the code required to see your UI live in Xcode previews. For more details, you can refer to the session What’s new in Xcode 16 (03:04).

  2. Preview Modifier: This new API makes it easier to share environment or data for previews, reducing duplicate code and enabling the preview system to cache the data. This helps in creating more efficient and reusable previews. More information can be found in the same session What’s new in Xcode 16 (03:04).

These updates are part of the broader improvements in Swift and Xcode aimed at enhancing the developer experience by making code more expressive and reducing boilerplate. For a comprehensive overview of what's new in Swift, you can check out the session What’s new in Swift (00:07).