getditto / DittoSwiftTools

Diagnostic and Debugging Tools for DittoSwift
MIT License
9 stars 2 forks source link

Accept pre-release Ditto versions #125

Closed busec0 closed 5 months ago

busec0 commented 5 months ago

Context: https://dittolive.slack.com/archives/C04E3JVJGG4/p1717834981728039

Trying to use DittoSwiftTools & a pre-release version of Ditto like 4.7.2-rc.3 will fail to resolve the package:

Screenshot 2024-06-08 at 13 02 38
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'dittoswifttools' 4.9.0.
'dittoswifttools' 4.9.0 cannot be used because 'dittoswifttools' 4.9.0 depends on 'dittoswiftpackage' 4.5.0..<5.0.0 and root depends on 'dittoswiftpackage' 4.7.2-rc.3.
bplattenburg commented 5 months ago

This seems to be an SPM issue (maybe bug) in that it won't consider things like 4.7.2-rc.3 to satisfy something like ">= 4.5.0", even though these extensions are part of the SemVer 2.0 spec that SPM references: https://dittolive.slack.com/archives/C06L4TKPC5C/p1718047990590389?thread_ts=1717849947.978169&cid=C06L4TKPC5C.

bplattenburg commented 5 months ago

I dug a bit and I think SPM should work correctly for this, will try to make a minimum reproduction case.

See Package.Version's conformance to Comparable:

extension Version : Comparable {

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`, `a ==
    /// b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    ///
    /// - Returns: A boolean value indicating the result of the equality test.
    @inlinable public static func == (lhs: PackageDescription.Version, rhs: PackageDescription.Version) -> Bool

    /// Returns a Boolean value indicating whether the value of the first
    /// argument is less than that of the second argument.
    ///
    /// The precedence is determined according to rules described in the [Semantic Versioning 2.0.0](https://semver.org) standard, paragraph 11.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func < (lhs: PackageDescription.Version, rhs: PackageDescription.Version) -> Bool
}

And: SemVer 2.0 Paragraph 11

bplattenburg commented 5 months ago

I'm able to reproduce this with any new Xcode project or SPM package.

See below for a sample Package.swift for a minimal reproduction:

// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "SPMSemVerReproPackage",
    products: [
        // Products define the executables and libraries a package produces, making them visible to other packages.
        .library(
            name: "SPMSemVerReproPackage",
            targets: ["SPMSemVerReproPackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/getditto/DittoSwiftPackage", exact: "4.7.2-rc.3"),
        .package(url: "https://github.com/getditto/DittoSwiftTools", from: "4.11.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .target(
            name: "SPMSemVerReproPackage"),
        .testTarget(
            name: "SPMSemVerReproPackageTests",
            dependencies: ["SPMSemVerReproPackage"]),
    ]
)

This gives me the following package resolution error:


Showing All Issues
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'dittoswiftpackage' 4.7.2-rc.3 and root depends on 'dittoswifttools' 4.11.0..<5.0.0.
'dittoswifttools' >= 4.11.0 practically depends on 'dittoswiftpackage' 4.5.0..<5.0.0 because no versions of 'dittoswifttools' match the requirement 4.11.1..<5.0.0 and 'dittoswifttools' 4.11.0 depends on 'dittoswiftpackage' 4.5.0..<5.0.0.

I don't know if there's much more we can really do on this unless there's an SPM feature or flag to allow prerelease extensions to satisfy constraints like from: "4.5.0" as seen in DittoSwiftTools Package.swift

busec0 commented 5 months ago

I don't know if there's much more we can really do on this unless there's an SPM feature or flag to allow prerelease extensions to satisfy constraints like from: "4.5.0" as seen in DittoSwiftTools Package.swift

Is there a way to raise an issue / bug on SPM? Can we do that? Looks like a bug to me.

bplattenburg commented 5 months ago

It appears to already be logged as a bug against SPM here: https://github.com/apple/swift-package-manager/issues/7316

bplattenburg commented 5 months ago

Closing as this is bug in Swift Package Manager (linked above)