4

I'm trying to use BluetoothManager in an app on iOS 7 but it doesn't seem to be working.

Calling setEnabled: and setPowered: on BluetoothManager doesn't have any effect, and I'm registering for notifications (BluetoothAvailabilityChangedNotification) but these are never sent.

I've imported the framework and I'm using example code as given by these questions, but these are all pre-iOS 7, which may be the problem;

iOS BluetoothManager Framwork
iOS: Can't get BluetoothManager to work
Programmatically turn on bluetooth in the iphone sdk?

Community
  • 1
  • 1
ttarik
  • 3,824
  • 1
  • 32
  • 51
  • 1
    Check your console, there could be some messages in there. Most likely it became protected by an entitlement. – Victor Ronin Nov 08 '13 at 15:05
  • Your 3rd link has multiple answers, and only [this one worked for me in the recent past](http://stackoverflow.com/a/6606794/119114). Notice the difference between them. I believe this is explained in your second answer. Let us know if you've specifically tried that, and it still doesn't work. Thanks. – Nate Nov 08 '13 at 19:47
  • @VictorRonin The only console message is 'BTM: attaching to BTServer'. If it's no longer usable, is there any other way to connect to Bluetooth 2.0 devices? – ttarik Nov 08 '13 at 23:30
  • @Nate Nope, afraid that doesn't work either. – ttarik Nov 08 '13 at 23:31

1 Answers1

2

Turns out that this framework hasn't been protected in iOS 7 and is still available for use.

I believe the problem was with the location of the BluetoothManager.h and BluetoothDevice.h header files. They need to be located in the following directory: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework/Headers

And the "Framework Search Paths" build setting of your project needs to include $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks for it to use these files.

I'm not sure why this worked - having the header files in the Xcode project still returned a valid(?) object for [BluetoothManager sharedInstance] but simply didn't give any other functionality. At least now it works, yay!

Oh and I should mention how I discovered this! michaeldorner's "BeeTee" github project is pretty much a basic BluetoothManager sample project designed for iOS 7. The readme file describes the header file placement, other than that it was just the build setting in his project to enable these headers to be used.

ttarik
  • 3,824
  • 1
  • 32
  • 51
  • The *location* of a header file can't make the difference between a runtime error, and your code working correctly. If you were missing the header originally, you should have seen some **compile time** errors or warnings. Something else must have been going on here. – Nate Nov 11 '13 at 07:18
  • 1
    That's what I thought, but it's the only thing that was changed in order to make the app functional. I didn't need to modify any of my code (michaeldorner's code is structured differently but was otherwise the same, anyway), just adding the header file and changing the build setting made it start working. – ttarik Nov 11 '13 at 07:29
  • For some reason I don't seem to have a Headers folder. I have a _CodeSignature folder and BluetoothManager Unix file. Any idea? – Jorgen Apr 22 '14 at 13:18
  • 1
    @Jorgen It doesn't exist by default. You need to download the header files and add them to the framework folder, e.g. from here: https://github.com/michaeldorner/BeeTee/blob/master/Headers.zip – ttarik Apr 23 '14 at 02:03
  • @ev0lution Thanks for the help. Still having problems. I'm trying to "pair" two devices (iPad & printer) and I know the MAC address and BT Pin for the printer. Any idea? – Jorgen Apr 29 '14 at 08:08
  • @Jorgen The actual capabilities of this framework are extremely limited. I don't think I ever managed to successfully pair/connect to devices, and I couldn't find any evidence elsewhere on the internet that anyone else had done so, either. – ttarik Apr 29 '14 at 11:47