Winning the War Bluetooth on OS X

If you’re experiencing issues with MacID not reconnecting properly, this post outlines some of the things that you can do to try and overcome the problems.

Bluetooth in OS X is becoming the new wifi in OS X. That is to say, it’s now exceptionally buggy for some people.

While we wait for Apple to send out updates there are a few things we can do. There are a few files associated with Bluetooth on your Mac, don’t worry about breaking your Mac by deleting anything I recommend in this post because OS X will re-generate the files when it needs to.

In this post on Stack Overflow you can see there are two main files associated with the Bluetooth cache on your Mac. They’re located in two different places though so if this is your first time digging around in system folders you might get a little lost.

Here’s what to do:

There are two different Bluetooth files you need to find to clear the cache. Although I have already written a post on the first file, it uses Terminal, so here’s how to delete the file manually. Note that the file in the ByHost folder will have a few random characters in, but it will always start with com.apple.Bluetooth 

First find these two folders:

  • /Library/Preferences can be found by opening Finder, clicking Go, then clicking on your hard drive, then choose Library, then choose Preferences.

    /Library/Preferences/com.apple.Bluetooth.plist - file to delete
    /Library/Preferences/com.apple.Bluetooth.plist – file to delete
  • ~/Library/Preferences/ByHost can be found by opening Finder, clicking Go while holding ALT on your keyboard, then clicking Library, then Preferences, then ByHost.

    ~/Library/Preferences/ByHost/com.apple.Bluetooth.randomcharacters.plist - file to delete
    ~/Library/Preferences/ByHost/com.apple.Bluetooth.randomcharacters.plist – file to delete
  1. Unpair your device from the MacID menu.
  2. Turn off Bluetooth.
  3. Delete com.apple.Bluetooth.plist from /Library/Preferences
  4. Delete files named com.apple.Bluetooth.somerandomcharacters.plist from ~/Library/Preferences/ByHost (note that this is the user preference folder, not the system one)
  5. Restart BOTH your Mac and iPhone.
  6. Turn Bluetooth back on.
  7. Open both MacID for iOS and MacID for OS X to re-pair them.

What else can you do?

When I first started development on MacID I couldn’t get Bluetooth to turn off, the option was greyed out. Turns out there was a file lurking about that completely screwed everything up. After deleting a file in /Library/Preferences/SystemConfiguration called com.apple.Bluetooth everything worked properly for me.

If that file exists on your machine, deleting it may help you here too.

You can also try my other post on clearing the cache using Terminal.

But why is this happening?

When MacID disconnects, either OS X or iOS (neither I nor Apple are sure which yet) is making the MacID app look like a new device by changing the identifier associated with it.

When you pair MacID for iOS with MacID for OS X, MacID for OS X stores the identifier and uses it to reconnect (so that it knows your iPhone is the right one). If that identifier changes, as above, then MacID will never be able to reconnect without re-pairing.

To make matters even more complicated, connection attempts never time-out with Bluetooth LE so it will forever sit at “waiting to attempt” assuming that your iPhone is just out of range.

During development this happened a few times, but always sorted itself out. Usually after clearing the cache as described above, and restarting both Mac and iPhone a couple of times.

I have now filed two separate bug reports with Apple and are sending them reports when I can.