PyObjC Framework SecurityUI
PyObjC Framework SecurityUI provides Python bindings for Apple's SecurityUI.framework on macOS. This framework offers user interface components for interacting with security-related authorization services. Version 12.1 is the current release, part of the larger PyObjC project, which generally follows macOS and Python release cycles.
Warnings
- breaking PyObjC 12.0 dropped support for Python 3.9. Users on Python 3.9 must remain on PyObjC < 12.0.
- breaking PyObjC 11.0 dropped support for Python 3.8. Users on Python 3.8 must remain on PyObjC < 11.0.
- breaking PyObjC 11.1 changed how 'init' family methods handle object references, now correctly stealing a reference to `self` and returning a new one, aligning with `clang` ARC documentation. This may alter object lifecycle management for code relying on previous behavior.
- gotcha In PyObjC 10.3, calling `__init__` for Python classes that override `__new__` was disabled. While partially reverted in 10.3.1, this can still cause issues if `__new__` is implemented but `__init__` is used with a PyObjC-provided `__new__`.
- gotcha Experimental free-threading support (PEP 703) was introduced in PyObjC 11.0 for Python 3.13. While a significant feature, its 'experimental' status means users should exercise caution and thorough testing.
- deprecated Automatic Key-Value Observing (KVO) usage for subclasses of `NSProxy` defined in Python is disabled since PyObjC 12.1. This change improves stability but means KVO will not automatically apply to such classes.
Install
-
pip install pyobjc-framework-securityui -
pip install pyobjc
Imports
- SFAuthorization
from SecurityUI import SFAuthorization
Quickstart
from Foundation import NSBundle
from SecurityUI import SFAuthorization
# This example verifies the SecurityUI framework and a key class are available.
# Check if the framework bundle exists
security_ui_bundle = NSBundle.bundleWithPath_(
'/System/Library/Frameworks/SecurityUI.framework'
)
if security_ui_bundle:
print(f"SecurityUI framework bundle found at {security_ui_bundle.bundlePath()}")
print(f"Framework version: {security_ui_bundle.bundleShortVersionString()}")
else:
print("SecurityUI framework bundle not found or inaccessible. "
"Ensure you are running on macOS.")
# Verify a key class from the framework can be imported and accessed
try:
auth_class = SFAuthorization
print(f"Successfully imported SFAuthorization class: {auth_class}")
# In a real application, you'd then instantiate and use auth_class
# e.g., auth = auth_class.alloc().init()
except NameError:
print("Failed to import SFAuthorization class from SecurityUI. "
"Ensure pyobjc-framework-securityui is installed and running on macOS.")