52

I'm trying some iOS test applications on the new Mac mini, that supports Bluetooth Low Energy. The CoreBluetooth framework is used in those. However, I'm not able to get Bluetooth working in the iPhone simulator, that is part of Xcode.

When I allocate a new CBCentralManager, centralManagerDidUpdateState: receives CBCentralManagerStatePoweredOff which stands for Bluetooth is currently powered off.

The first time I ran the text application, a box was then opened up that looked pretty bugged (only language variables were used, not the actual texts) and with two buttons. The first led me to the settings panel where there was an option to enable Bluetooth. However, after I told it to enable Bluetooth, it just shows the spinning animation, and it won't either complete or cancel. Even after rebooting the Mac, there is still only the spinning animation. The box also does not open up anymore.

Essentially, I think that the iPhone simulator should support Bluetooth Low Energy. Otherwise, it does not really make sense that there is an option in the settings application on the simulator. Also, the central manager state is CBCentralManagerStatePoweredOff but not CBCentralManagerStateUnsupported which would stand for The platform doesn't support Bluetooth Low Energy. This gives also hope that support could exist.

  • Does the iPhone simulator support Bluetooth Low Energy?
  • If yes, how can I enable it?
Etan
  • 15,505
  • 17
  • 83
  • 142

6 Answers6

46

The simulator does support Bluetooth Low Energy (4.0) according to this appnote from Apple. The only problem is that even if you have a computer with BLE inside, you will not be able to use the simulator together with it, because (I think) you occupy the availability on BLE for other devices to discover your computer, thereby restricting the functionality of the Mac.

So if you go get yourself a BLE USB dongle you will be able to use it in simulator.

EDIT: Adding information from @JoeShaw:

Unfortunately it appears as though Core Bluetooth support has been dropped from the simulator for iOS 7. Reference: doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7. In addition, the linked technote seems to have been removed.

chwi
  • 2,663
  • 2
  • 34
  • 62
  • Yep that's the newest update. However, even if you attach a BLE USB dongle it may bug in a way that Mac OS may register with the dongle instead of the internal one. Then, the simulator is still not able to use the internal one, and because the external dongle is blocked it won't work either. Therefore, I suggest attaching the dongle after system startup to circumvent this problem. – Etan Jun 18 '12 at 13:11
  • Good info. Where did you aquire a dongle? – chwi Jun 18 '12 at 17:08
  • 1
    Did not acquire one, it's just information that I've read on Apple websites as well. I went for a real iPhone 4S because otherwise you won't experience all of the bugs :-) – Etan Jun 18 '12 at 20:43
  • Tried the steps on http://developer.apple.com/library/ios/#technotes/tn2295/_index.html. But still the can't turn on Bluetooth on the simulator. I am using the TI CC2540 USB dongle. – Gamma-Point May 21 '13 at 01:36
  • Gamma, it seems to me like you are trying to turn on the regular bluetooth. Bt4 does not have a switch in iOS and has to checked programatically – chwi May 21 '13 at 06:37
  • 6
    Unfortunately it appears as though Core Bluetooth support has been dropped from the simulator for iOS 7. Reference: http://www.doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7/. In addition, the linked technote seems to have been removed. – Joe Shaw Nov 15 '13 at 20:34
14

I have been using the simulator to test BLE apps - but you need to be on OSX 10.7. As Wilhelmsen mentioned, you also need a BLE USB dongle. In addition, you need to set an NVRAM setting:

$sudo nvram bluetoothHostControllerSwitchBehavior="never"

See this Technical Note from Apple for more details on using the simulator to test BLE apps: http://developer.apple.com/library/ios/#technotes/tn2295/_index.html

chwi
  • 2,663
  • 2
  • 34
  • 62
mezulu
  • 1,095
  • 1
  • 11
  • 20
10

According to http://www.doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7/, Core Bluetooth support has been dropped from the simulator as of iOS 7. I haven't figured out why yet, but it means you will need to test on real hardware in the future.

It also appears as though Apple has removed Tech Note 2295, as I get redirected when I hit the URL.

Joe Shaw
  • 20,211
  • 16
  • 63
  • 87
  • 3
    The problem was that the compatibility issues with all the different BT dongles took too much effort to workaround. Therefore, Apple dropped BT support for the simulator, as the encountered bugs made the simulator behave differently than the real device. – Etan Nov 18 '13 at 11:25
5

I've found that Apple writes in their own samples that the simulator cannot be used to test Core Bluetooth-based applications.

Important: This project requires a Bluetooth LE Capable Device (Currently only the iPhone 4S) and will not work on the simulator.

Etan
  • 15,505
  • 17
  • 83
  • 142
2

I've been working on a BLE app for the past week and can say with confidence that no, the simulator does not support BLE unless the mac that your using has BLE(Macbook Air) - but even then i'm not 100% sure how to enable this(most likely by just turing on BLE on your mac and on the simulator).

If you don't have a BLE enabled mac, have to find yourself a 4s to do testing with!

kj13ennett
  • 309
  • 1
  • 2
  • 10
  • I am using the Mac mini Server from Mid 2011, so it should have Bluetooth 4.0. – Etan Apr 10 '12 at 08:10
  • Again, not without an external dongle according to the documentation from Apple – chwi Jun 20 '12 at 06:51
  • 1
    Bluetooth support dropped by apple. Here is a confirmation from apple staff: https://forums.developer.apple.com/thread/14983 – Gultekin Dec 06 '18 at 14:13
0

Actually I tried in the simulator and does not work. The simulator does not recognize if you have a Bluetooth 4.0 in your computer but if you are using Command line tool projects in Xcode then it works. just for the cases you want to create something in Command line tool.

O.C.
  • 59
  • 1