Two types of Swift macros
What is macro? 💡 Macro is a feature that generates code during compilation. Unlike macros in C, which work like “find and replace”, Swift macros are type-safe and context aware, making them powerful tools reducing boilerplate code. Two types of macros attached - use @ prefix, tied to a declaration adding extra logic to it, like: @Test, @Model, @Observable freestanding - use # prefix, standalone code that can be invoked independently as a part of the code, like #expect, #Predicate, #warning Example of attached macro ⤵️...