# Trying to write a Macro, but I cannot compile

**URL:** <https://forums.swift.org/t/trying-to-write-a-macro-but-i-cannot-compile/67240>\
**Category:** Using Swift\
**Tags:** swift-syntax, swift-package, swift59\
**Created:** [September 12, 2023, 10:54am UTC](https://forums.swift.org/t/trying-to-write-a-macro-but-i-cannot-compile/67240 "2023-09-12T10:54:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukzett](https://avatars.discourse-cdn.com/v4/letter/l/b5e925/32.png) [@lukzett](https://forums.swift.org/u/lukzett)\
**Post date:** [September 12, 2023, 10:54am UTC](https://forums.swift.org/t/trying-to-write-a-macro-but-i-cannot-compile/67240/1 "2023-09-12T10:54:13Z")

</div>

Hello, I wanted to write my own Swift macro but I am stuck.

have installed the swift 5-9 dev toolchain. I verify it like this:

```swift
 % swift --version
Apple Swift version 5.9-dev (LLVM 299c632af12fe28, Swift f42cd3b53880c62)
Target: arm64-apple-macosx13.0

```

I created a new project as suggested here like this:

```swift
swift package init --type macro

```

This gave me this structure:

```swift
% tree                     
.
├── Package.swift
├── Sources
│ ├── terminal
│ │ └── terminal.swift
│ ├── terminalClient
│ │ └── main.swift
│ └── terminalMacros
│ └── terminalMacro.swift
└── Tests
    └── terminalTests
        └── terminalTests.swift

```

But when I run `swift build` I get:

```swift
 % swift build
Updating https://github.com/apple/swift-syntax.git
Updated https://github.com/apple/swift-syntax.git (0.55s)
Computing version for https://github.com/apple/swift-syntax.git
error: Dependencies could not be resolved because no versions of 'swift-syntax' match the requirement 509.0.0..<510.0.0 and root depends on 'swift-syntax' 509.0.0..<510.0.0.

```

Sometimes I also get this (when VSCode detects a change):

```swift
Executing task: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift package resolve 

error: 'terminal': package 'terminal' is using Swift tools version 5.9.0 but the installed version is 5.8.1

 * The terminal process "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift 'package', 'resolve'" terminated with exit code: 1. 
 * Terminal will be reused by tasks, press any key to close it. 

```

It seems to use the wrong toolchain.. but how do I configure the right one? I thought `swift --version` is telling me it's correct?
