swiftwwdc

Swift Macro #unwrap


In Apple's WWDC 2023 they announced macros and, among others, they showed us this code snippet:

macro unwrap<Wrapped>(_ expr: Wrapped, message: String) -> Wrapped

I have downloaded Xcode 15 Beta and tried to get it to work, without result. I get the error message of:

Macro 'unwrap(_:message:)' requires a definition

What can I do or how can I write this correctly?


Solution

  • You should create a new macro.In Xcode File → New → Package... and select Swift Macro