PyObjC is a bridge between Python and Objective-C, enabling Python scripts to use and extend existing Objective-C class libraries on macOS. The `pyobjc-framework-security` package provides Python wrappers for Apple's Security framework, allowing developers to access macOS security services like authentication, authorization, and secure data handling from Python. The current version is 12.1.
pip install pyobjc-framework-securityVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pyobjc-framework-security` to generate cryptographically secure random bytes using the `SecRandomCopyBytes` C function from the macOS Security framework. It showcases loading a C function and handling byte buffers.
Upgrade to Python 3.10 or later. PyObjC 12.1 requires Python >=3.10.
Upgrade to Python 3.9 or later (preferably 3.10+ for current versions).
Migrate away from `IMServicePlugIn` to modern macOS APIs, as the framework is no longer supported by Apple or PyObjC.
If implementing custom object creation, ensure `__new__` is handled carefully. Avoid using `__init__` if relying on PyObjC's default `__new__` implementation for Objective-C classes, or upgrade to 10.3.1+ if a user-defined `__new__` requires `__init__`.
Developers working with custom `init` methods in Objective-C classes wrapped by PyObjC should be aware of this change in reference counting behavior to prevent memory leaks or premature deallocation. Consult Apple's ARC documentation for details.
Consult the PyObjC API notes for the Security framework and Apple's documentation for modern alternatives. File an issue with PyObjC if a critical API is missing.