{"id":22753597,"url":"https://github.com/starryinternet/combinecorebluetooth","last_synced_at":"2026-03-08T06:31:31.307Z","repository":{"id":38389470,"uuid":"399224695","full_name":"StarryInternet/CombineCoreBluetooth","owner":"StarryInternet","description":"A wrapper API for CoreBluetooth using Combine Publishers","archived":false,"fork":false,"pushed_at":"2024-10-28T02:03:00.000Z","size":150,"stargazers_count":130,"open_issues_count":2,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-30T08:27:47.433Z","etag":null,"topics":["bluetooth","combine","corebluetooth","ios","macos","reactive-programming","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StarryInternet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-23T19:26:45.000Z","updated_at":"2024-10-18T14:32:46.000Z","dependencies_parsed_at":"2024-05-29T17:22:24.350Z","dependency_job_id":"3f02d81f-dc47-4e99-a614-1ae28cae4b89","html_url":"https://github.com/StarryInternet/CombineCoreBluetooth","commit_stats":{"total_commits":58,"total_committers":5,"mean_commits":11.6,"dds":"0.31034482758620685","last_synced_commit":"48635dc29dcc1a61e34bd57b6d289e8035d0e109"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2FCombineCoreBluetooth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2FCombineCoreBluetooth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2FCombineCoreBluetooth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2FCombineCoreBluetooth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StarryInternet","download_url":"https://codeload.github.com/StarryInternet/CombineCoreBluetooth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266564,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth","combine","corebluetooth","ios","macos","reactive-programming","swift","tvos","watchos"],"created_at":"2024-12-11T06:11:51.903Z","updated_at":"2026-03-08T06:31:31.258Z","avatar_url":"https://github.com/StarryInternet.png","language":"Swift","readme":"# CombineCoreBluetooth\n\n[![CI](https://github.com/StarryInternet/CombineCoreBluetooth/actions/workflows/ci.yml/badge.svg)](https://github.com/StarryInternet/CombineCoreBluetooth/actions/workflows/ci.yml)\n[![GitHub](https://img.shields.io/github/license/StarryInternet/CombineCoreBluetooth)](https://github.com/StarryInternet/CombineCoreBluetooth/blob/master/LICENSE)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStarryInternet%2FCombineCoreBluetooth%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/StarryInternet/CombineCoreBluetooth)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStarryInternet%2FCombineCoreBluetooth%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/StarryInternet/CombineCoreBluetooth)\n\nCombineCoreBluetooth is a library that bridges Apple's `CoreBluetooth` framework and Apple's `Combine` framework, making it possible to subscribe to perform bluetooth operations while subscribing to a publisher of the results of those operations, instead of relying on implementing delegates and manually filtering for the results you need.\n\n## Requirements:\n\n- iOS 13, tvOS 13, macOS 11, or watchOS 6\n- Xcode 15 or higher\n- Swift 5.9 or higher\n\n(If you are using carthage, or if you wish to open the project to play with the demo app, you will need to use Xcode 16)\n\n## Installation\n\n### Swift Package Manager\n\nAdd this line to your dependencies list in your Package.swift:\n\n```swift\n.package(name: \"CombineCoreBluetooth\", url: \"https://github.com/StarryInternet/CombineCoreBluetooth.git\", from: \"0.8.0\"),\n```\n\n### Cocoapods\n\nAdd this line to your Podfile:\n\n```ruby\npod 'CombineCoreBluetooth'\n```\n\n### Carthage\n\nAdd this line to your Cartfile:\n\n```\ngithub \"StarryInternet/CombineCoreBluetooth\"\n```\n\n## Usage\n\nThis library is heavily inspired by [pointfree.co's approach](https://www.pointfree.co/collections/dependencies) to designing dependencies, but with some customizations. Many asynchronous operations returns their own `Publisher` or expose their own long-lived publisher you can subscribe to.\n\nThis library doesn't maintain any additional state beyond what's needed to enable this library to provide a combine-centric API. This means that you are responsible for maintaining any state necessary, including holding onto any `Peripheral`s returned by discovering and connected to via the `CentralManager` type.\n\nTo scan for a peripheral, much like in plain CoreBluetooth, you call the `scanForPeripherals(withServices:options:)` method. However, on this library's `CentralManager` type, this returns a publisher of `PeripheralDiscovery` values. If you want to store a peripheral for later use, you could subscribe to the returned publisher by doing something like this:\n\n```swift\nlet serviceID = CBUUID(string: \"0123\")\n\ncentralManager.scanForPeripherals(withServices: [serviceID])\n  .first()\n  .assign(to: \\.peripheralDiscovery, on: self) // property of type PeripheralDiscovery\n  .store(in: \u0026cancellables)\n```\n\nTo do something like fetching a value from a characteristic, for instance, you could call the following methods on the `Peripheral` type and subscribe to the resulting `Publisher`:\n\n```swift\n// use whatever ids your peripheral advertises here\nlet characteristicID = CBUUID(string: \"4567\")\n\nperipheralDiscovery.peripheral\n  .readValue(forCharacteristic: characteristicID, inService: serviceID)\n  .sink(receiveCompletion: { completion in\n    // handle any potential errors here\n  }, receiveValue: { data in\n   // handle data from characteristic here, or add more publisher methods to map and transform it.\n  })\n  .store(in: \u0026cancellables)\n```\n\nThe publisher returned in `readValue` will only send values that match the service and characteristic IDs through to any subscribers, so you don't need to worry about any filtering logic yourself. Note that if the `Peripheral` never receives a value from this characteristic over bluetooth, it will never send a value into the publisher, so you may want to add a timeout if your use case requires it.\n\n## Caveats\n\nAll major types from `CoreBluetooth` should be available in this library, wrapped in their own types to provide the `Combine`-centric API. This library has been tested in production for most `CentralManager` related operations. Apps acting as bluetooth peripherals are also supported using the `PeripheralManager` type, but that side hasn't been as rigorously tested.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarryinternet%2Fcombinecorebluetooth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarryinternet%2Fcombinecorebluetooth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarryinternet%2Fcombinecorebluetooth/lists"}