Handling multiple versions of a package: Resolving Dependency Conflicts


I’m currently using SwiftLint plugin and trying to using SwiftTest in my project. Both of these dependencies rely on SwiftSyntax, but they require different versions of it.

So, I encountered the following error:

Failed to resolve dependencies Dependencies could not be resolved because 'swift-testing' depends on 'swift-syntax' 600.0.0-latest..<601.0.0 and root depends on 'swiftlint' 0.55.1..<1.0.0.
'swiftlint' >= 0.55.1 practically depends on 'swift-syntax' 510.0.2..<511.0.0 because no versions of 'swiftlint' match the requirement 0.55.2..<1.0.0 and 'swiftlint' 0.55.1 depends on 'swift-syntax' 510.0.2..<511.0.0.

Yes, this issue could be resolved once SwiftLint is updated.
However, I'm wondering is there any way to use multiple packages that depend different versions of the same package.

Is there a workaround for this problem?

1 Like

I cannot answer your question generally with a high certainty, but I think that there’s currently no way to deal with multiple versions of the same dependency in Swift packages.

However, I can help you with your concrete problem
by pointing you to this separate repository, that only contains the SwiftLint plugins. This has many advantages (which are listed in its README) among resolving your dependency issue.

This new repository stays in sync with any changes happening on the plugin code in the main repository and there will be a new release whenever there is one for SwiftLint.