deviceplug / btleplug

Rust Cross-Platform Host-Side Bluetooth LE Access Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add iOS Support

qdot opened this issue · comments


Not sure how much this relates to #2, i.e. how much of CoreBluetooth code can translate between macOS and iOS. Also need to provide documentation on what's required for getting bluetooth access working in iOS apps with rust code (info.plist additions, background perms, etc).

I have very little Cocoa experience, and all my iOS has been through not-quite-native libraries/frameworks (Xamarin/React Native/etc), so lots of open questions.


Now that we have macOS, this might be done? Need to get an iOS/Swift grownup in to check this.

@schell can this be closed, given your findings with objective-c?

We have successfully scanned and connected to peripherals on iOS using btleplug. It seems the only special thing needed in our case (after the expected work of creating a C wrapper/library to FFI into) was the addition of the key: value pair NSBluetoothAlwaysUsageDescription: Our app uses bluetooth to find, connect and transfer data between different devices in our iOS app. I'm sure you could use any value though. All in all btleplug has been great to work with.

Our use isn't extensive in any way but it looks like it's working as expected.

NSBluetoothAlwaysUsageDescription is in the Info.plist right?


We might want to call this closable after we update the README to mention support since it's been confirmed, though it might also be nice to get some basic build instructions in too.

@qwandor yes, exactly. Sorry I was a bit tired last night!

For build instructions it roughly goes:

  • write a rust library (static) that uses btleplug and exposes an FFI API to C
  • use cbindgen to generate a C header file for that API
  • use cargo-lipo to build a universal static lib
  • drag the header file and the library into your Xcode project
  • add NSBluetoothAlwaysUsageDescription to your Info.plist file

That's how I did it, but I know there are many ways to pet a cat, so to speak.


Since we've got iOS working for multiple people now, both via bare library and flutter, calling this done.