pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.72k stars 565 forks source link

How to avoid SwiftSyntax annoyance? #793

Closed groue closed 10 months ago

groue commented 10 months ago

Hello,

I'm a happy user of Swift Snapshot Testing, and this afternoon I met my first SPM problem due to a conflicting dependency on http://github.com/apple/swift-syntax from another package.

SPM error >Failed to resolve dependencies Dependencies could not be resolved because 'XXX' depends on 'swift-openapi-generator' 0.3.0..<0.4.0 and 'XXX' depends on 'swift-snapshot-testing' 1.14.1..<2.0.0. > 'swift-snapshot-testing' is incompatible with 'swift-openapi-generator' because 'swift-openapi-generator' 0.3.0 depends on 'swift-syntax' 508.0.1..<509.0.0 and no versions of 'swift-openapi-generator' match the requirement 0.3.1..<0.4.0. > 'swift-snapshot-testing' >= 1.14.1 practically depends on 'swift-syntax' 509.0.0..<510.0.0 because 'swift-snapshot-testing' 1.14.1 depends on 'swift-syntax' 509.0.0..<510.0.0 and no versions of 'swift-snapshot-testing' match the requirement 1.14.2..<2.0.0.

SwiftSyntax is well-known for not following semver, and just create churn in the package ecosystem. Stephen Celis has started the forum thread Macro Adoption Concerns around SwiftSyntax, so I know you're well aware of the problem.

Yes, the landscape may improve over time. For example, maybe SPM will learn to better deal with packages that only depend on swift-syntax for their own tests.

Meanwhile, the dependency of swift-snapshot-testing on swift-syntax is just a ticking bomb waiting to annoy your users when they least expect it.

I'm opening a symmetric issue in the other repository: https://github.com/apple/swift-openapi-generator/issues/329.

mbrandonw commented 10 months ago

Hi @groue, so the issue in a nutshell is that SnapshotTesting depends on v509 of SwiftSyntax and OpenAPIGenerator depends on v508, making it impossible to depend on both. This is definitely the problem we had in mind when we created that forum post, and when Swift 5.10 is released things are going to get even hairier. But there are a few things that have happened since then that make the situation a little better.

So, a few things come to mind:

In conclusion, barring any fundamental changes from Apple regarding SwiftSyntax, I do think it is going to take significant work for library authors to support multiple SwiftSyntax versions and keep the ecosystem healthy. Only the most dedicated maintainers will do this work, and it's not easy.

mbrandonw commented 10 months ago

Also this isn't really an issue with the library, per se, so I am going to move this to a discussion.