{"id":6160,"library":"pyobjc-framework-replaykit","title":"PyObjC ReplayKit Framework","description":"pyobjc-framework-replaykit provides Python bindings for Apple's ReplayKit framework on macOS, enabling developers to integrate screen recording and broadcasting capabilities into their Python applications. Part of the larger PyObjC project, it closely tracks macOS SDK updates, with current version 12.1. The PyObjC project generally releases new versions multiple times a year, often aligning with major macOS releases and Python version updates.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","framework","replaykit","pyobjc","bindings","screen-recording","objective-c"],"install":[{"cmd":"pip install pyobjc-framework-replaykit","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides the core bridge between Python and Objective-C, essential for all PyObjC framework wrappers. It is implicitly installed as a dependency.","package":"pyobjc-core","optional":false}],"imports":[{"note":"Framework bindings are typically imported directly by their framework name.","symbol":"ReplayKit","correct":"import ReplayKit"}],"quickstart":{"code":"import ReplayKit\nfrom PyObjCTools import AppHelper\nfrom Foundation import NSObject, NSLog\n\nclass ReplayKitChecker(NSObject):\n    def applicationDidFinishLaunching_(self, notification):\n        # Access the shared screen recorder instance\n        recorder = ReplayKit.RPScreenRecorder.sharedRecorder()\n\n        # Check if ReplayKit is available for recording\n        if recorder.isAvailable():\n            NSLog(\"ReplayKit is available for screen recording.\")\n        else:\n            NSLog(\"ReplayKit is not available for screen recording.\")\n\n        # In a real application, you'd perform further ReplayKit actions here\n        # For this quickstart, we just check availability and then stop the application.\n        AppHelper.stopEventLoop()\n\nif __name__ == \"__main__\":\n    # Run a minimal Cocoa event loop to execute the application delegate.\n    # This is often necessary for PyObjC code interacting with UI frameworks.\n    AppHelper.runEventLoop(argv=[], appDelegate=ReplayKitChecker.alloc().init())\n","lang":"python","description":"This example demonstrates how to check if ReplayKit is available for screen recording on the current macOS system. It sets up a minimal `PyObjCTools.AppHelper` event loop, which is often required for PyObjC applications interacting with Cocoa frameworks on the main thread. The `applicationDidFinishLaunching_` method, analogous to `AppDelegate` in Objective-C, is used to interact with the `ReplayKit.RPScreenRecorder` shared instance."},"warnings":[{"fix":"Upgrade your Python interpreter to version 3.10 or later, or use an older PyObjC version (e.g., PyObjC 10.x for Python 3.9, PyObjC 9.x for Python 3.8).","message":"PyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 dropped support for Python 3.8. Ensure your Python environment is 3.10 or newer for PyObjC 12.x.","severity":"breaking","affected_versions":"12.0+"},{"fix":"Review custom initializer methods in your Python classes exposed to Objective-C to ensure correct reference handling, especially if you manually managed `objc_object` reference counts or observed unexpected object lifetimes.","message":"Starting with PyObjC 11.1, the bridge's behavior for initializer methods (like `init`) was aligned with `clang`'s Automatic Reference Counting (ARC) documentation. This means 'init' family methods now correctly steal a reference to `self` and return a new one. Code relying on the prior, less correct, reference counting behavior for initializers might need adjustment.","severity":"gotcha","affected_versions":"11.1+"},{"fix":"If encountering issues with `__init__` not being called, ensure that if your class is an `NSObject` subclass, `__init__` is not called on an instance that was implicitly created via PyObjC's `__new__` mechanism. Consider moving initialization logic to Objective-C style initializer methods (e.g., `initWithSomething_`).","message":"In PyObjC 10.3, a change prevented the use of `__init__` when a class or its superclass utilized `__new__` provided by PyObjC. While version 10.3.1 partially re-enabled `__init__` if the user *explicitly* implemented `__new__`, `__init__` still cannot be used if the class relies on PyObjC's implicit `__new__` for Objective-C object creation.","severity":"gotcha","affected_versions":"10.3 - 10.3.1"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}