Skip to content

feat: Update README.md#37

Open
maximkrouk wants to merge 1 commit intostackotter:mainfrom
maximkrouk:readme-swift-syntax-override-guide
Open

feat: Update README.md#37
maximkrouk wants to merge 1 commit intostackotter:mainfrom
maximkrouk:readme-swift-syntax-override-guide

Conversation

@maximkrouk
Copy link
Copy Markdown
Contributor

Added a guide on bypassing swift-syntax version resolution

Note

Some of my dependencies prevent me from using latest version of swift-macro-toolkit, but by depending on local swift-syntax fork I managed to bypass swift-syntax version resolution. It's too small piece of knowledge to make some article about, but I think some folks may find it really helpful and swift-macro-toolkit looks like a right place to mention it.

@maximkrouk maximkrouk force-pushed the readme-swift-syntax-override-guide branch from 169d4a0 to d0c1bc5 Compare March 7, 2026 15:05
@stackotter
Copy link
Copy Markdown
Owner

Are you saying that if your app depends on a local swift-syntax checkout, SwiftPM then uses that swift-syntax checkout for swift-macro-toolkit as well?

@maximkrouk
Copy link
Copy Markdown
Contributor Author

Nope, for example:

Afair standard resolution checked out swift-macro-toolkit at 0.7.x. It couldn't use 0.8.0 because TCA (and some of it's deps) limited swift-syntax to 602

I simply cloned swift-syntax to a local directory and added a local dependency to app's Package.swift, since swift-syntax version was resolved as a local clone, it's no longer limiting swift-macro-toolkit

Sure it may not always work, but at least worked with 603 and likely to work in most cases as long as swift version matches (6xy/7xy etc)

Copy link
Copy Markdown
Owner

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this one. I've tested out your approach locally and it works great! In fact I've used it for multiple other packages during local development of packages with very nested dependencies (much easier than going and changing all the dependencies just to test a small change in a downstream package).

Just had a typo correction and some additional sentences that I think should provide useful context.

> | `0.7.0` | `601.0.0` |
> | `0.8.0` | `602.0.0` |
>
> _It is also possible to use local [`swift-syntax`](https://github.com/swiftlang/swift-syntax) overrides if some other dependency pervents you from depending on newer [`swift-macro-toolkit`](https://github.com/stackotter/swift-macro-toolkit) version and vice versa. It requires cloning [`swift-syntax`](https://github.com/swiftlang/swift-syntax) into a local directory and depending your app on the local clone. Usually [`swift-syntax`](https://github.com/swiftlang/swift-syntax) updates don't break macros_ 💁‍♂️
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: pervents (meant to be prevents I believe)

> | `0.7.0` | `601.0.0` |
> | `0.8.0` | `602.0.0` |
>
> _It is also possible to use local [`swift-syntax`](https://github.com/swiftlang/swift-syntax) overrides if some other dependency pervents you from depending on newer [`swift-macro-toolkit`](https://github.com/stackotter/swift-macro-toolkit) version and vice versa. It requires cloning [`swift-syntax`](https://github.com/swiftlang/swift-syntax) into a local directory and depending your app on the local clone. Usually [`swift-syntax`](https://github.com/swiftlang/swift-syntax) updates don't break macros_ 💁‍♂️
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... into a local directory and updating your app to depend on the local clone. This will force SwiftPM to use your local clone of swift-syntax throughout the whole package graph, allowing you to bypass conflicting version requirements. Note that this may fail if some macros depend on newer/older API variants. Usually swift-syntax...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants