AliSoftware / AliSoftware/OHHTTPStubs

Error: product 'OHHTTPStubsSwift' required by package not found. Did you mean 'OHHTTPStubsSwift'?

Aberta
#369 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Objective-C
Estrelas
5.1k
Forks
597
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

### New Issue Checklist

- [x] I have tried with the latest version of OHHTTPStubs
- [x] I have read the [README](https://github.com/AliSoftware/OHHTTPStubs/blob/master/README.md)
- [x] I have read the [Using the right Swift Version of `OHHTTPStubs` for your project](https://github.com/AliSoftware/OHHTTPStubs#using-the-right-swift-version-of-ohhttpstubs-for-your-project) section
- [x] I have searched in the [existing issues](https://github.com/AliSoftware/OHHTTPStubs/issues?utf8=✓&q=is%3Aissue)
- [x] I have read [the OHHTTPStubs wiki](https://github.com/AliSoftware/OHHTTPStubs/wiki) to see if there wasn't a detailed page talking about my issue

### Environment

- version of OHHTTPStubs: 9.1.0
- integration method you are using:
* [ ] Cocoapods
* [ ] Carthage
* [ ] submodule
* [x] other
- version of the tool you use: Swift Package Manager: 5.9

### Issue Description

Hi, I am trying to use OHHHTTPStubs in my tests, but they are failing.

Since I am using the Swift Package Manager, I've added OHHTTPStubs as a dependency:

```swift
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "Sdk",
platforms: [.macOS(.v14), .iOS(.v15)],
products: [
.library(
name: "Sdk",
targets: ["Sdk"]),
.executable(
name: "Example",
targets: ["SdkExample"]
),
],
dependencies: [
.package(
url: "https://github.com/AliSoftware/OHHTTPStubs.git", from: "9.0.0"
)
],
targets: [
.target(
name: "Sdk", dependencies: ["Org", "Api"]),
.executableTarget(
name: "SdkExample", dependencies: ["Sdk"]
),
.testTarget(
name: "SdkTests",
dependencies: ["Sdk", "OHHTTPStubs", "OHHTTPStubsSwift"]),
.target(name: "Org", dependencies: ["SdkInternal", "Shared"]),
.target(name: "Api", dependencies: ["SdkInternal", "Shared"]),
.target(name: "Shared", dependencies: ["SdkInternal"]),
.target(name: "SdkInternal", dependencies: []),
]
)
```

Then I created a very basic test:

```swift
import Foundation
import OHHTTPStubs
import XCTest

@testable import Sdk
@testable import Shared

final class SdkTests: XCTestCase {
func testExample() async throws {
stub(condition: isHost("my-api.com")) { _ in
let stubData = """
{
"id": 1,
}
""".data(using: .utf8)!
return OHHTTPStubsResponse(statusCode: 200)
}

let sdk = Sdk(baseUrl: "http://my-api.com")

var params = SdkRequestParams()
params.headers["Authorization"] = "Bearer token"

let getByIdResult = try await sdk.org.getById(id: "1", params: params)
XCTAssertEqual(getByIdResult.metadata.statusCode, 200)
}
}
```

However, when I try to run it, I get this error:

```
error: 'sdk': product 'OHHTTPStubsSwift' required by package 'sdk' target 'SdkTests' not found. Did you mean 'OHHTTPStubsSwift'?
```

If I remove the `import OHHTTPStubsSwift`, I get these errors:

```
error: cannot find 'stub' in scope
stub(condition: isHost("my-api.com")) { _ in
^~~~
error: cannot find 'isHost' in scope
stub(condition: isHost("my-api.com")) { _ in
^~~~~~
error: cannot find 'OHHTTPStubsResponse' in scope
return OHHTTPStubsResponse(statusCode: 200)
^~~~~~~~~~~~~~~~~~~
error: fatalError

error: fatalError
```

I am new to Swift. Could you help me?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.