This question has been asked before but I wasn't able to find a satisfactory solution yet, so I'm reposting to raise awareness.The problem is somewhat straightforward: Swift Syntax depends on a dynamic library
_InternalSwiftSyntaxParser which is bundled with the toolchain.
Now, the first problem is that the
libSyntax looks for
_InternalSwiftSyntaxParser in the wrong place, multiple places in fact, none of them being the Xcode toolchain. You can overcome this by packaging
_InternalSwiftSyntaxParser with your app as a binary dependency, however, that leads to another problem. If the consumer of your package has a different toolchain version installed, he'll get something like this at compile time:
The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax
Now, I'm guessing another way to partially solve this would be to modify the
@rpath and ship
libSyntax as a binary dependency, but that wouldn't help much with the second issue either, if the consumer's toolchain doesn't match
libSyntax version, it will still fail.
Is there a way to elegantly/maintainably solve this?
It's a quite unique situation I think and ideally SPM would be able to dynamically pick the right
swift-syntax version depending on the installed toolchain (and also somehow mitigate the
@rpath issue described above).