Skip to content

Commit af28b32

Browse files
authored
Merge pull request #29 from NordicSemiconductor/develop
Version 0.12.0
2 parents 1562143 + c710301 commit af28b32

25 files changed

+285
-303
lines changed

CoreBluetoothMock.podspec

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'CoreBluetoothMock'
3-
s.version = '0.11.1'
3+
s.version = '0.12.0'
44
s.summary = 'Mocking library for CoreBluetooth.'
55

66
s.description = <<-DESC
@@ -14,12 +14,16 @@ device and test the app on simulator.
1414
s.source = { :git => 'https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock.git', :tag => s.version.to_s }
1515
s.social_media_url = 'https://twitter.com/nordictweets'
1616

17-
s.ios.deployment_target = '8.0'
17+
s.ios.deployment_target = '9.0'
1818
s.osx.deployment_target = '10.13'
1919
s.tvos.deployment_target = '9.0'
2020
s.watchos.deployment_target = '2.0'
21-
s.swift_versions = ['4.2', '5.0', '5.1', '5.2']
21+
s.swift_versions = ['4.2', '5.0', '5.1', '5.2', '5.3']
2222
s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
2323

2424
s.source_files = 'CoreBluetoothMock/Classes/**/*'
25+
26+
# Regarding the lines below see: https://stackoverflow.com/a/63955114/2115352
27+
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
28+
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
2529
end

CoreBluetoothMock/Classes/CBMCentralManagerMock.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import CoreBluetooth
3232

33-
public class CBMCentralManagerMock: NSObject, CBMCentralManager {
33+
open class CBMCentralManagerMock: NSObject, CBMCentralManager {
3434
/// Mock RSSI deviation.
3535
///
3636
/// Returned RSSI values will be in range
@@ -67,11 +67,11 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
6767
}
6868
}
6969

70-
public weak var delegate: CBMCentralManagerDelegate?
71-
public var state: CBMManagerState {
70+
open weak var delegate: CBMCentralManagerDelegate?
71+
open var state: CBMManagerState {
7272
return initialized ? CBMCentralManagerMock.managerState : .unknown
7373
}
74-
public private(set) var isScanning: Bool
74+
open private(set) var isScanning: Bool
7575
private var scanFilter: [CBMUUID]?
7676
private var scanOptions: [String : Any]?
7777

@@ -438,7 +438,7 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
438438
}
439439
}
440440

441-
public func scanForPeripherals(withServices serviceUUIDs: [CBMUUID]?,
441+
open func scanForPeripherals(withServices serviceUUIDs: [CBMUUID]?,
442442
options: [String : Any]?) {
443443
// Central manager must be in powered on state.
444444
guard ensurePoweredOn() else { return }
@@ -479,15 +479,15 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
479479
}
480480
}
481481

482-
public func stopScan() {
482+
open func stopScan() {
483483
// Central manager must be in powered on state.
484484
guard ensurePoweredOn() else { return }
485485
isScanning = false
486486
scanFilter = nil
487487
scanOptions = nil
488488
}
489489

490-
public func connect(_ peripheral: CBMPeripheral,
490+
open func connect(_ peripheral: CBMPeripheral,
491491
options: [String : Any]?) {
492492
// Central manager must be in powered on state.
493493
guard ensurePoweredOn() else { return }
@@ -516,7 +516,7 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
516516
}
517517
}
518518

519-
public func cancelPeripheralConnection(_ peripheral: CBMPeripheral) {
519+
open func cancelPeripheralConnection(_ peripheral: CBMPeripheral) {
520520
// Central manager must be in powered on state.
521521
guard ensurePoweredOn() else { return }
522522
// Ignore peripherals that are not mocks.
@@ -534,7 +534,7 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
534534
}
535535
}
536536

537-
public func retrievePeripherals(withIdentifiers identifiers: [UUID]) -> [CBMPeripheral] {
537+
open func retrievePeripherals(withIdentifiers identifiers: [UUID]) -> [CBMPeripheral] {
538538
// Starting from iOS 13, this method returns peripherals only in ON state.
539539
guard ensurePoweredOn() else { return [] }
540540
// Get the peripherals already known to this central manager.
@@ -564,7 +564,7 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
564564
}
565565
}
566566

567-
public func retrieveConnectedPeripherals(withServices serviceUUIDs: [CBMUUID]) -> [CBMPeripheral] {
567+
open func retrieveConnectedPeripherals(withServices serviceUUIDs: [CBMUUID]) -> [CBMPeripheral] {
568568
// Starting from iOS 13, this method returns peripherals only in ON state.
569569
guard ensurePoweredOn() else { return [] }
570570
// Get the connected peripherals with at least one of the given services
@@ -607,7 +607,7 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
607607
}
608608

609609
@available(iOS 13.0, *)
610-
public func registerForConnectionEvents(options: [CBMConnectionEventMatchingOption : Any]?) {
610+
open func registerForConnectionEvents(options: [CBMConnectionEventMatchingOption : Any]?) {
611611
fatalError("Mock connection events are not implemented")
612612
}
613613

@@ -623,7 +623,7 @@ public class CBMCentralManagerMock: NSObject, CBMCentralManager {
623623

624624
// MARK: - CBPeripheralMock implementation
625625

626-
public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
626+
open class CBMPeripheralMock: CBMPeer, CBMPeripheral {
627627

628628
/// The parent central manager.
629629
private let manager: CBMCentralManagerMock
@@ -652,12 +652,12 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
652652
/// and iOS had chance to read device name.
653653
fileprivate var wasConnected: Bool = false
654654

655-
public var delegate: CBMPeripheralDelegate?
655+
open var delegate: CBMPeripheralDelegate?
656656

657-
public override var identifier: UUID {
657+
open override var identifier: UUID {
658658
return mock.identifier
659659
}
660-
public var name: String? {
660+
open var name: String? {
661661
// If the device wasn't connected and has just been scanned first time,
662662
// return nil. When scanning continued, the Local Name from the
663663
// advertisement data is returned. When the device was connected, the
@@ -669,12 +669,12 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
669669
nil
670670
}
671671
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)
672-
public var canSendWriteWithoutResponse: Bool {
672+
open var canSendWriteWithoutResponse: Bool {
673673
return _canSendWriteWithoutResponse
674674
}
675-
public private(set) var ancsAuthorized: Bool = false
676-
public private(set) var state: CBMPeripheralState = .disconnected
677-
public private(set) var services: [CBMService]? = nil
675+
open private(set) var ancsAuthorized: Bool = false
676+
open private(set) var state: CBMPeripheralState = .disconnected
677+
open private(set) var services: [CBMService]? = nil
678678

679679
// MARK: Initializers
680680

@@ -852,7 +852,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
852852

853853
// MARK: Service discovery
854854

855-
public func discoverServices(_ serviceUUIDs: [CBMUUID]?) {
855+
open func discoverServices(_ serviceUUIDs: [CBMUUID]?) {
856856
// Central manager must be in powered on state.
857857
guard manager.ensurePoweredOn() else { return }
858858
guard state == .connected,
@@ -893,7 +893,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
893893
}
894894
}
895895

896-
public func discoverIncludedServices(_ includedServiceUUIDs: [CBMUUID]?,
896+
open func discoverIncludedServices(_ includedServiceUUIDs: [CBMUUID]?,
897897
for service: CBMService) {
898898
// Central manager must be in powered on state.
899899
guard manager.ensurePoweredOn() else { return }
@@ -951,7 +951,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
951951

952952
}
953953

954-
public func discoverCharacteristics(_ characteristicUUIDs: [CBMUUID]?,
954+
open func discoverCharacteristics(_ characteristicUUIDs: [CBMUUID]?,
955955
for service: CBMService) {
956956
// Central manager must be in powered on state.
957957
guard manager.ensurePoweredOn() else { return }
@@ -1008,7 +1008,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
10081008
}
10091009
}
10101010

1011-
public func discoverDescriptors(for characteristic: CBMCharacteristic) {
1011+
open func discoverDescriptors(for characteristic: CBMCharacteristic) {
10121012
// Central manager must be in powered on state.
10131013
guard manager.ensurePoweredOn() else { return }
10141014
guard state == .connected,
@@ -1066,7 +1066,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
10661066

10671067
// MARK: Read requests
10681068

1069-
public func readValue(for characteristic: CBMCharacteristic) {
1069+
open func readValue(for characteristic: CBMCharacteristic) {
10701070
// Central manager must be in powered on state.
10711071
guard manager.ensurePoweredOn() else { return }
10721072
guard state == .connected,
@@ -1100,7 +1100,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
11001100
}
11011101
}
11021102

1103-
public func readValue(for descriptor: CBMDescriptor) {
1103+
open func readValue(for descriptor: CBMDescriptor) {
11041104
// Central manager must be in powered on state.
11051105
guard manager.ensurePoweredOn() else { return }
11061106
guard state == .connected,
@@ -1136,7 +1136,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
11361136

11371137
// MARK: Write requests
11381138

1139-
public func writeValue(_ data: Data,
1139+
open func writeValue(_ data: Data,
11401140
for characteristic: CBMCharacteristic,
11411141
type: CBMCharacteristicWriteType) {
11421142
// Central manager must be in powered on state.
@@ -1215,7 +1215,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
12151215
}
12161216
}
12171217

1218-
public func writeValue(_ data: Data, for descriptor: CBMDescriptor) {
1218+
open func writeValue(_ data: Data, for descriptor: CBMDescriptor) {
12191219
// Central manager must be in powered on state.
12201220
guard manager.ensurePoweredOn() else { return }
12211221
guard state == .connected,
@@ -1251,7 +1251,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
12511251
}
12521252

12531253
@available(iOS 9.0, *)
1254-
public func maximumWriteValueLength(for type: CBMCharacteristicWriteType) -> Int {
1254+
open func maximumWriteValueLength(for type: CBMCharacteristicWriteType) -> Int {
12551255
// Central manager must be in powered on state.
12561256
guard manager.ensurePoweredOn() else { return 0 }
12571257
guard state == .connected, let mtu = mock.mtu else {
@@ -1262,7 +1262,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
12621262

12631263
// MARK: Enabling notifications and indications
12641264

1265-
public func setNotifyValue(_ enabled: Bool,
1265+
open func setNotifyValue(_ enabled: Bool,
12661266
for characteristic: CBMCharacteristic) {
12671267
// Central manager must be in powered on state.
12681268
guard manager.ensurePoweredOn() else { return }
@@ -1304,7 +1304,7 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
13041304

13051305
// MARK: Other
13061306

1307-
public func readRSSI() {
1307+
open func readRSSI() {
13081308
// Central manager must be in powered on state.
13091309
guard manager.ensurePoweredOn() else { return }
13101310
queue.async { [weak self] in
@@ -1319,11 +1319,11 @@ public class CBMPeripheralMock: CBMPeer, CBMPeripheral {
13191319
}
13201320

13211321
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)
1322-
public func openL2CAPChannel(_ PSM: CBML2CAPPSM) {
1322+
open func openL2CAPChannel(_ PSM: CBML2CAPPSM) {
13231323
fatalError("L2CAP mock is not implemented")
13241324
}
13251325

1326-
public override var hash: Int {
1326+
open override var hash: Int {
13271327
return mock.identifier.hashValue
13281328
}
13291329
}

0 commit comments

Comments
 (0)