From 2f3712c830300dde975fbee256b4dca50c5273c2 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 30 Apr 2023 13:28:32 +0000 Subject: [PATCH] [Enhancement] Communications library for non Apple platforms (part II) (#16) This PR contains the work done to make the `MockURLProtocol` class from the `Communications` library available for non-Apple platforms. Co-authored-by: Javier Cicchelli Reviewed-on: https://repo.rock-n-code.com/rock-n-code/swift-libs/pulls/16 --- README.md | 4 ++-- Sources/Communications/Classes/MockURLProtocol.swift | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c348c0d..b6677e8 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ In the intended `Package.swift` file, it is required to add the following depend ```swift dependencies: [ // ... - .package(url: "https://github.com/rock-n-code/swift-libs.git", from: "0.1.5") + .package(url: "https://github.com/rock-n-code/swift-libs.git", from: "0.1.7") // ... ], ``` @@ -66,7 +66,7 @@ In an opened Xcode project, it is required to follow these steps to install the 4. press on the *+* (plus) button to add dependencies to the project; 5. enter the URL `https://github.com/rock-n-code/swift-libs.git` into the *Search or Enter Package URL* located in the upper right corner; 6. select the retrieved option; -7. define the dependency rule (the *Up to Next Major Version* option and the *0.1.5* text are recommended); +7. define the dependency rule (the *Up to Next Major Version* option and the *0.1.7* text are recommended); 8. select the target to which the dependency will be applied (if required); 9. wait for the package to be resolved and included in the project; 10. now you should be ready to start using this package! diff --git a/Sources/Communications/Classes/MockURLProtocol.swift b/Sources/Communications/Classes/MockURLProtocol.swift index f4122a6..e634324 100644 --- a/Sources/Communications/Classes/MockURLProtocol.swift +++ b/Sources/Communications/Classes/MockURLProtocol.swift @@ -10,9 +10,12 @@ // //===----------------------------------------------------------------------===// -#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + /// This class overrides the `URLProtocol` protocol used by the `URLSession` to handle the loading of protocol-specific URL data so it is possible to mock URL response for testing purposes. public class MockURLProtocol: URLProtocol { @@ -117,4 +120,3 @@ public struct MockURLResponse { } } -#endif