{"id":6162,"library":"pyobjc-framework-safetykit","title":"PyObjC Framework SafetyKit","description":"PyObjC Framework SafetyKit provides Python wrappers for the macOS SafetyKit framework, allowing Python applications to interact with Apple's APIs related to parental controls and screen time. It is part of the larger PyObjC project, which bridges Python and Objective-C. The current version is 12.1, and releases typically align with macOS SDK updates and PyObjC core library releases.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","framework","objective-c","pyobjc","apple"],"install":[{"cmd":"pip install pyobjc-framework-safetykit","lang":"bash","label":"Install PyObjC SafetyKit bindings"}],"dependencies":[{"reason":"Provides the core bridge between Python and Objective-C, essential for all PyObjC framework bindings.","package":"pyobjc","optional":false}],"imports":[{"note":"Framework classes and functions are typically imported directly from a package named after the framework.","symbol":"SafetyKit","correct":"import SafetyKit"}],"quickstart":{"code":"import SafetyKit\nimport objc\n\n# SafetyKit provides APIs for parental controls and screen time.\n# Actual usage typically involves interacting with system services\n# and requires specific macOS versions and user permissions.\n\n# This quickstart demonstrates importing the framework and accessing a known class.\ntry:\n    # SNSafetyChecker is a primary class within the SafetyKit framework.\n    _ = SafetyKit.SNSafetyChecker\n    print(\"Successfully imported SafetyKit and accessed SNSafetyChecker class.\")\n    print(\"Refer to Apple's official SafetyKit documentation for detailed API usage.\")\n\n    # Example: To interact with a class, you would follow Apple's Objective-C API patterns.\n    # For instance, if SNSafetyChecker had a static method 'isSupported':\n    # if hasattr(SafetyKit.SNSafetyChecker, 'isSupported'):\n    #     print(f\"SNSafetyChecker.isSupported(): {SafetyKit.SNSafetyChecker.isSupported()}\")\n\nexcept AttributeError:\n    print(\"Could not find SNSafetyChecker in SafetyKit. \"\n          \"This might indicate an unsupported macOS version or an incorrect class name.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred during SafetyKit access: {e}\")\n\n","lang":"python","description":"Demonstrates how to import the `SafetyKit` framework and access a representative class like `SNSafetyChecker`. Actual interaction with SafetyKit APIs requires consulting Apple's official documentation for Objective-C, as PyObjC provides direct bindings."},"warnings":[{"fix":"Upgrade Python to 3.10 or later, or use an older PyObjC version compatible with your Python environment.","message":"PyObjC has dropped support for older Python versions in recent major releases. Version 12.0 dropped support for Python 3.9, and version 11.0 dropped support for Python 3.8. Ensure your Python environment meets the `pyobjc-framework-safetykit` requirements (currently >=3.10).","severity":"breaking","affected_versions":"11.0, 12.0"},{"fix":"Review and update code that customizes or interacts heavily with Objective-C object initialization, ensuring compliance with standard ARC rules.","message":"The core PyObjC bridge changed its modeling of Automatic Reference Counting (ARC) for initializer methods in v11.1. Methods in the 'init' family now correctly steal a reference to self and return a new one, aligning with clang's documentation. Code relying on previous, potentially incorrect, reference counting behavior for initializers may break.","severity":"breaking","affected_versions":"11.1 and later"},{"fix":"If subclassing Objective-C classes and encountering initialization issues, ensure `__new__` is correctly implemented or avoid `__init__` if relying on PyObjC's default `__new__` behavior.","message":"Behavior around `__init__` and `__new__` when subclassing Objective-C classes in Python was altered in PyObjC 10.3 and partially reverted in 10.3.1. While `__init__` usage was reintroduced for user-defined `__new__`, code relying on PyObjC's default `__new__` cannot use `__init__`. This can affect Python subclasses of Objective-C types.","severity":"breaking","affected_versions":"10.3, 10.3.1 and later"},{"fix":"Always refer to Apple's official SafetyKit documentation (e.g., via developer.apple.com) when implementing features using this library.","message":"PyObjC framework wrappers, including `pyobjc-framework-safetykit`, do not include their own detailed documentation for the Objective-C APIs. Users must consult Apple's official developer documentation for the 'SafetyKit' framework to understand class structures, methods, and usage patterns.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}