Git Product home page Git Product logo

blecombinekit's Introduction

BLECombineKit

badge-platforms badge-ci badge-codecov badge-carthage badge-spm

CoreBluetooth abstraction layer for iOS, macOS, TvOS and WatchOS development environments. 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:

iOS 13.0+ macOS 11.0+ Beta Mac Catalyst 13.0+ tvOS 13.0+ watchOS 6.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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.