{"id":6164,"library":"pyobjc-framework-screencapturekit","title":"PyObjC ScreenCaptureKit Framework Bindings","description":"PyObjC-framework-ScreenCaptureKit provides Python bindings for Apple's ScreenCaptureKit framework on macOS. It enables Python applications to interact with macOS screen recording functionalities. This library is part of the larger PyObjC project, receiving updates in sync with macOS SDK changes and Python versions. The current version is 12.1, released with a focus on macOS SDK updates and Python 3.10+ compatibility.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","cocoa","bindings","screencapture","pyobjc"],"install":[{"cmd":"pip install pyobjc-framework-screencapturekit","lang":"bash","label":"Install ScreenCaptureKit bindings"}],"dependencies":[{"reason":"Core PyObjC bridge functionality","package":"pyobjc-core","optional":false}],"imports":[{"symbol":"ScreenCaptureKit","correct":"import ScreenCaptureKit"},{"symbol":"SCShareableContent","correct":"from ScreenCaptureKit import SCShareableContent"}],"quickstart":{"code":"import ScreenCaptureKit\nfrom Foundation import NSLog, NSDate\nimport objc\n\n# Define a completion handler for the asynchronous call\ndef completion_handler(content, error):\n    if error:\n        NSLog(\"Error getting shareable content: %@\", error)\n    elif content:\n        NSLog(\"Successfully retrieved shareable content:\")\n        NSLog(\"Applications: %s\", content.applications())\n        NSLog(\"Displays: %s\", content.displays())\n        NSLog(\"Windows: %s\", content.windows())\n    else:\n        NSLog(\"No content or error.\")\n\n# Asynchronously get available screen capture content\n# Note: This requires 'Screen Recording' permission in macOS System Settings.\nScreenCaptureKit.SCShareableContent.getShareableContentWithCompletionHandler_(completion_handler)\n\n# Keep the runloop active briefly for the completion handler to execute.\n# In a full Cocoa application, this would be handled by the app's main runloop.\nobjc.currentEventLoop().runUntilDate_(NSDate.dateWithTimeIntervalSinceNow_(2))\n","lang":"python","description":"This quickstart demonstrates how to list available screen capture content (applications, displays, windows) using `SCShareableContent`. Note that running this code requires 'Screen Recording' permissions to be granted to your Python environment in macOS System Settings > Privacy & Security. Asynchronous operations in `ScreenCaptureKit` require the `NSRunLoop` to be active for completion handlers to execute."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or later.","message":"Python 3.9 support was dropped in PyObjC 12.0. PyObjC 11.0 also dropped support for Python 3.8. Ensure your Python version meets the `pyobjc` requirements (currently Python >=3.10).","severity":"breaking","affected_versions":"11.0, 12.0"},{"fix":"Review code involving object creation and initialization, especially where references are passed or returned, to ensure correct memory management under the new ARC semantics.","message":"The core bridge's behavior for initializer methods (e.g., `init` family) was aligned with `clang`'s Automatic Reference Counting documentation. This change in object lifecycle management can cause subtle reference counting issues in existing code that relied on the previous PyObjC behavior.","severity":"breaking","affected_versions":"11.1 and later"},{"fix":"Grant 'Screen Recording' permission to the Python application or terminal running the script in macOS System Settings.","message":"Accessing ScreenCaptureKit functionalities requires explicit 'Screen Recording' permissions in macOS System Settings > Privacy & Security. Without this permission, API calls may return errors or empty results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the application is deployed and run exclusively on macOS environments.","message":"PyObjC, including `ScreenCaptureKit` bindings, is fundamentally a macOS-only library due to its reliance on Apple's Cocoa and Foundation frameworks. It will not run on other operating systems.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If encountering issues, consider using a non-free-threaded Python 3.13 build or a Python 3.12 environment until free-threading support in PyObjC matures.","message":"Free-threading (PEP 703) in Python 3.13 is experimentally supported as of PyObjC 11.0. Older versions (e.g., PyObjC 10.3) explicitly stated no support for it. While experimental support exists, be aware of potential instabilities or unexpected behavior when using PyObjC in a free-threaded Python environment.","severity":"gotcha","affected_versions":"10.3 (no support), 11.x (experimental support)"},{"fix":"Ensure the `NSRunLoop` is active when performing asynchronous operations, either by running an application's main loop or explicitly running `objc.currentEventLoop()` for a duration.","message":"Many ScreenCaptureKit operations are asynchronous, relying on completion handlers or delegates. For these handlers to execute, the macOS `NSRunLoop` must be active. In simple scripts, you might need to manually run `objc.currentEventLoop().runUntilDate_(...)` to allow callbacks to process.","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","problems":[]}