{"id":6156,"library":"pyobjc-framework-photosui","title":"PyObjC PhotosUI Framework","description":"pyobjc-framework-photosui provides Python bindings for Apple's PhotosUI framework on macOS, allowing Python developers to interact with system-level Photos user interface components. It is part of the larger PyObjC project, which acts as a bridge between Python and Objective-C. The library is actively maintained, with version 12.1 being the latest stable release, and it generally releases new versions in conjunction with major macOS SDK updates.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macOS","Objective-C","Cocoa","UI","framework","Apple"],"install":[{"cmd":"pip install pyobjc-framework-photosui","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides the core bridge between Python and Objective-C, essential for all PyObjC framework wrappers.","package":"pyobjc-core","optional":false}],"imports":[{"note":"The PhotosUI framework is exposed directly as a Python package.","symbol":"PhotosUI","correct":"import PhotosUI"}],"quickstart":{"code":"import PhotosUI\nimport Foundation\nimport AppKit\n\n# Most PhotosUI interactions require a running Cocoa application.\n# This snippet demonstrates basic import and class access.\n# For a functional UI example, a full PyObjC app setup with NSApplication is required.\n\ndef main():\n    # Initialize a basic NSApplication (required for most Cocoa frameworks)\n    app = AppKit.NSApplication.sharedApplication()\n    \n    # Access a PhotosUI class to confirm the framework is loaded\n    try:\n        # PHLivePhotoView is a common PhotosUI class introduced in iOS/macOS 10.11\n        _ = PhotosUI.PHLivePhotoView\n        print(\"Successfully imported PhotosUI and accessed PHLivePhotoView.\")\n    except AttributeError:\n        print(\"Could not access PHLivePhotoView. Ensure macOS version supports PhotosUI and PyObjC is correctly installed.\")\n    \n    # Note: A real PhotosUI application would involve delegates, windows, and an event loop.\n    # app.run() # This would start the GUI event loop, blocking further execution.\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to import the `PhotosUI` framework and access a class within it. Most `PhotosUI` functionalities require a running Cocoa application, typically managed via `AppKit.NSApplication`. This snippet initializes the shared application (without starting its run loop) and attempts to access `PHLivePhotoView` to confirm the bindings are loaded. Full UI interactions would require more extensive setup."},"warnings":[{"fix":"Upgrade to Python 3.10 or later for PyObjC 12.x, or Python 3.9 or later for PyObjC 11.x. Always use a Python version supported by your PyObjC version.","message":"Python 3.9 support was dropped in PyObjC 12.0. Python 3.8 support was dropped in PyObjC 11.0.","severity":"breaking","affected_versions":"11.0, 12.0"},{"fix":"Existing code should review object instantiation patterns, especially custom subclasses of Objective-C classes, to ensure correct reference handling, though PyObjC manages most ARC complexities internally. This primarily affects advanced users subclassing Objective-C objects.","message":"PyObjC 11.1 aligned the core bridge's behavior 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.","severity":"breaking","affected_versions":"11.1 and later"},{"fix":"If implementing `__new__` in a Python subclass of an Objective-C class, ensure `__init__` is not called if `__new__` is meant to handle object initialization entirely, or structure your class hierarchy to avoid conflicts. Refer to PyObjC documentation on object instantiation.","message":"The interaction between Python's `__init__` and `__new__` methods when subclassing Objective-C classes changed in PyObjC 10.3, leading to breakage for some projects. While partially reverted in 10.3.1, code relying on `__new__` provided by PyObjC cannot use `__init__`.","severity":"breaking","affected_versions":"10.3, 10.3.1"},{"fix":"Migrate away from IMServicePlugIn to current Apple APIs if your application relies on this functionality. This warning is specific to the `pyobjc-framework-IMServicePlugIn` package, but is a relevant major version change within the broader PyObjC ecosystem.","message":"The 'IMServicePlugIn' framework bindings were removed in PyObjC 10.0 as the framework itself was deprecated in macOS 10.13 and removed in macOS 14.","severity":"deprecated","affected_versions":"10.0 and later"},{"fix":"Run `xcode-select --install` in your terminal to ensure the command line tools are present.","message":"PyObjC requires the Xcode Command Line Tools to be installed on macOS for building and sometimes even for installation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When `ClassName(...)` doesn't work as expected, explicitly use `ClassName.alloc().init(...)` or `ClassName.alloc().initWithArgument(...)` patterns. Consult Apple's Objective-C documentation for the specific class's initialization methods.","message":"Objective-C object instantiation is a two-step process (`alloc()` then `init...()`). While PyObjC allows calling the class directly for many cases, understanding this underlying mechanism is crucial for complex or custom object creation.","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":[]}