[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 <javier@rock-n-code.com>
Reviewed-on: #16
This commit is contained in:
Javier Cicchelli 2023-04-30 13:28:32 +00:00
parent fb439a82a8
commit 2f3712c830
2 changed files with 6 additions and 4 deletions

View File

@ -37,7 +37,7 @@ In the intended `Package.swift` file, it is required to add the following depend
```swift ```swift
dependencies: [ 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; 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; 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; 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); 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; 9. wait for the package to be resolved and included in the project;
10. now you should be ready to start using this package! 10. now you should be ready to start using this package!

View File

@ -10,9 +10,12 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
import Foundation 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. /// 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 { public class MockURLProtocol: URLProtocol {
@ -117,4 +120,3 @@ public struct MockURLResponse {
} }
} }
#endif