Skip to content

Commit 5c55203

Browse files
committed
Merge development into main
2 parents 1526787 + b42cdae commit 5c55203

File tree

7 files changed

+23
-69
lines changed

7 files changed

+23
-69
lines changed

Package.swift

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import PackageDescription
88
let package = Package(
99
name: "ComposableRequest",
1010
// Supported versions.
11-
platforms: [.iOS(.v9),
12-
.macOS(.v10_10),
13-
.tvOS(.v9),
14-
.watchOS(.v2)],
11+
platforms: [.iOS("13.0"),
12+
.macOS("10.15"),
13+
.tvOS("13.0"),
14+
.watchOS("6.0")],
1515
// Exposed libraries.
1616
products: [.library(name: "Requests",
1717
targets: ["ComposableRequest"]),
@@ -20,13 +20,10 @@ let package = Package(
2020
.library(name: "StorageCrypto",
2121
targets: ["ComposableStorageCrypto"])],
2222
// Package dependencies.
23-
dependencies: [.package(url: "https://github.com/cx-org/CombineX",
24-
.upToNextMinor(from: "0.3.0")),
25-
.package(url: "https://github.com/sbertix/Swiftchain.git",
23+
dependencies: [.package(url: "https://github.com/sbertix/Swiftchain.git",
2624
.upToNextMinor(from: "1.0.0"))],
2725
// All targets.
28-
targets: [.target(name: "ComposableRequest",
29-
dependencies: [.product(name: "CXShim", package: "CombineX")]),
26+
targets: [.target(name: "ComposableRequest"),
3027
.target(name: "ComposableStorage",
3128
dependencies: []),
3229
.target(name: "ComposableStorageCrypto",
@@ -35,48 +32,7 @@ let package = Package(
3532
dependencies: ["ComposableRequest", "ComposableStorage", "ComposableStorageCrypto"])]
3633
)
3734

38-
enum CombineImplementation {
39-
/// Apple **Combine**.
40-
case combine
41-
/// **cx-org/CombineX**.
42-
case combineX
43-
44-
/// Default implementation.
45-
/// If available, Apple **Combine** is always preferred.
46-
static var `default`: CombineImplementation {
47-
#if canImport(Combine)
48-
return .combine
49-
#else
50-
return .combineX
51-
#endif
52-
}
53-
54-
/// Optional init.
55-
///
56-
/// - parameter description: A valid `String`.
57-
init?(_ description: String) {
58-
let desc = description.lowercased().filter { $0.isLetter }
59-
switch desc {
60-
case "combine": self = .combine
61-
case "combinex": self = .combineX
62-
default: return nil
63-
}
64-
}
65-
}
66-
67-
extension ProcessInfo {
68-
/// The selected combine implementation. Defaults to `.default`.
69-
var combineImplementation: CombineImplementation {
70-
return environment["CX_COMBINE_IMPLEMENTATION"].flatMap(CombineImplementation.init) ?? .default
71-
}
72-
}
73-
74-
// MARK: Adjustments
75-
7635
if ProcessInfo.processInfo.environment["TARGETING_WATCHOS"] == "true" {
7736
// #workaround(xcodebuild -version 11.6, Test targets don’t work on watchOS.) @exempt(from: unicode)
7837
package.targets.removeAll(where: { $0.isTest })
7938
}
80-
if ProcessInfo.processInfo.combineImplementation == .combine {
81-
package.platforms = [.macOS("10.15"), .iOS("13.0"), .tvOS("13.0"), .watchOS("6.0")]
82-
}

Sources/ComposableRequest/Extensions/@_exported.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
// Created by Stefano Bertagno on 10/03/21.
66
//
77

8-
@_exported import CXShim
8+
@_exported import Combine

Sources/ComposableRequest/Publishers/Pager/Pager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public extension Publishers {
6363
iteration.stream
6464
.collect()
6565
.flatMap { [count, generator] outputs -> AnyPublisher<Output, Failure> in
66-
Publishers.Sequence(sequence: outputs.map(Just.init))
67-
.flatMap(maxPublishers: .max(1)) { $0 }
66+
Publishers.Sequence(sequence: outputs.map { Just($0).setFailureType(to: Failure.self) })
67+
.flatMap(maxPublishers: Subscribers.Demand.max(1)) { $0 }
6868
.append(iteration.offset(outputs).flatMap { Pager(count-1, offset: $0, generator: generator) }?.eraseToAnyPublisher()
6969
?? Empty().eraseToAnyPublisher())
7070
.eraseToAnyPublisher()

Sources/ComposableRequest/Publishers/Publisher+Request.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public extension Request {
1919
}
2020
// Return the actual stream.
2121
let logger = input.logger ?? Logger.default
22-
return (input.session.cx as CXWrappers.URLSession)
22+
return input.session
2323
.dataTaskPublisher(for: request)
2424
.retry(max(input.retries, 0))
2525
.map(Request.Response.init)

Tests/ComposableRequestTests/ObservableTests.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by Stefano Bertagno on 06/05/2020.
66
//
77

8+
import Combine
89
import XCTest
910

1011
@testable import ComposableRequest
@@ -51,7 +52,7 @@ final class ObservableTests: XCTestCase {
5152
.compactMap { $0["string"].string() }
5253
.assertBackgroundThread()
5354
}
54-
.receive(on: RunLoop.main.cx)
55+
.receive(on: RunLoop.main)
5556
.assertMainThread()
5657
}
5758
.unlock(with: url)
@@ -74,8 +75,9 @@ final class ObservableTests: XCTestCase {
7475
func testRemoteFuture() {
7576
let expectations = ["output", "completion"].map(XCTestExpectation.init)
7677
Just(url)
78+
.setFailureType(to: Error.self)
7779
.assertMainThread()
78-
.receive(on: RunLoop.main.cx)
80+
.receive(on: RunLoop.main)
7981
.assertMainThread()
8082
.flatMap {
8183
Request($0)
@@ -85,7 +87,7 @@ final class ObservableTests: XCTestCase {
8587
.wrap()
8688
.compactMap { $0["string"].string() }
8789
}
88-
.subscribe(on: RunLoop.main.cx)
90+
.subscribe(on: RunLoop.main)
8991
.sink(
9092
receiveCompletion: {
9193
if case .failure(let error) = $0 { XCTFail(error.localizedDescription) }
@@ -119,7 +121,7 @@ final class ObservableTests: XCTestCase {
119121
}
120122
}
121123
.pages(languages.count, offset: 0)
122-
.receive(on: RunLoop.main.cx)
124+
.receive(on: RunLoop.main)
123125
.assertMainThread()
124126
.sink(
125127
receiveCompletion: {
@@ -206,7 +208,7 @@ final class ObservableTests: XCTestCase {
206208
Request(url)
207209
.publish(session: .shared)
208210
.map(\.response)
209-
.receive(on: RunLoop.main.cx)
211+
.receive(on: RunLoop.main)
210212
.sink(
211213
receiveCompletion: { _ in XCTFail("This should not complete") },
212214
receiveValue: { _ in XCTFail("This should not output") }

Tests/ComposableRequestTests/Shared/Publisher.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
// Created by Stefano Bertagno on 10/03/21.
66
//
77

8+
import Combine
89
import Foundation
910
import XCTest
1011

11-
import CXShim
12-
1312
extension Publisher {
1413
/// Assert main thread.
1514
func assertMainThread() -> Publishers.HandleEvents<Self> {

docs/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
[![Swift](https://img.shields.io/badge/Swift-5.2-%23DE5C43?style=flat&logo=swift)](https://swift.org)
66
[![codecov](https://codecov.io/gh/sbertix/ComposableRequest/branch/main/graph/badge.svg)](https://codecov.io/gh/sbertix/Swiftagram)
77
<br />
8-
![iOS](https://img.shields.io/badge/iOS-9.0-8CFF96)
9-
![macOS](https://img.shields.io/badge/macOS-10.10-8CFF96)
10-
![tvOS](https://img.shields.io/badge/tvOS-9.0-8CFF96)
11-
![watchOS](https://img.shields.io/badge/watchOS-2.0-8CFF96)
8+
![iOS](https://img.shields.io/badge/iOS-13.0-8CFF96)
9+
![macOS](https://img.shields.io/badge/macOS-10.15-8CFF96)
10+
![tvOS](https://img.shields.io/badge/tvOS-13.0-8CFF96)
11+
![watchOS](https://img.shields.io/badge/watchOS-6.0-8CFF96)
1212

1313
<br />
1414

1515
**ComposableRequest** is a networking layer based on a declarative interface, written in (modern) **Swift**.
1616

1717
It abstracts away `URLSession` implementation, in order to provide concise and powerful endpoint representations, thanks to the power of **Combine** `Publisher`s.
18-
Compatibilty for older versions of **iOS**, **macOS**, **tvOS** and **watchOS** is provided through **CombineX**'s **CXShim**, learn more [here](https://github.com/cx-org/CombineX/wiki/Combine-Compatible-Package).
1918

2019
It comes with `Storage` (inside of **ComposableStorage**), a way of caching `Storable` items, and related concrete implementations (e.g. `UserDefaultsStorage`, `KeychainStorage` – for which you're gonna need to add **ComposableStorageCrypto**, depending on [**Swiftchain**](https://github.com/sbertix/Swiftchain), together with the ability to provide the final user of your API wrapper to inject code through `Provider`s.
2120

@@ -51,9 +50,7 @@ Furthermore, with the integration of the **Swift Package Manager** in **Xcode 11
5150
<details><summary><strong>Targets</strong></summary>
5251
<p>
5352

54-
- **ComposableRequest**, an HTTP client originally integrated in **Swiftagram**, the core library.\
55-
It depends on [**CombineX**](https://github.com/cx-org/CombineX/)'s [**CXShim**](https://github.com/cx-org/CombineX/wiki/Combine-Compatible-Package) to provide **Combine** support on all platforms, reguardless of their minum deployment version.
56-
53+
- **ComposableRequest**, an HTTP client originally integrated in **Swiftagram**, the core library.
5754
- **ComposableStorage**, can be imported together with **ComposableRequest** to extend its functionality.
5855
</p>
5956
</details>

0 commit comments

Comments
 (0)