Safer `Core Bluetooth` presence check
The previous check does not working on macOS Big Sur as it presumes that Core Bluetooth was already loaded on the process.
Superseeds
@@ -51,9 +51,9 @@ if platform.system() == "Linux":
BleakClientBlueZDBus as BleakClient,
) # noqa
elif platform.system() == "Darwin":
- from Foundation import NSClassFromString
-
- if NSClassFromString("CBPeripheral") is None:
+ try:
+ from CoreBluetooth import CBPeripheral
+ except:
raise BleakError("Bleak requires the CoreBluetooth Framework")
from bleak.backends.corebluetooth.discovery import discover # noqa
