Python Bindings for SharedWithYouCore Framework

12.1 · active · verified Tue Apr 14

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]

Warnings

Install

Imports

Quickstart

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]

from Foundation import NSAutoreleasePool
from SharedWithYouCore import SWCollaborationCoordinator
import objc

# PyObjC requires an NSAutoreleasePool for many Cocoa operations
pool = NSAutoreleasePool.alloc().init()

try:
    # Get the SWCollaborationCoordinator class
    CoordinatorClass = SWCollaborationCoordinator

    # Instantiate the coordinator
    coordinator = CoordinatorClass.alloc().init()
    
    print(f"Successfully instantiated SWCollaborationCoordinator: {coordinator}")
    print(f"Is it an Objective-C object? {isinstance(coordinator, objc.objc_object)}")

except Exception as e:
    print(f"An error occurred: {e}")
finally:
    # Release the autorelease pool to clean up Cocoa objects
    del pool

view raw JSON →