{"id":5806,"library":"pyobjc-framework-corewlan","title":"PyObjC CoreWLAN Framework Bindings for macOS","description":"The `pyobjc-framework-corewlan` package provides Python bindings for Apple's CoreWLAN framework on macOS. It allows Python applications to interact with Wi-Fi interfaces, retrieve network information, and manage wireless connections. It is part of the larger PyObjC project, which bridges Python and Objective-C, enabling Python developers to leverage macOS Cocoa frameworks directly. The current version is 12.1, with a regular release cadence aligned with macOS SDK updates and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macOS","CoreWLAN","Objective-C","bridge","Wi-Fi","networking"],"install":[{"cmd":"pip install pyobjc-framework-CoreWLAN","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or later.","package":"python","optional":false}],"imports":[{"note":"Imports the entire CoreWLAN framework as a Python package.","symbol":"CoreWLAN","correct":"import CoreWLAN"}],"quickstart":{"code":"import CoreWLAN\n\ndef get_wifi_info():\n    try:\n        # Get the default wireless interface\n        interface = CoreWLAN.CWInterface.interface()\n\n        if interface:\n            print(f\"Current Wi-Fi interface Hardware Address: {interface.hardwareAddress()}\")\n            print(f\"Current Wi-Fi Power Status: {'On' if interface.powerOn() else 'Off'}\")\n\n            current_ssid = interface.ssid()\n            if current_ssid:\n                print(f\"Currently connected to network: {current_ssid}\")\n            else:\n                print(\"Not currently connected to a Wi-Fi network.\")\n\n            # List available Wi-Fi networks\n            print(\"\\nAvailable Wi-Fi Networks:\")\n            for network in CoreWLAN.CWInterface.interface().cachedScanResults():\n                print(f\"  - SSID: {network.ssid()}, RSSI: {network.rssiValue()} dBm\")\n\n        else:\n            print(\"No Wi-Fi interface found.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Note: Accessing CoreWLAN functionality, especially for modifications, often requires a properly signed application or elevated privileges on macOS.\")\n\nif __name__ == \"__main__\":\n    get_wifi_info()","lang":"python","description":"This quickstart demonstrates how to import the CoreWLAN framework and retrieve basic information about the Wi-Fi interface and available networks. Note that modifying Wi-Fi settings (e.g., turning power on/off) typically requires a properly signed application or administrative privileges on macOS, and is not included in this basic example."},"warnings":[{"fix":"Upgrade your Python environment to Python 3.10 or later. Python 3.10+ is required.","message":"PyObjC v12.0 and later dropped support for Python 3.9. Attempting to use these versions with Python 3.9 will result in installation or runtime errors.","severity":"breaking","affected_versions":"12.0+"},{"fix":"Ensure your Python environment is at version 3.9 or later (preferably 3.10+ as per v12.0 changes).","message":"PyObjC v11.0 and later dropped support for Python 3.8. Similar to Python 3.9, this will cause compatibility issues.","severity":"breaking","affected_versions":"11.0+"},{"fix":"Review any custom Objective-C subclasses defined in Python, especially their `init` methods, to ensure they correctly handle reference counting based on the new behavior. Incorrect handling might lead to memory leaks or premature object deallocation.","message":"PyObjC v11.1 introduced changes to align reference counting behavior for Objective-C 'init' family methods with `clang`'s automatic reference counting (ARC) documentation. This means `init` methods now correctly model stealing a reference to `self` and returning a new one.","severity":"breaking","affected_versions":"11.1+"},{"fix":"If defining Objective-C subclasses in Python with custom object creation logic, carefully manage the use of `__new__` and `__init__` in accordance with PyObjC's specific rules, particularly when overriding `__new__`.","message":"The interaction between Python's `__init__` and `__new__` methods for PyObjC subclasses was altered in v10.3, partially reverted in v10.3.1. While `__init__` can now be used with user-implemented `__new__`, it still cannot be used with PyObjC's provided `__new__`.","severity":"gotcha","affected_versions":"10.3 - 10.3.1+"},{"fix":"Remove any dependencies on the `IMServicePlugIn` framework. There is no direct replacement within PyObjC as the underlying Apple framework is no longer available.","message":"The 'IMServicePlugIn' framework bindings were removed in PyObjC v10.0 because the framework itself was deprecated in macOS 10.13 and removed in macOS 14.","severity":"breaking","affected_versions":"10.0+"},{"fix":"Ensure your macOS application is properly signed with a developer certificate to gain full access to CoreWLAN functionalities. Running from an unsiged script or an ad-hoc signed app might result in permission errors or limited functionality.","message":"Accessing privacy-relevant CoreWLAN information or performing actions (like changing Wi-Fi power) in macOS requires the application binary to be properly signed, not just an ad-hoc signature.","severity":"gotcha","affected_versions":"All versions on recent macOS"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}