I wanted to use the levels of swift-log in my LogModel. But for this Logger.Level must conform to Codable and so I opened the Pull Request which got merged. However, no version swift-log@1.1.2 was created for this (which I totally understand), so the dependency conflict described above has now occurred.
Now the swift package update leads to the following error:
Updating https://github.com/PDF-Archiver/LogModel.git
Updating https://github.com/apple/swift-log.git
error: the package dependency graph could not be resolved; possibly because of these requirements: https://github.com/apple/swift-log.git @ 1.0.0..<2.0.0
Question
I can understand that this configuration leads to a conflict. However, I want to ask if there is a solution. For example the forcing a specific dependency (here: "swift-log@master"). Because I think that this is a quite common scenario in the „OpenSource World“ and I could not find a solution for it.
In theory, this should already work since branch-based dependencies override version-based dependencies but the current resolver has a bunch of bugs. SwiftPM recently switched to a new resolver which behaves correctly in this example. For now, you should be able to work around the resolver bug by also adding .package(url: "https://github.com/apple/swift-log.git", .branch("master")) in your top-level package.
thank you so much for your super quick response! I added the Vapor dependency to be as close as possible to my "real world" example und added .package(url: "https://github.com/apple/swift-log.git", .branch("master")) in my top-level package:
I got the same error and an additional warning (which I do not understand, since Logging is a dependency of "App"):
$ swift package show-dependencies
error: multiple products named 'Logging' in: Console, swift-log
error: multiple targets named 'Logging' in: Console, swift-log
warning: dependency 'swift-log' is not used by any target
And just in case ....
$ swift --version
Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Target: x86_64-apple-darwin19.0.0
$ swift package tools-version
5.1.0
That error looks like you're running into Logging module name clash in Vapor 3. Unfortunately (for now at least) Vapor 3 isn't compatible with swift-log.
@Joe_Smith thank you. You are right! So lets decuple the vapor question from the initial question.
I created a TestLib with swift-log@1.0.0... and added .package(url: "https://github.com/apple/swift-log.git", .branch("master")) in my top-level package as @Aciid suggested:
Now I got this error (independent of swift-log in the top-level package):
$ swift package update
Updating https://github.com/JulianKahnert/TestLib.git
Updating https://github.com/PDF-Archiver/LogModel.git
Updating https://github.com/apple/swift-log.git
error: the package dependency graph could not be resolved; possibly because of these requirements: https://github.com/JulianKahnert/TestLib.git @ master
What happens if you remove that dependency (which depends on swift-log at master )?
You could also try running swift package --enable-pubgrub-resolver update which uses a new dependency-resolution algorithm and has helped me understand conflicts thanks to its helpful error messages too.