Macros | Documentation
Macros transform your source code when you compile it, letting you avoid writing repetitive code by hand. During compilation, Swift expands any macros in your code before building your code as usual. Expanding a macro is always an additive operation: Macros add new code, but they never delete or modify existing code. Both the input to a macro and the output of macro expansion are checked to ensure they’re syntactically valid Swift code. Likewise, the values you pass to a macro and the values in code generated by a macro are checked to ensure they have the correct types. In addition, if the macro’s implementation encounters an error when expanding that macro, the compiler treats this as a compilation error. These guarantees make it easier to reason about code that uses macros, and they make it easier to identify issues like using a macro incorrectly or a macro implementation that has a bug. Swift has two kinds of macros: Freestanding macros appear on their own, without being attached to
To navigate the symbols, press Up Arrow, Down Arrow, Left Arrow or Right Arrow No items were found 1 item was found {number} items were found. Tab back to navigate through them. re looking for can't be found."},"color-scheme":{"select":"Select a color scheme preference","auto":"Auto","dark":"Dark","light":"Light"},"accessibility":{"strike":{"start":"start of stricken text","end":"end of stricken text"},"code":{"start":"start of code block","end":"end of code block"},"skip-navigation":"Skip Navigation","in-page-link":"in page link"},"select-language":"Select the language for this page","icons":
related reading
- Swift Macros: Understanding Freestanding & Attached Macros - QuickBird Studiosquickbirdstudios.com
- Macros - The Rust Programming Languageweb.mit.edu
- Documentationdocs.swift.org
- SwiftUI by Example - free quick start tutorials for Swift developershackingwithswift.com
- Documentationdocs.swift.org
- Building a menu using List - a free SwiftUI by Example tutorialhackingwithswift.com
- Documentationdocs.swift.org
- Documentationdocs.swift.org
- Configuring views | Apple Developer Documentationdeveloper.apple.com
- DevDocs API Documentationdevdocs.io
- Swift: From Protocol to AssociatedType then Type Erasure | Welcome to Monstarlab’s Engineering Blogengineering.monstar-lab.com
- Documentationdocs.swift.org