<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/externalMacro(module:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s13externalMacro6module4typexSS_SStclufm"
  },
  "title" : "externalMacro(module:type:)"
}
-->

# externalMacro(module:type:)

Specifies the module and type name for a macro’s implementation.

```
@freestanding(expression) macro externalMacro<T>(module: String, type: String) -> T
```

## Parameters

`module`

The module name.

`type`

The type that implements the macro.

## Return Value

The macro’s implementation.

## Overview

This macro can only be used to define a macro;
using it in any other context is an error.
The specified type must conform to the protocols
that correspond to the roles of the macro being declared.
For example:

```swift
macro stringify(_ value: T) -> (T, String) =
    #externalMacro(module: "ExampleMacros", type: "StringifyMacro")
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)