AliSoftware/OHHTTPStubs

Unable to import OHHTTPStubsSwift from swift package manager dependency

pavm035 opened this issue · 2 comments

New Issue Checklist

Environment

  • version of OHHTTPStubs: [9.0.0]
  • integration method you are using:
    • Cocoapods
    • Carthage
    • submodule
    • other
  • version of the tool you use: [Xcode12 beta3]

Issue Description

I'm trying to add OHHTTPStubs ad my pakcage dependency in my Swift package, I can import OHHTTPStubs but not OHHTTPStubsSwift into my project, i have added dependency like this
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .upToNextMajor(from: "9.0.0")),

.testTarget(
            name: "MyFrameworkTests",
            dependencies: [
                "MyFramework",
                "OHHTTPStubs",
                "OHHTTPStubsSwift" // <= Error here, i tried removing it also but it remains same
            ],
            resources: [
                .process("TestData")
            ]
        ),

NOTE: There is someone posted similar problem here https://stackoverflow.com/questions/61069763/swift-package-manifest-for-multiple-library-products

Complete output when you encounter the issue (if any)
xxxx/Package.swift: dependency 'OHHTTPStubsSwift' in target 'MyFrameworkTests' requires explicit declaration; reference the package in the target dependency with '.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")'

That error tells you how to fix this.

xxxx/Package.swift: dependency 'OHHTTPStubsSwift' in target 'MyFrameworkTests' requires explicit declaration; reference the package in the target dependency with '.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")'

In the test target dependencies use this .product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")

eseay commented

Change your .testTarget to:

.testTarget(
    name: "MyFrameworkTests",
    dependencies: [
        "MyFramework",
        .product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")
    ]
)

It also appears you can now do the following, which I have opted for:

.testTarget(
    name: "MyFrameworkTests",
    dependencies: [
        .target(name: "MyFramework"),
        .product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")
    ]
)