Skip to content

Commit 82e27a8

Browse files
committed
Bump tools version to 5.6, add dependency to make testing possible again
1 parent bd54d85 commit 82e27a8

7 files changed

Lines changed: 139 additions & 90 deletions

File tree

CombineCoreBluetooth.xcodeproj/project.pbxproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
00371A0227EE588C00C2F766 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 00371A0127EE588C00C2F766 /* Preview Assets.xcassets */; };
1616
00371A2327F02B1900C2F766 /* CentralView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00371A2227F02B1900C2F766 /* CentralView.swift */; };
1717
00482BE828308A4D0053B7C1 /* PeripheralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00482BE728308A4D0053B7C1 /* PeripheralTests.swift */; };
18+
006CA40A2ACB7D2300DDA85D /* ConcurrencyExtras in Frameworks */ = {isa = PBXBuildFile; productRef = 006CA4092ACB7D2300DDA85D /* ConcurrencyExtras */; };
1819
00CF0B78288DD73700FD88E1 /* PeripheralError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00CF0B77288DD73700FD88E1 /* PeripheralError.swift */; };
1920
00D8C7432A69A6E20069EC00 /* PeripheralManagerError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00D8C7422A69A6E20069EC00 /* PeripheralManagerError.swift */; };
2021
EB443FB927C6BDE10005CCEA /* Exports.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB443F9C27C6BDE00005CCEA /* Exports.swift */; };
@@ -116,6 +117,7 @@
116117
buildActionMask = 2147483647;
117118
files = (
118119
EB443FDD27C6C1940005CCEA /* CombineCoreBluetooth.framework in Frameworks */,
120+
006CA40A2ACB7D2300DDA85D /* ConcurrencyExtras in Frameworks */,
119121
);
120122
runOnlyForDeploymentPostprocessing = 0;
121123
};
@@ -346,6 +348,9 @@
346348
EB443FDF27C6C1940005CCEA /* PBXTargetDependency */,
347349
);
348350
name = "CombineCoreBluetooth Tests";
351+
packageProductDependencies = (
352+
006CA4092ACB7D2300DDA85D /* ConcurrencyExtras */,
353+
);
349354
productName = "CombineCoreBluetooth-iOSTests";
350355
productReference = EB443FD927C6C1940005CCEA /* CombineCoreBluetooth Tests.xctest */;
351356
productType = "com.apple.product-type.bundle.unit-test";
@@ -380,6 +385,9 @@
380385
Base,
381386
);
382387
mainGroup = EB443F8427C6BCA70005CCEA;
388+
packageReferences = (
389+
006CA4082ACB7D2300DDA85D /* XCRemoteSwiftPackageReference "swift-concurrency-extras" */,
390+
);
383391
productRefGroup = EB443F8F27C6BCA70005CCEA /* Products */;
384392
projectDirPath = "";
385393
projectRoot = "";
@@ -829,11 +837,28 @@
829837
};
830838
/* End XCConfigurationList section */
831839

840+
/* Begin XCRemoteSwiftPackageReference section */
841+
006CA4082ACB7D2300DDA85D /* XCRemoteSwiftPackageReference "swift-concurrency-extras" */ = {
842+
isa = XCRemoteSwiftPackageReference;
843+
repositoryURL = "https://github.com/pointfreeco/swift-concurrency-extras.git";
844+
requirement = {
845+
kind = versionRange;
846+
maximumVersion = 2.0.0;
847+
minimumVersion = 0.1.0;
848+
};
849+
};
850+
/* End XCRemoteSwiftPackageReference section */
851+
832852
/* Begin XCSwiftPackageProductDependency section */
833853
0014FFB127F0359600D2A122 /* CombineCoreBluetooth */ = {
834854
isa = XCSwiftPackageProductDependency;
835855
productName = CombineCoreBluetooth;
836856
};
857+
006CA4092ACB7D2300DDA85D /* ConcurrencyExtras */ = {
858+
isa = XCSwiftPackageProductDependency;
859+
package = 006CA4082ACB7D2300DDA85D /* XCRemoteSwiftPackageReference "swift-concurrency-extras" */;
860+
productName = ConcurrencyExtras;
861+
};
837862
/* End XCSwiftPackageProductDependency section */
838863
};
839864
rootObject = EB443F8527C6BCA70005CCEA /* Project object */;

CombineCoreBluetooth.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.resolved

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// swift-tools-version:5.8
1+
// swift-tools-version:5.6
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

6-
#if swift(>=5.6)
7-
let dependencies: [Package.Dependency] = [
8-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
9-
]
10-
#else
11-
let dependencies: [Package.Dependency] = []
12-
#endif
13-
146
let package = Package(
157
name: "CombineCoreBluetooth",
168
platforms: [
@@ -25,18 +17,24 @@ let package = Package(
2517
targets: ["CombineCoreBluetooth"]
2618
),
2719
],
28-
dependencies: dependencies,
20+
dependencies: [
21+
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", "0.1.0"..<"2.0.0"),
22+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
23+
],
2924
targets: [
3025
.target(
3126
name: "CombineCoreBluetooth",
32-
dependencies: [],
27+
dependencies: [
28+
],
3329
swiftSettings: [
34-
.enableExperimentalFeature("StrictConcurrency")
3530
]
3631
),
3732
.testTarget(
3833
name: "CombineCoreBluetoothTests",
39-
dependencies: ["CombineCoreBluetooth"]
34+
dependencies: [
35+
"CombineCoreBluetooth",
36+
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
37+
]
4038
),
4139
]
4240
)

Tests/CombineCoreBluetoothTests/CentralManagerTests.swift

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import XCTest
22
@testable import CombineCoreBluetooth
3+
import ConcurrencyExtras
34

45
final class CentralManagerTests: XCTestCase {
56
var cancellables: Set<AnyCancellable>!
@@ -64,41 +65,47 @@ final class CentralManagerTests: XCTestCase {
6465
}
6566

6667
func testScanForPeripheralsScansOnlyOnSubscription() {
67-
var scanCount = 0
68-
var stopCount = 0
68+
let scanCount = LockIsolated(0)
69+
let stopCount = LockIsolated(0)
6970
let peripheralDiscovery = PassthroughSubject<PeripheralDiscovery, Never>()
70-
let centralManager = CentralManager.unimplemented(scanForPeripheralsWithServices: { _, _ in
71-
scanCount += 1
72-
}, stopScanForPeripherals: {
73-
stopCount += 1
74-
}, didDiscoverPeripheral: peripheralDiscovery.eraseToAnyPublisher()
71+
let centralManager = CentralManager.unimplemented(
72+
scanForPeripheralsWithServices: { _, _ in
73+
scanCount.withValue { $0 += 1 }
74+
},
75+
stopScanForPeripherals: {
76+
stopCount.withValue { $0 += 1}
77+
},
78+
didDiscoverPeripheral: peripheralDiscovery.eraseToAnyPublisher()
7579
)
7680

7781
let p = centralManager.scanForPeripherals(withServices: nil)
78-
XCTAssertEqual(scanCount, 0)
82+
scanCount.withValue { XCTAssertEqual($0, 0) }
7983
let _ = p.sink(receiveValue: { _ in })
80-
XCTAssertEqual(scanCount, 1)
84+
scanCount.withValue { XCTAssertEqual($0, 1) }
8185
}
8286

8387
func testScanForPeripheralsStopsOnCancellation() {
84-
var scanCount = 0
85-
var stopCount = 0
88+
let scanCount = LockIsolated(0)
89+
let stopCount = LockIsolated(0)
8690
let peripheralDiscovery = PassthroughSubject<PeripheralDiscovery, Never>()
87-
let centralManager = CentralManager.unimplemented(scanForPeripheralsWithServices: { _, _ in
88-
scanCount += 1
89-
}, stopScanForPeripherals: {
90-
stopCount += 1
91-
}, didDiscoverPeripheral: peripheralDiscovery.eraseToAnyPublisher()
91+
let centralManager = CentralManager.unimplemented(
92+
scanForPeripheralsWithServices: { _, _ in
93+
scanCount.withValue { $0 += 1 }
94+
},
95+
stopScanForPeripherals: {
96+
stopCount.withValue { $0 += 1}
97+
},
98+
didDiscoverPeripheral: peripheralDiscovery.eraseToAnyPublisher()
9299
)
93100

94101
let p = centralManager.scanForPeripherals(withServices: nil)
95-
XCTAssertEqual(scanCount, 0)
102+
scanCount.withValue { XCTAssertEqual($0, 0) }
96103
let cancellable = p.sink(receiveValue: { _ in })
97-
XCTAssertEqual(scanCount, 1)
98-
XCTAssertEqual(stopCount, 0)
104+
scanCount.withValue { XCTAssertEqual($0, 1) }
105+
stopCount.withValue { XCTAssertEqual($0, 0) }
99106

100107
cancellable.cancel()
101-
XCTAssertEqual(scanCount, 1)
102-
XCTAssertEqual(stopCount, 1)
108+
scanCount.withValue { XCTAssertEqual($0, 1) }
109+
stopCount.withValue { XCTAssertEqual($0, 1) }
103110
}
104111
}

Tests/CombineCoreBluetoothTests/PeripheralManagerTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import XCTest
22
@testable import CombineCoreBluetooth
3+
import ConcurrencyExtras
34

45
#if !os(watchOS) && !os(tvOS)
56
final class PeripheralManagerTests: XCTestCase {
@@ -65,9 +66,11 @@ final class PeripheralManagerTests: XCTestCase {
6566
let characteristic = CBMutableCharacteristic(type: .init(string: "0001"), properties: [.notify], value: nil, permissions: [.readable])
6667
let central = Central.unimplemented(identifier: .init(), maximumUpdateValueLength: { 512 })
6768
let readyToUpdateSubject = PassthroughSubject<Void, Never>()
68-
var shouldSucceed = false
69+
let shouldSucceed = LockIsolated(false)
6970
let peripheralManager = PeripheralManager.unimplemented(
70-
updateValueForCharacteristic: { _, _, _ in shouldSucceed },
71+
updateValueForCharacteristic: { _, _, _ in
72+
shouldSucceed.withValue { $0 }
73+
},
7174
readyToUpdateSubscribers: readyToUpdateSubject.eraseToAnyPublisher()
7275
)
7376

@@ -86,7 +89,7 @@ final class PeripheralManagerTests: XCTestCase {
8689
for _ in 1...3 {
8790
readyToUpdateSubject.send(())
8891
}
89-
shouldSucceed = true
92+
shouldSucceed.setValue(true)
9093
readyToUpdateSubject.send(())
9194
XCTAssert(complete)
9295
}

0 commit comments

Comments
 (0)