{"id":6166,"library":"pyobjc-framework-screentime","title":"PyObjC ScreenTime Framework","description":"PyObjC is a bridge between Python and Objective-C, enabling Python scripts to use and extend existing Objective-C class libraries, primarily Apple's Cocoa frameworks. `pyobjc-framework-screentime` provides Python wrappers for the macOS ScreenTime framework, allowing access to its APIs. The library is currently at version 12.1 and maintains an active release cadence, typically aligning with macOS and Python version updates.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","framework","screentime","pyobjc","apple","objective-c"],"install":[{"cmd":"pip install pyobjc-framework-screentime","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This package provides bindings for a specific macOS framework and depends on the core PyObjC bridge.","package":"pyobjc-core","optional":false},{"reason":"Requires Python 3.10 or newer.","package":"Python","optional":false}],"imports":[{"note":"Bindings for the ScreenTime framework are accessed through the 'ScreenTime' package.","symbol":"ScreenTime","correct":"import ScreenTime"}],"quickstart":{"code":"import Foundation\nimport ScreenTime # Import the specific framework\n\ndef demonstrate_pyobjc_basics():\n    \"\"\"Demonstrates basic PyObjC object creation and method calls.\"\"\"\n    # Example using a common Foundation class\n    now = Foundation.NSDate.date() # Pythonic instantiation (available since PyObjC 10.3)\n    print(f\"Current NSDate object: {now}\")\n    print(f\"Description of NSDate: {now.description()}\")\n\n    # To use ScreenTime, you would typically interact with its specific classes and functions.\n    # For instance, if ScreenTime had a class like 'STConfiguration' (hypothetical example):\n    # try:\n    #     config_manager = ScreenTime.STConfiguration.alloc().init()\n    #     print(f\"ScreenTime configuration manager: {config_manager}\")\n    # except AttributeError:\n    #     print(\"Hypothetical STConfiguration class not found or API not accessible.\")\n\n    print(\"Note: Actual ScreenTime API usage requires specific macOS versions, permissions, and understanding of Apple's documentation.\")\n\nif __name__ == \"__main__\":\n    demonstrate_pyobjc_basics()","lang":"python","description":"This quickstart demonstrates basic object instantiation and method calling using `Foundation.NSDate`, a common pattern applicable across PyObjC frameworks. Specific ScreenTime API usage will follow Apple's Objective-C documentation."},"warnings":[{"fix":"Ensure your Python environment meets the `requires_python` specification (>=3.10 for PyObjC 12.1) before upgrading PyObjC.","message":"PyObjC frequently drops support for older Python versions. PyObjC 12.0 dropped Python 3.9, and PyObjC 11.0 dropped Python 3.8. Always check the `requires_python` metadata or release notes to ensure compatibility with your Python environment.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review custom `init` implementations in Python subclasses of Objective-C objects. PyObjC 10.3 introduced a Pythonic `Class(...)` instantiation pattern that is generally safer and recommended.","message":"PyObjC 11.1 aligned its core bridge with `clang`'s Automatic Reference Counting (ARC) documentation for initializer methods. Methods in the 'init' family now correctly steal a reference to `self` and return a new reference. This changed behavior for `[NSObject alloc]` proxies and can affect custom `init` implementations, potentially leading to crashes if old patterns are used.","severity":"breaking","affected_versions":">=11.1"},{"fix":"When subclassing Objective-C classes, implement Objective-C style `init` methods (e.g., `initWithFoo_:`). If overriding `__new__` in a Python subclass, be aware of the interaction with `__init__` and refer to PyObjC documentation on object instantiation. The Pythonic `Class(...)` instantiation is often a safer alternative.","message":"Version 10.3 initially broke `__init__` usage for Python subclasses of Objective-C classes, particularly when a user implemented `__new__` or when relying on PyObjC's `__new__` behavior. This was partially reverted in 10.3.1 to reintroduce `__init__` support when a user implements `__new__`.","severity":"gotcha","affected_versions":"10.3 - 10.3.1"},{"fix":"Exercise caution when using PyObjC in a free-threaded Python environment (Python 3.13+). Always consult Apple's documentation for the specific framework and classes you are using to understand their thread-safety guarantees.","message":"PyObjC 11.0 introduced experimental support for free-threading (PEP 703) with Python 3.13+. While PyObjC protects its own implementation, Apple's frameworks are not necessarily thread-safe (e.g., `NSMutableArray` for concurrent updates, non-atomic properties, GUI classes on non-main threads).","severity":"gotcha","affected_versions":">=11.0 (with Python 3.13+)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}