PureSwift / Socket

Swift async/await based socket
MIT License
116 stars 7 forks source link

`swift-system` dependency version should be a version number instead of a branch #7

Open DMAPro opened 1 year ago

DMAPro commented 1 year ago

Hello,

The swift-system dependency is currently specified as

        .package(
            url: "https://github.com/PureSwift/swift-system",
            branch: "feature/dynamic-lib"
        )

So, a branch is specified instead of a version number. This causes an issue when linking the Socket library to a package. E.g. if I'm making a package and I add a dependency like this:

.package(url: "git@github.com:PureSwift/Socket.git", from: "0.3.2")

I get an error, because SPM doesn't allow mixing and matching a stable version of the Socket package with an "unstable" version of the swift-system dependency:

Failed to resolve dependencies Dependencies could not be resolved because root depends on 'socket' 0.3.2..<1.0.0.
'socket' >= 0.3.2 cannot be used because no versions of 'socket' match the requirement 0.3.3..<1.0.0 and package 'socket' is required using a stable-version but 'socket' depends on an unstable-version package 'swift-system'.

A workaround is to use an "unstable" version for both (or rather a version that SPM deems unstable). For example, I'm linking a specific commit (for version 0.3.2):

.package(url: "git@github.com:PureSwift/Socket.git", revision: "489e63b")

However, as you can imagine, it's not super convenient :)

If you could fix the dependency declaration for the swift-system package, it would be much appreciated!

In any case, thank you for your work! :)

stackotter commented 4 months ago

+1 to this! I've got a fork which fixes this issue but it'd be good to be able to merge this in to the source repo so that development doesn't get split.

Is there a reason that you'd like swift-system to be able to be compiled as a separate dynamic library instead of directly into the Socket library? I assume it's probably code size, but a debug build of Socket (as a dylib) is 1.6mb and a release build is 889kb, so you wouldn't be saving much by ensuring that the same copy of swift-system is used everywhere.

@colemancda I'd love to hear your opinion on how this issue should be approached!

Tl;dr

SwiftPM considers Socket unstable because it depends on your swift-system fork via a branch dependency, which in turn makes it impossible to use Socket without making your own package unstable afaict (and definitely not in a way that has the benefits of semver).