Skip to content

Commit

Permalink
Merge pull request #29 from Henryforce/master_fix
Browse files Browse the repository at this point in the history
Fixed master and updated environment support to only iOS
  • Loading branch information
Henryforce authored Jan 13, 2022
2 parents 560990c + 14a6789 commit e8e6325
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 33 deletions.
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "CombineExt",
"repositoryURL": "https://github.com/CombineCommunity/CombineExt.git",
"state": {
"branch": null,
"revision": "0880829102152185190064fd17847a7c681d2127",
"version": "1.5.1"
}
}
]
},
"version": 1
}
35 changes: 21 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "BLECombineKit",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)
.iOS(.v13)
],
products: [
.library(name: "BLECombineKit", targets: ["BLECombineKit"])
Expand All @@ -19,18 +19,25 @@ let package = Package(
],
targets: [
.target(
name: "BLECombineKit",
dependencies: ["CombineExt"],
path: ".",
exclude: [
"Source/BLECombineKit.h",
"Source/Info.plist",
"BLECombineExplorer",
"Tests"
],
sources: [
"Source"
]
)
name: "BLECombineKit",
dependencies: ["CombineExt"],
path: ".",
exclude: [
"Source/BLECombineKit.h",
"Source/Info.plist",
"BLECombineExplorer",
"Tests"
],
sources: [
"Source"
]
),
.testTarget(
name: "BLECombineKitTests",
dependencies: [
"BLECombineKit",
],
path: "Tests"
),
]
)
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# BLECombineKit

![badge-platforms][] [![badge-ci][]][travis] [![badge-codecov][]][codecov] [![badge-carthage][]][carthage] [![badge-spm][]][spm]
![badge-platforms][] [![badge-carthage][]][carthage] [![badge-spm][]][spm]

CoreBluetooth abstraction layer for iOS, macOS, TvOS and WatchOS development environments. Powered by Combine.
CoreBluetooth abstraction layer for iOS development environment. Powered by Combine.

- SwiftUI compatible
- Apple's APIs dependencies only

Per Apple's docs, https://developer.apple.com/documentation/combine, Combine (and BLECombineKit) is only supported on:
It is currently supported on:

iOS 13.0+
macOS 11.0+ Beta
Mac Catalyst 13.0+
tvOS 13.0+
watchOS 6.0+

# How to use

Expand Down Expand Up @@ -62,13 +58,9 @@ In Xcode, select File --> Swift Packages --> Add Package Dependency and then add
https://github.com/Henryforce/BLECombineKit
```

[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg
[badge-codecov]: https://codecov.io/gh/codecov/example-swift/branch/master/graphs/badge.svg
[badge-ci]: https://travis-ci.com/Henryforce/BLECombineKit.svg?branch=master
[badge-platforms]: https://img.shields.io/badge/platforms-iOS%20%7C%20-lightgrey.svg
[badge-carthage]: https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat
[badge-spm]: https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg

[codecov]: https://codecov.io/gh/Henryforce/BLECombineKit/branch/master
[travis]: https://travis-ci.com/Henryforce/BLECombineKit
[carthage]: https://github.com/Carthage/Carthage
[spm]: https://github.com/apple/swift-package-manager
1 change: 1 addition & 0 deletions Source/Central/BLECentralManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public protocol BLECentralManager: AnyObject {
func stopScan()
func connect(peripheralWrapper: CBPeripheralWrapper, options: [String:Any]?)
func cancelPeripheralConnection(_ peripheral: CBPeripheralWrapper) -> AnyPublisher<Never, Never>

func registerForConnectionEvents(options: [CBConnectionEventMatchingOption : Any]?)
func observeWillRestoreState() -> AnyPublisher<[String: Any], Never>
func observeDidUpdateANCSAuthorization() -> AnyPublisher<BLEPeripheral, Never>
Expand Down
15 changes: 14 additions & 1 deletion Source/Error/BLEError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ extension CBATTError: Hashable, Identifiable {
public var id: Self { self }
}

public enum BLEError: Error, Hashable, Identifiable, CustomStringConvertible {
public enum BLEError: Error, CustomStringConvertible {

public enum CoreBluetoothError: Error, Hashable, Identifiable, CustomStringConvertible {
case base(code: CBError.Code, description: String), ATT(code: CBATTError.Code, description: String), other(error: NSError)

Expand Down Expand Up @@ -97,6 +98,14 @@ public enum BLEError: Error, Hashable, Identifiable, CustomStringConvertible {

public var id: Self { self }

case advertisingInProgress

case advertisingStartFailed(Error)

case addingServiceFailed(CBMutableService, Error)

case publishingL2CAPChannelFailed(CBL2CAPPSM, Error)

/// Generic error for handling `unknown` cases.
case unknown

Expand All @@ -117,6 +126,10 @@ public enum BLEError: Error, Hashable, Identifiable, CustomStringConvertible {

public var description: String {
switch(self) {
case .advertisingInProgress: return "Advertising in Progress"
case .advertisingStartFailed(let error): return "Advertising failed to start with error: \(error)"
case .addingServiceFailed(let service, let error): return "Adding service \(service) failed with error: \(error)"
case .publishingL2CAPChannelFailed(_, let error): return "Publishing L2CAPChannel failed with error: \(error)"
case .unknown: return "Unknown error"
case .deallocated: return "Deallocated"
case .managerState(let error): return "Manager state error: \(error)"
Expand Down
2 changes: 1 addition & 1 deletion Tests/BLECentralManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CoreBluetooth
import Combine
@testable import BLECombineKit

class BLECentralManagerTests: XCTestCase {
final class BLECentralManagerTests: XCTestCase {

var sut: BLECentralManager!
var delegate: BLECentralManagerDelegate!
Expand Down
2 changes: 1 addition & 1 deletion Tests/BLECharacteristicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import XCTest
import CoreBluetooth
@testable import BLECombineKit

class BLECharacteristicTests: XCTestCase {
final class BLECharacteristicTests: XCTestCase {

var blePeripheralMock: MockBLEPeripheral!

Expand Down
2 changes: 1 addition & 1 deletion Tests/BLECombineKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import XCTest
import BLECombineKit

class BLECombineKitTests: XCTestCase {
final class BLECombineKitTests: XCTestCase {

func testBLECombineKitInitReturnsBLECentralManager() throws {
let bleCentralManager = BLECombineKit.buildCentralManager()
Expand Down
2 changes: 1 addition & 1 deletion Tests/BLEDataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import XCTest
@testable import BLECombineKit

class BLEDataTests: XCTestCase {
final class BLEDataTests: XCTestCase {

var mockupPeripheral: MockBLEPeripheral!

Expand Down
2 changes: 1 addition & 1 deletion Tests/BLEPeripheralTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CoreBluetooth
import Combine
@testable import BLECombineKit

class BLEPeripheralTests: XCTestCase {
final class BLEPeripheralTests: XCTestCase {

var sut: StandardBLEPeripheral!
var delegate: BLEPeripheralDelegate!
Expand Down
2 changes: 1 addition & 1 deletion Tests/BLEServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import XCTest
import CoreBluetooth
@testable import BLECombineKit

class BLEServiceTests: XCTestCase {
final class BLEServiceTests: XCTestCase {

var blePeripheralMock: MockBLEPeripheral!

Expand Down

0 comments on commit e8e6325

Please sign in to comment.