erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 607 forks source link

Please drop "v" prefix for tagged versions for a better experience with Swift Package Manager #496

Closed macblazer closed 3 years ago

macblazer commented 3 years ago

There is now some potential support in master for pulling in OCMock via the Swift Package Manager. However, the version tags used by OCMock that are prefixed with a v such as the most recent v3.8.1 do not work with SPM's current versioning engine.

Request

Drop the v from the release tags in the next and all future versions of OCMock so that it can fully work with CocoaPods, Carthage, and Swift Package Manager. Future version numbers will look like 3.8.2, 3.9.0, etc.

Reasoning

Attempting to pull in OCMock via SPM within Xcode results in an error stating that "https://github.com/erikdoe/ocmock.git has no Package.swift manifest for version 3.8.1" (screenshot below). This indicates that Xcode is pulling the v off the front of the tags which is semi-helpful, but it still does not allow the package to be used.

OCMockSPMFail

When attempting to pull in OCMock via SPM within a Package.swift file, the output of swift test is:

SamplePackage: error: manifest parse error(s): Invalid semantic version string 'v3.8.1'

Here is the Package.swift file:

// swift-tools-version:5.3
import PackageDescription

let package = Package(
    name: "Sample",
    products: [
        .library(name: "Sample",
                 targets: ["Sample"])
    ],
    dependencies: [
        .package(
            name: "OCMock",
            url: "https://github.com/erikdoe/ocmock.git",
            from: "v3.8.1"
            // .branch("master") // this works, but not versioned
            // .revision("adc9fcec2bf690116dce1e4d8c8c35c8b0adb2ee") // this works, but never updates
        )
    ],
    targets: [
        .target(name: "Sample",
            dependencies: ["Sample"]),
        .testTarget(name: "Sample",
            dependencies: ["Sample", "OCMock"])
    ]
)

Output of swift --version:

Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28) Target: x86_64-apple-darwin19.6.0

Output of xcodebuild -version:

Xcode 12.4 Build version 12D4e

Workaround

Specifying a branch or revision of the OCMock repository as a SPM dependency does work.

Using the branch specification will always pull the head of the branch which will pull in breaking changes on major version updates. Using the revision specification pulls in that one specific revision and needs to be manually updated to a new revision on a regular basis.

erikdoe commented 3 years ago

Sorry for the long delay but to get this done I had to learn more about Swift Package Manager, XCFrameworks, and a bunch of other stuff, all of which I wasn't really looking forward to.

That said, I have now pushed the first release that does support Swift Package Manager. It still has a v in it's tag but that should be okay. I suspect you saw the issue because no tagged version of OCMock had a Package.swift file. Please try and let me know whether it works now.

erikdoe commented 3 years ago

In the meantime I've tried this, and I can confirm that Swift Package Manager can find OCMock by version, even when the version is tagged with a v. So, I'm going to close this issue.

Unfortunately, there is another issue left, which I will comment on in #500.