Skip to content

Commit 625914e

Browse files
committed
Fix Linux compatibility
1 parent 1b446f5 commit 625914e

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

native/swift/Sources/wordpress-api/Protocols/CallbackAwarePerformer.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ extension CallbackAwarePerformer {
108108
return
109109
}
110110

111-
guard let httpResponse = response as? HTTPURLResponse, let data else {
111+
guard let response, let data else {
112112
completion(.failure(WordPressAPI.Errors.unableToParseResponse))
113113
return
114114
}
115115

116116
do {
117-
let rawResponse = try WpNetworkResponse.from(data: data, response: httpResponse)
117+
let rawResponse = try WpNetworkResponse.from(data: data, response: response)
118118
let parsedResponse = try responseConverter(rawResponse)
119119
completion(.success(parsedResponse))
120120
} catch {
@@ -135,5 +135,4 @@ extension CallbackAwarePerformer where Self: NoDeletionParams {
135135
try parseDeleteResponse(response: $0)
136136
}, completion: callback)
137137
}
138-
139138
}

native/swift/Sources/wordpress-api/Protocols/Conformances/Media.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Foundation
22
@preconcurrency import WordPressAPIInternal
3-
import Combine
3+
4+
#if os(Linux)
5+
import FoundationNetworking
6+
#endif
47

58
public final class MediaRequestPerformer {
69
typealias ExecutorType = MediaRequestExecutor
@@ -19,9 +22,12 @@ public final class MediaRequestPerformer {
1922
public struct MediaCreateParams {}
2023
public struct MediaRequestCreateResponse {}
2124

22-
extension MediaRequestPerformer: PublisherAwarePerformer {}
2325
extension MediaRequestPerformer: CallbackAwarePerformer {}
2426

27+
#if canImport(Combine)
28+
extension MediaRequestPerformer: PublisherAwarePerformer {}
29+
#endif
30+
2531
extension MediaRequestPerformer: RequestPerformer {
2632
public func buildListWithEditRequest(params: MediaListParams) -> WpNetworkRequest {
2733
builder.listWithEditContext(params: params)

native/swift/Sources/wordpress-api/Protocols/Conformances/PostType.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import Foundation
44
@preconcurrency import WordPressAPIInternal
55
#endif
66

7+
#if os(Linux)
8+
import FoundationNetworking
9+
#endif
10+
711
public final class PostTypeRequestPerformer {
812
typealias ExecutorType = PostTypesRequestExecutor
913
typealias RequestBuilderType = PostTypesRequestBuilder

native/swift/Sources/wordpress-api/Protocols/Conformances/Posts.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import Foundation
44
@preconcurrency import WordPressAPIInternal
55
#endif
66

7+
#if os(Linux)
8+
import FoundationNetworking
9+
#endif
10+
711
public final class PostsRequestPerformer {
812
typealias ExecutorType = PostsRequestExecutor
913
typealias RequestBuilderType = PostsRequestBuilder
@@ -98,7 +102,6 @@ extension PostsRequestPerformer: PaginationAwarePerformer {}
98102
extension PostsRequestPerformer: SequenceAwarePerformer {}
99103

100104
#if canImport(Combine)
101-
import Combine
102105
extension PostsRequestPerformer: PublisherAwarePerformer {}
103106
#endif
104107

native/swift/Sources/wordpress-api/Protocols/Conformances/Users.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import Foundation
44
@preconcurrency import WordPressAPIInternal
55
#endif
66

7+
#if os(Linux)
8+
import FoundationNetworking
9+
#endif
10+
711
public final class UsersRequestPerformer {
812
typealias ExecutorType = UsersRequestExecutor
913
typealias RequestBuilderType = UsersRequestBuilder
@@ -24,7 +28,6 @@ extension UsersRequestPerformer: PaginationAwarePerformer {}
2428
extension UsersRequestPerformer: SequenceAwarePerformer {}
2529

2630
#if canImport(Combine)
27-
import Combine
2831
extension UsersRequestPerformer: PublisherAwarePerformer {}
2932
#endif
3033

native/swift/Sources/wordpress-api/Protocols/RequestPerformer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Foundation
22

3+
#if os(Linux)
4+
import FoundationNetworking
5+
#endif
6+
37
public protocol RequestPerformer: Sendable {
48
associatedtype IdType
59

0 commit comments

Comments
 (0)