Skip to content

Commit f4ed12b

Browse files
authored
Add info about macro entry point (#182)
This type is added when you create a new macro project, but there isn't documentation about this requirement elsewhere. Omitting a macro entry point type produces some inscrutable errors.
2 parents 3d73694 + 0416eef commit f4ed12b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

TSPL.docc/LanguageGuide/Macros.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,19 @@ private func fourCharacterCode(for characters: String) -> UInt32? {
552552
enum CustomError: Error { case message(String) }
553553
```
554554

555+
If you're adding this macro to an existing Swift Package Manager project,
556+
add a type that acts as the entry point for the macro target
557+
and lists the macros that the target defines:
558+
559+
```swift
560+
import SwiftCompilerPlugin
561+
562+
@main
563+
struct MyProjectMacros: CompilerPlugin {
564+
var providingMacros: [Macro.Type] = [FourCharacterCode.self]
565+
}
566+
```
567+
555568
The `#fourCharacterCode` macro
556569
is a freestanding macro that produces an expression,
557570
so the `FourCharacterCode` type that implements it

0 commit comments

Comments
 (0)