PyObjC provides Python bindings for Apple's macOS frameworks, allowing Python applications to interact with Objective-C APIs. The `pyobjc-framework-cfnetwork` package specifically provides wrappers for the CFNetwork framework, which offers a C-based API for low-level network services. It is actively maintained as part of the broader PyObjC project, with releases often coinciding with new macOS SDK updates and Python version support. The current version is 12.1.
pip install pyobjc-framework-cfnetworkVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `CFNetwork.CFHostCreateWithName` to create a host object and then resolve its IP addresses. It showcases basic interaction with a C-based macOS networking API through PyObjC.
Ensure your project targets Python 3.10 or later when using PyObjC 12.x, and Python 3.9 or later when using PyObjC 11.x.
Review code that interacts with `alloc`/`init` patterns for potential memory management issues, although Python's GC often mitigates direct impact unless complex manual reference counting is involved.
Avoid using free-threaded Python builds (e.g., `python --enable-thread-gil=0`) with PyObjC until full, stable support is officially announced to prevent crashes or incorrect behavior.
Carefully review classes that override `__new__` and use `__init__` in conjunction with PyObjC, especially for subclasses of Objective-C classes. You may need to adapt to PyObjC's object construction patterns, typically favoring `init` methods.
If your application relied on `IMServicePlugIn` bindings, you must either target an older macOS and PyObjC version or migrate to alternative APIs if available.