{"id":6136,"library":"pyobjc-framework-mediatoolbox","title":"PyObjC MediaToolbox Framework","description":"PyObjC provides Python bindings for Objective-C frameworks on macOS, enabling Python developers to interact with Apple's system APIs. `pyobjc-framework-mediatoolbox` offers wrappers for the MediaToolbox framework, which supports media format readers and audio processing. 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","PyObjC","frameworks","MediaToolbox","bindings","media"],"install":[{"cmd":"pip install pyobjc-framework-mediatoolbox","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core bridge for Python to Objective-C, implicitly required by all PyObjC framework bindings.","package":"pyobjc-core"}],"imports":[{"symbol":"MediaToolbox","correct":"import MediaToolbox"}],"quickstart":{"code":"import MediaToolbox\nimport Foundation\n\n# Simply importing the framework demonstrates it's loadable.\n# Accessing a generic Objective-C class (e.g., NSObject from Foundation)\n# via any PyObjC framework binding confirms the bridge is working.\n\n# In a real application, you would access MediaToolbox-specific classes or functions\n# e.g., MediaToolbox.MTAudioProcessingTapCreate\n# or constants like kCMFormatDescriptionBridgeError_InvalidParameter if exposed via MediaToolbox or an imported dependency.\n\nprint(f\"MediaToolbox module loaded from: {MediaToolbox.__file__}\")\n\n# Verify that basic PyObjC functionality is available by accessing NSObject\n# which is part of Foundation, implicitly loaded or linked by most PyObjC frameworks.\nif hasattr(Foundation, 'NSObject'):\n    print(f\"Foundation.NSObject available, indicating PyObjC bridge is active.\")\nelse:\n    print(\"Foundation.NSObject not found, PyObjC bridge might not be fully active.\")","lang":"python","description":"This quickstart demonstrates successful installation and basic import of the `MediaToolbox` framework, confirming the PyObjC bridge is active. Real-world usage would involve interacting with specific classes and functions provided by Apple's MediaToolbox framework."},"warnings":[{"fix":"Always check the `requires_python` metadata or release notes to ensure compatibility with your Python environment. For PyObjC 12.1, Python >=3.10 is required.","message":"PyObjC frequently drops support for older Python versions. PyObjC 12.0 dropped Python 3.9, and PyObjC 11.0 dropped Python 3.8.","severity":"breaking","affected_versions":"11.0, 12.0+"},{"fix":"Review custom `init` implementations in Python subclasses of Objective-C objects. Ensure they correctly handle reference counting semantics, which typically means calling the superclass initializer and returning `self`.","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 can alter memory management behavior for Python subclasses overriding Objective-C initializers.","severity":"breaking","affected_versions":"11.1+"},{"fix":"If overriding `__new__` in a Python subclass of an Objective-C object, ensure `__init__` is correctly handled, particularly when upgrading from PyObjC 10.3. Refer to PyObjC documentation on object instantiation and consider using Objective-C style `init` methods (e.g., `initWithFoo_:`) for robustness.","message":"PyObjC 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"},{"fix":"If your application relied on `IMServicePlugIn` bindings, you must refactor your code as the underlying framework is no longer available in modern macOS versions.","message":"In PyObjC 10.0, the `IMServicePlugIn` bindings were removed as the entire framework was deprecated in macOS 10.13 and removed in macOS 14.","severity":"breaking","affected_versions":"10.0+"},{"fix":"When using free-threading, carefully review thread safety considerations for all interactions with Apple's Objective-C frameworks. Synchronize access to shared mutable Objective-C objects as needed.","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"}