{"id":6169,"library":"pyobjc-framework-securityfoundation","title":"PyObjC SecurityFoundation Framework","description":"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.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","cocoa","bindings","security"],"install":[{"cmd":"pip install pyobjc-framework-securityfoundation","lang":"bash","label":"Install PyObjC SecurityFoundation"}],"dependencies":[{"reason":"This package provides bindings for a specific macOS framework and relies on the core PyObjC bridge functionality.","package":"pyobjc-core","optional":false}],"imports":[{"note":"PyObjC maps macOS frameworks to Python packages with the same name. SFAuthorization is the primary class in the SecurityFoundation framework.","symbol":"SFAuthorization","correct":"from SecurityFoundation import SFAuthorization"}],"quickstart":{"code":"import SecurityFoundation\nimport objc\n\n# Get a default SFAuthorization object\nauth = SecurityFoundation.SFAuthorization.authorization()\n\nif auth:\n    print(f\"Successfully obtained SFAuthorization object: {auth}\")\n    # Further operations would involve using methods on the 'auth' object\n    # to perform authorization checks or privilege escalation.\nelse:\n    print(\"Failed to obtain SFAuthorization object.\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade Python to a supported version (e.g., Python 3.10+ for PyObjC 12.1).","message":"Python Version Support Drops: PyObjC has a policy of dropping support for older Python versions. PyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 dropped support for Python 3.8. Always consult the release notes to ensure compatibility with your target Python and macOS versions.","severity":"breaking","affected_versions":"11.0, 12.0+"},{"fix":"Adopt the `alloc().init()` pattern for object creation, or ensure `__new__` is explicitly implemented by the user if `__init__` is needed.","message":"Changes in `__init__` and `__new__` behavior: In PyObjC 10.3, calling `__init__` on subclasses that rely on PyObjC's `__new__` was disabled. While partially reintroduced in 10.3.1 for user-implemented `__new__`, code relying on the PyObjC-provided `__new__` cannot use `__init__`. This can break existing subclassing patterns.","severity":"breaking","affected_versions":"10.3, 10.3.1+"},{"fix":"Remove any dependencies on `IMServicePlugIn`. Applications needing similar functionality may need to find alternative macOS APIs or adjust their design.","message":"Removal of `IMServicePlugIn` Bindings: The `IMServicePlugIn` framework bindings were entirely removed in PyObjC 10.0, as the underlying framework was deprecated by Apple in macOS 10.13 and removed in macOS 14.","severity":"breaking","affected_versions":"10.0+"},{"fix":"Avoid using KVO with Python subclasses of `NSProxy`. If KVO-like functionality is required, implement a custom observation mechanism.","message":"KVO (Key-Value Observing) for `NSProxy` Subclasses: As of PyObjC 12.1, KVO usage is automatically disabled for Python subclasses of `NSProxy`. Attempting to use KVO with these subclasses can lead to `SystemError`.","severity":"gotcha","affected_versions":"12.1+"},{"fix":"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.","message":"`os.fspath` with Cocoa URLs: Prior to PyObjC 10.1, `os.fspath()` would raise a `TypeError` when used with Cocoa URL objects (`NSURL`, `CFURLRef`) that referred to local filesystem paths. This was fixed in 10.1.","severity":"gotcha","affected_versions":"<10.1"},{"fix":"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.","message":"`bytearray` as C `char*` argument: In versions prior to 12.1, passing a `bytearray` directly to an Objective-C function or selector expecting a null-terminated C char array might have required manual conversion. As of 12.1, `bytearray` instances can be used directly.","severity":"gotcha","affected_versions":"<12.1"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}