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 --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 package init --type macro
This gave me this structure:
% 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 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):
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?