{"id":6120,"library":"pyobjc-framework-iobluetooth","title":"PyObjC Framework IOBluetooth","description":"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.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","bluetooth","ffi","framework","apple"],"install":[{"cmd":"pip install pyobjc-framework-iobluetooth","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"The core bridge between Python and Objective-C, required for any PyObjC framework binding.","package":"pyobjc-core"},{"reason":"Often implicitly or explicitly required for a full Cocoa application context, as IOBluetooth frequently interacts with Cocoa fundamentals.","package":"pyobjc-framework-cocoa","optional":true}],"imports":[{"note":"The primary module for accessing IOBluetooth framework functionality.","symbol":"IOBluetooth","correct":"import IOBluetooth"},{"note":"The underlying PyObjC bridge module, often needed for advanced interactions or to use PyObjC utilities like `objc.ObjCLazyModule`.","symbol":"objc","correct":"import objc"},{"note":"Common base classes and utilities from the Foundation framework, frequently used when working with any Objective-C framework.","symbol":"NSObject, NSBundle","correct":"from Foundation import NSObject, NSBundle"}],"quickstart":{"code":"import objc\nfrom Foundation import NSBundle\nimport IOBluetooth\n\n# Verify that the IOBluetooth framework is loaded and accessible\nprint(f\"IOBluetooth module loaded: {IOBluetooth is not None}\")\n\nif IOBluetooth is not None:\n    # Access a common class from the IOBluetooth framework, e.g., IOBluetoothDevice\n    # and try to get its bundle identifier to confirm functionality.\n    device_class = IOBluetooth.IOBluetoothDevice\n    if device_class:\n        print(f\"Successfully accessed IOBluetoothDevice class: {device_class}\")\n        # Get the bundle for the class to show a more concrete interaction\n        bundle = NSBundle.bundleForClass_(device_class)\n        if bundle:\n            print(f\"IOBluetooth bundle identifier: {bundle.bundleIdentifier()}\")\n        else:\n            print(\"Could not retrieve bundle for IOBluetoothDevice class.\")\n    else:\n        print(\"Failed to access IOBluetoothDevice class.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to Python 3.10 or newer, or pin `pyobjc-framework-iobluetooth<12.0`.","message":"PyObjC 12.0 dropped support for Python 3.9. Users on Python 3.9 must use an older version of pyobjc-framework-iobluetooth (or the full pyobjc package).","severity":"breaking","affected_versions":">=12.0"},{"fix":"Upgrade to Python 3.9 or newer, or pin `pyobjc-framework-iobluetooth<11.0`.","message":"PyObjC 11.0 dropped support for Python 3.8. Users on Python 3.8 must use an older version of pyobjc-framework-iobluetooth (or the full pyobjc package).","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review code interacting with Objective-C `init` methods for potential reference counting issues and adjust accordingly.","message":"Version 11.1 changed how initializer methods (methods in the 'init' family) handle references, aligning with `clang`'s Automatic Reference Counting (ARC) documentation. This means `init` methods now steal a reference to `self` and return a new one, which can alter object lifecycle management.","severity":"breaking","affected_versions":">=11.1"},{"fix":"Ensure deployment environment is macOS. Use cross-platform alternatives for Bluetooth interaction if multi-OS support is required.","message":"PyObjC is a macOS-specific bridge. `pyobjc-framework-iobluetooth` will only function on macOS and cannot be used on other operating systems.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If defining custom `__new__` or `__init__` for Objective-C classes, thoroughly test object initialization and lifecycle. Consider moving complex initialization logic to Objective-C methods if encountering issues.","message":"Changes in `__init__` and `__new__` behavior in versions 10.3 and 10.3.1 can cause issues. While `__init__` was initially disabled when PyObjC provided `__new__` (v10.3), it was re-enabled for user-implemented `__new__` (v10.3.1). This interaction can be tricky for custom class creation patterns.","severity":"gotcha","affected_versions":">=10.3, <11.1"},{"fix":"Run `xcode-select --install` in the terminal to ensure Command Line Tools are present before installation.","message":"Installing PyObjC and its framework bindings may require Apple's Xcode Command Line Tools to be installed, especially for certain Python versions or environments.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}