<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/swift-macros-understanding-freestanding-attached-macros-miwvn6mgi" -->

---
title: Swift Macros: Understanding Freestanding &amp; Attached Macros
description: Swift Macros allow packages to expose code generation functionality that can simplify code and reduce boilerplate. This post explains the different types of...
canonical: https://daily.dev/posts/swift-macros-understanding-freestanding-attached-macros-miwvn6mgi
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Swift Macros: Understanding Freestanding &amp; Attached Macros | daily.dev
og:description: Swift Macros allow packages to expose code generation functionality that can simplify code and reduce boilerplate. This post explains the different types of...
og:url: https://daily.dev/posts/swift-macros-understanding-freestanding-attached-macros-miwvn6mgi
og:image: https://api.daily.dev/og/posts/mIWvn6mgi.png
og:image:alt: Swift Macros: Understanding Freestanding &amp; Attached Macros
og:image:width: 1200
og:image:height: 630
og:locale: en
---

[QuickBird Studios](https://daily.dev/sources/quickbirdstudios)

[Read post](https://api.daily.dev/r/mIWvn6mgi)

# [Swift Macros: Understanding Freestanding & Attached Macros](https://api.daily.dev/r/mIWvn6mgi "Go to post")

Swift Macros allow packages to expose code generation functionality that can simplify code and reduce boilerplate. This post explains the different types of Macros in Swift (freestanding and attached) and their usage. It also discusses the benefits and limitations of using Swift Macros.

[#swift](/tags/swift "Check all #swift posts")

Jun 09, 2024•17m read time•From [quickbirdstudios.com](https://api.daily.dev/r/mIWvn6mgi "quickbirdstudios.com")

[![Post cover image](https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/726a0eebb4597c0e0f15e3ade635fd43?_a=AQAEuiZ)](https://api.daily.dev/r/mIWvn6mgi "Go to post")

Table of contents

[Types of Macros](https://api.daily.dev/r/mIWvn6mgi "Types of Macros")[Let’s create a macro!](https://api.daily.dev/r/mIWvn6mgi "Let’s create a macro!")[Discussion](https://api.daily.dev/r/mIWvn6mgi "Discussion")[Conclusion](https://api.daily.dev/r/mIWvn6mgi "Conclusion")

11 Impressions1 Upvote

Comment

Bookmark

Copy

![Placeholder image for anonymous user](https://media.daily.dev/image/upload/s--qsFuKGv_--/t_logo,f_auto/public/noProfile)Share your thoughtsPost

[![QuickBird Studios's image](https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/1e2ab41bd3a54f1eb328ef68649ebf20)](https://daily.dev/sources/quickbirdstudios)

[QuickBird Studios](https://daily.dev/sources/quickbirdstudios "https://daily.dev/sources/quickbirdstudios")

4 Followers

•

32 Upvotes

#### Would you recommend this post?

Copy link

WhatsApp

Facebook

X

New Squad

Copy linkShare with your friends

1

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Swift Macros: Understanding Freestanding & Attached Macros","url":"https://daily.dev/posts/swift-macros-understanding-freestanding-attached-macros-miwvn6mgi","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/swift-macros-understanding-freestanding-attached-macros-miwvn6mgi"},"datePublished":"2024-06-09T14:09:45.186Z","dateModified":"2024-08-23T15:14:37.047Z","description":"Swift Macros allow packages to expose code generation functionality that can simplify code and reduce boilerplate. This post explains the different types of...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/726a0eebb4597c0e0f15e3ade635fd43?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/726a0eebb4597c0e0f15e3ade635fd43?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":"QuickBird Studios","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"QuickBird Studios","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/1e2ab41bd3a54f1eb328ef68649ebf20","url":"https://daily.dev/sources/quickbirdstudios"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/swift-macros-understanding-freestanding-attached-macros-miwvn6mgi","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"QuickBird Studios","item":"https://daily.dev/sources/quickbirdstudios"},{"@type":"ListItem","position":3,"name":"Swift Macros: Understanding Freestanding & Attached Macros"}]}
```

