PyObjC SecurityFoundation provides Python wrappers for the macOS SecurityFoundation framework, enabling Python scripts to interact with authorization services and other security-related APIs on macOS. It is part of the larger PyObjC project, which regularly releases updates, with the current version being 12.1.
pip install pyobjc-framework-securityfoundationVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the `SecurityFoundation` framework and obtain a default `SFAuthorization` object, which is a core component for interacting with macOS Authorization Services.
Upgrade Python to a supported version (e.g., Python 3.10+ for PyObjC 12.1).
Adopt the `alloc().init()` pattern for object creation, or ensure `__new__` is explicitly implemented by the user if `__init__` is needed.
Remove any dependencies on `IMServicePlugIn`. Applications needing similar functionality may need to find alternative macOS APIs or adjust their design.
Avoid using KVO with Python subclasses of `NSProxy`. If KVO-like functionality is required, implement a custom observation mechanism.
If using PyObjC versions older than 10.1, convert Cocoa URL objects to Python string paths manually before passing them to `os.fspath()`. Upgrade to 10.1 or newer to use `os.fspath()` directly.
For older versions, ensure `bytearray` is explicitly converted (e.g., `str(b.decode('utf-8'))` or `b'...' + b'\0'`) if a null-terminated C string is expected. Upgrade to 12.1+ to use `bytearray` directly.