Swiftpack.co - Henryforce/BLECombineKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Henryforce.
Henryforce/BLECombineKit v0.1.7
CoreBluetooth abstraction layer for iOS, macOS, TvOS and WatchOS development environments. Powered by Combine.
⭐️ 13
🕓 1 week ago
iOS
.package(url: "https://github.com/Henryforce/BLECombineKit.git", from: "v0.1.7")

BLECombineKit

badge-platforms badge-carthage badge-spm

CoreBluetooth abstraction layer for iOS development environment. Powered by Combine.

  • SwiftUI compatible
  • Apple's APIs dependencies only

It is currently supported on:

iOS 13.0+

How to use

As simple as creating a CBCentralManager and let the reactive magic of Combine do the rest:

import CoreBluetooth
import Combine
import BLECombineKit

...

let centralManager = BLECombineKit.buildCentralManager(with: CBCentralManager())

centralManager.scanForPeripherals(withServices: nil, options: nil)
    .first()
    .flatMap { $0.peripheral.discoverServices(serviceUUIDs: nil) }
    .flatMap { $0.discoverCharacteristics(characteristicUUIDs: nil) }
    .flatMap { $0.observeValue() }
    .sink(receiveCompletion: { completion in
        print(completion)
    }, receiveValue: { data in
        print(data.value)
    })
    .store(in: &disposables)

You can reference the sample project inside the repository to see the library in action with SwiftUI.

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CombineBluetoothKit into your Xcode project using Carthage specify it in your Cartfile:

github "Henryforce/BLECombineKit"

Then, run carthage update to build framework and drag CombineBluetoothKit.framework into your Xcode project.

Swift Package Manager

In Xcode, select File --> Swift Packages --> Add Package Dependency and then add the following url:

https://github.com/Henryforce/BLECombineKit

GitHub

link
Stars: 13
Last commit: 3 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 week ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics