Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iOS Support #12

Closed
qdot opened this issue Jan 11, 2020 · 8 comments
Closed

Add iOS Support #12

qdot opened this issue Jan 11, 2020 · 8 comments
Labels
corebluetooth (macos/ios) Issues related to the MacOS/iOS CoreBluetooth impl help wanted Extra attention is needed

Comments

@qdot
Copy link
Contributor

qdot commented Jan 11, 2020

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.

@qdot qdot added help wanted Extra attention is needed corebluetooth (macos/ios) Issues related to the MacOS/iOS CoreBluetooth impl labels Jan 11, 2020
@qdot
Copy link
Contributor Author

qdot commented Jan 21, 2020

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

@imalsogreg
Copy link

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

@schell
Copy link

schell commented Jan 7, 2022

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.

@qwandor
Copy link
Collaborator

qwandor commented Jan 7, 2022

NSBluetoothAlwaysUsageDescription is in the Info.plist right?

@qdot
Copy link
Contributor Author

qdot commented Jan 7, 2022

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.

@schell
Copy link

schell commented Jan 7, 2022

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

@schell
Copy link

schell commented Jan 7, 2022

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.

@qdot
Copy link
Contributor Author

qdot commented Jul 30, 2022

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

@qdot qdot closed this as completed Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
corebluetooth (macos/ios) Issues related to the MacOS/iOS CoreBluetooth impl help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants