{"id":6175,"library":"pyobjc-framework-sharedwithyoucore","title":"Python Bindings for SharedWithYouCore Framework","description":"PyObjC is a bridge between Python and Objective-C, enabling Python scripts to use and extend Objective-C class libraries on macOS. The `pyobjc-framework-sharedwithyoucore` package provides Python wrappers for Apple's SharedWithYouCore framework, which allows applications to collaborate and share documents directly with Messages, Mail, and FaceTime apps. It is actively maintained, with new releases typically aligning with macOS SDK updates and Python version support. [3, 22]","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macOS","PyObjC","Objective-C","Apple","framework","SharedWithYouCore","interoperability"],"install":[{"cmd":"pip install pyobjc-framework-sharedwithyoucore","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides the core bridge between Python and Objective-C. [21]","package":"pyobjc-core"}],"imports":[{"symbol":"SWCollaborationCoordinator","correct":"from SharedWithYouCore import SWCollaborationCoordinator"},{"symbol":"SWStartCollaborationAction","correct":"from SharedWithYouCore import SWStartCollaborationAction"}],"quickstart":{"code":"from Foundation import NSAutoreleasePool\nfrom SharedWithYouCore import SWCollaborationCoordinator\nimport objc\n\n# PyObjC requires an NSAutoreleasePool for many Cocoa operations\npool = NSAutoreleasePool.alloc().init()\n\ntry:\n    # Get the SWCollaborationCoordinator class\n    CoordinatorClass = SWCollaborationCoordinator\n\n    # Instantiate the coordinator\n    coordinator = CoordinatorClass.alloc().init()\n    \n    print(f\"Successfully instantiated SWCollaborationCoordinator: {coordinator}\")\n    print(f\"Is it an Objective-C object? {isinstance(coordinator, objc.objc_object)}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Release the autorelease pool to clean up Cocoa objects\n    del pool\n","lang":"python","description":"This example demonstrates how to import a class from the `SharedWithYouCore` framework and instantiate a `SWCollaborationCoordinator` object. It also includes the necessary `NSAutoreleasePool` management, which is a common pattern in PyObjC applications. [13, 16]"},"warnings":[{"fix":"Upgrade to `pyobjc-framework-sharedwithyoucore` version 12.1 or higher, or use a supported Python version (3.10+). [2, 17]","message":"Python 3.9 support was dropped in PyObjC 12.0. Version 12.0 incorrectly listed Python 3.9 in its packaging metadata, causing installation failures when building from source. This was corrected in version 12.1. [2, 17]","severity":"breaking","affected_versions":"12.0"},{"fix":"Use Python 3.9 or later with PyObjC 11.x, or Python 3.10 or later with PyObjC 12.x. [2, 6]","message":"PyObjC 11.0 dropped support for Python 3.8. [2]","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review Python classes subclassing Objective-C objects, especially those with custom `__init__` or `__new__` methods. Ensure `__new__` is explicitly defined if `__init__` is used, or adapt to the Objective-C two-phase instantiation model (`alloc().init()`) directly. [12, 30]","message":"PyObjC 10.3 introduced a change that broke `__init__` when `__new__` was *not* explicitly implemented in Python classes. Version 10.3.1 partially reverted this, allowing `__init__` when `__new__` is user-implemented. However, classes relying on PyObjC's default `__new__` still cannot use `__init__` in the same way. [2, 27]","severity":"gotcha","affected_versions":"10.3 - 10.3.1"},{"fix":"Carefully review Apple's documentation for thread-safety of specific framework classes. Use `performSelectorOnMainThread_` or similar mechanisms for GUI updates. Implement explicit `NSAutoreleasePool` creation and drainage in non-main threads. [1, 11]","message":"While PyObjC supports free-threading (experimental in Python 3.13), Apple's Cocoa frameworks are generally not thread-safe. Many GUI elements and certain Core Foundation types require interaction on the main thread. Always manage `NSAutoreleasePool`s explicitly in new threads. [1, 11]","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review code that directly manipulates or relies on the exact reference count behavior of objects returned from `alloc()` prior to `init()` calls, as the handling of 'partially initialized' objects has been rearchitected. [2]","message":"PyObjC 11.1 aligned its core bridge behavior for Automatic Reference Counting (ARC) with `clang`'s documentation, specifically for initializer methods (e.g., `init` family). This means methods in the 'init' family now correctly steal a reference to `self` and return a new reference, changing the proxy behavior for `[NSObject alloc]`. [2]","severity":"breaking","affected_versions":">=11.1"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}