PyObjC Framework IOBluetooth

12.1 · active · verified Tue Apr 14

PyObjC Framework IOBluetooth is a Python binding for the IOBluetooth framework on macOS. It enables Python applications to interact with Bluetooth devices and services through Objective-C APIs. The library is currently at version 12.1 and typically releases new versions in conjunction with macOS SDK updates and PyObjC core developments, ensuring compatibility with the latest Apple technologies.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `IOBluetooth` framework using PyObjC and perform a basic check by accessing a class (`IOBluetoothDevice`) and its associated bundle. This confirms the successful loading and accessibility of the Objective-C framework through Python. For more in-depth usage, refer to Apple's IOBluetooth documentation.

import objc
from Foundation import NSBundle
import IOBluetooth

# Verify that the IOBluetooth framework is loaded and accessible
print(f"IOBluetooth module loaded: {IOBluetooth is not None}")

if IOBluetooth is not None:
    # Access a common class from the IOBluetooth framework, e.g., IOBluetoothDevice
    # and try to get its bundle identifier to confirm functionality.
    device_class = IOBluetooth.IOBluetoothDevice
    if device_class:
        print(f"Successfully accessed IOBluetoothDevice class: {device_class}")
        # Get the bundle for the class to show a more concrete interaction
        bundle = NSBundle.bundleForClass_(device_class)
        if bundle:
            print(f"IOBluetooth bundle identifier: {bundle.bundleIdentifier()}")
        else:
            print("Could not retrieve bundle for IOBluetoothDevice class.")
    else:
        print("Failed to access IOBluetoothDevice class.")

view raw JSON →