diff --git a/Sources/Mock.swift b/Sources/Mock.swift index a3bd6bd..645ec60 100644 --- a/Sources/Mock.swift +++ b/Sources/Mock.swift @@ -10,6 +10,9 @@ import Foundation import XCTest +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif /// A Mock which can be used for mocking data requests with the `Mocker` by calling `Mocker.register(...)`. public struct Mock: Equatable { diff --git a/Sources/Mocker.swift b/Sources/Mocker.swift index 91d2f64..e1d2bb1 100644 --- a/Sources/Mocker.swift +++ b/Sources/Mocker.swift @@ -7,6 +7,9 @@ // import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif /// Can be used for registering Mocked data, returned by the `MockingURLProtocol`. public struct Mocker { @@ -73,7 +76,7 @@ public struct Mocker { private init() { // Whenever someone is requesting the Mocker, we want the URL protocol to be activated. - URLProtocol.registerClass(MockingURLProtocol.self) + _ = URLProtocol.registerClass(MockingURLProtocol.self) } /// Register new Mocked data. If a mock for the same URL and HTTPMethod exists, it will be overwritten. diff --git a/Sources/MockingURLProtocol.swift b/Sources/MockingURLProtocol.swift index bb95857..7692ef1 100644 --- a/Sources/MockingURLProtocol.swift +++ b/Sources/MockingURLProtocol.swift @@ -7,6 +7,9 @@ // import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif /// The protocol which can be used to send Mocked data back. Use the `Mocker` to register `Mock` data open class MockingURLProtocol: URLProtocol {