---
title: Macros
framework: swift
role: collectionGroup
role_heading: API Collection
path: swift/macros
---

# Macros

Generate boilerplate code and perform other compile-time operations.

## Topics

### Essentials

- [Applying Macros](swift/applying-macros.md)

### Getting Source Location Information

- [file()](swift/file().md)
- [fileID()](swift/fileid().md)
- [filePath()](swift/filepath().md)
- [function()](swift/function().md)
- [line()](swift/line().md)
- [column()](swift/column().md)

### Generating Compile-Time Diagnostics

- [warning(_:)](swift/warning(_:).md)
- [error(_:)](swift/error(_:).md)

### Writing Custom Macros

- [externalMacro(module:type:)](swift/externalmacro(module:type:).md)

### Accessing the Dynamic Shared Object Handle

- [dsohandle()](swift/dsohandle().md)

## See Also

### Programming Tasks

- [Input and Output](swift/input-and-output.md)
- [Debugging and Reflection](swift/debugging-and-reflection.md)
- [Concurrency](swift/concurrency.md)
- [Key-Path Expressions](swift/key-path-expressions.md)
- [Manual Memory Management](swift/manual-memory-management.md)
- [Type Casting and Existential Types](swift/type-casting-and-existential-types.md)
- [C Interoperability](swift/c-interoperability.md)
- [Operator Declarations](swift/operator-declarations.md)
