lukepistrol / SFSymbolsMacro

A Swift Macro for "type-safe" SF Symbols.
MIT License
184 stars 1 forks source link

Cannot use latest version of SwiftLint with SFSymbolsMacro due to conflicting swift syntax versions #4

Open BrentMifsud opened 3 months ago

BrentMifsud commented 3 months ago
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'sfsymbolsmacro' 0.5.2..<1.0.0 and root depends on 'swiftlint' 0.55.1..<1.0.0.
'swiftlint' is incompatible with 'sfsymbolsmacro' because 'sfsymbolsmacro' 0.5.2 depends on 'swift-syntax' 509.1.1..<510.0.0 and no versions of 'sfsymbolsmacro' match the requirement 0.5.3..<1.0.0.
'swiftlint' >= 0.55.1 practically depends on 'swift-syntax' 510.0.2..<511.0.0 because 'swiftlint' 0.55.1 depends on 'swift-syntax' 510.0.2..<511.0.0 and no versions of 'swiftlint' match the requirement 0.55.2..<1.0.0.
hi2gage commented 1 month ago

Hey @BrentMifsud can you share how to reproduce this? could you provide a repo with a Package.swift or .xcodeproj that I could look at?

BrentMifsud commented 1 month ago

Its fairly easy to repro:

  1. make a new Xcode project
  2. add SwiftLint as a dependency
  3. add SFSymbolsMacro as a dependency
  4. Xcode will give you a package resolution error

you can do step 2 and 3 in the opposite order as well to reproduce the problem. Essentially SwiftLint and SFSymbolsMacro both depend on SwiftSyntax, but are likely pinned to different versions.

here's a project with the repro:

SwiftSyntaxConflict.zip

hi2gage commented 1 month ago

The provided project does not include the dependencies that you are using.

But I was able to reproduce by directly depending on the SwiftLint repository which is not recommended See README.md

[!NOTE] Consuming the plugins directly from the SwiftLint repository comes with several drawbacks. To avoid them and reduce the overhead imposed, it's highly recommended to consume the plugins from the dedicated SwiftLintPlugins repository, even though plugins from the SwiftLint repository are also absolutely functional. If the plugins from SwiftLint are preferred, just use the URL https://github.com/realm/SwiftLint in the package declarations above.

However, SwiftLintPlugins facilitates plugin adoption massively. It lists some of the reasons that drive the plugins as provided by SwiftLint itself very troublesome. Since the plugin code and the releases are kept in sync, there is no difference in functionality between the two, but you spare yourself a lot of time and trouble using the dedicated plugins repository.

This document assumes you're relying on SwiftLintPlugins.

are you using https://github.com/SimplyDanny/SwiftLintPlugins or https://github.com/realm/SwiftLint for your project?

Switching to SwiftLintPlugins everything should work since it's precompiled and does not require a dependency on swift-syntax

Screenshot 2024-08-08 at 8 35 03 PM

Once 600.0.0 is out of prerelease I can update our dependency to match SwiftLint

Let me know if you have any other questions!

BrentMifsud commented 1 month ago

Thanks for the heads up. I didn't realize they had a separate plugin package.