{"id":6177,"library":"pyobjc-framework-social","title":"PyObjC Social Framework","description":"PyObjC is a bridge between Python and Objective-C, enabling Python developers to write full-featured Cocoa applications and interact with macOS system frameworks. The `pyobjc-framework-social` package provides Python wrappers for Apple's Social.framework, allowing programmatic access to social media services integrated into macOS, such as sharing content. The library is currently at version 12.1 and typically releases updates in alignment with major macOS SDK changes and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","cocoa","framework","social","objective-c"],"install":[{"cmd":"pip install pyobjc-framework-social","lang":"bash","label":"Install pyobjc-framework-social"}],"dependencies":[{"reason":"Core bridge between Python and Objective-C, required by all PyObjC framework wrappers.","package":"pyobjc-core","optional":false}],"imports":[{"note":"Classes and constants from macOS frameworks are imported directly from their respective PyObjC wrapper packages (e.g., `Social` for Social.framework).","symbol":"SLComposeViewController","correct":"from Social import SLComposeViewController"},{"note":"Framework-defined constants are typically available directly from the wrapper package.","symbol":"SLServiceTypeTwitter","correct":"from Social import SLServiceTypeTwitter"},{"note":"The core PyObjC bridge module for low-level interactions or utility functions.","symbol":"objc","correct":"import objc"}],"quickstart":{"code":"import objc\nfrom Social import SLComposeViewController, SLServiceTypeTwitter, SLServiceTypeFacebook\n\ndef check_social_services():\n    \"\"\"\n    Checks if Twitter and Facebook social services are available on macOS.\n    Note: This example demonstrates basic availability checks without\n    requiring a full NSApplication event loop for UI presentation.\n    \"\"\"\n    # Explicitly load the Social framework if not already done by imports.\n    # This is often implicit but good for clarity in specific cases.\n    objc.loadBundle(\"Social\", globals(), bundle_path=objc.pathForFramework(\"/System/Library/Frameworks/Social.framework\"))\n\n    twitter_available = SLComposeViewController.isAvailableForServiceType_(SLServiceTypeTwitter)\n    facebook_available = SLComposeViewController.isAvailableForServiceType_(SLServiceTypeFacebook)\n\n    print(f\"Twitter service available: {twitter_available}\")\n    print(f\"Facebook service available: {facebook_available}\")\n\nif __name__ == \"__main__\":\n    check_social_services()\n","lang":"python","description":"This quickstart demonstrates how to import and use basic functionality from the `Social` framework to check the availability of social media services (Twitter and Facebook) on macOS. It highlights the direct access to Objective-C classes and their static methods provided by PyObjC. Note that interacting with the UI for composing a post (e.g., displaying `SLComposeViewController`) would require a running `NSApplication` event loop, which is a more involved setup not covered in this minimal example."},"warnings":[{"fix":"Upgrade to a supported Python version (3.10 or newer for PyObjC 12.x).","message":"PyObjC has periodically dropped support for older Python versions. Version 12.0 dropped support for Python 3.9, and version 11.0 dropped support for Python 3.8. Ensure your Python environment meets the `requires_python` specification (>=3.10 for v12.1).","severity":"breaking","affected_versions":"11.0, 12.0"},{"fix":"Review custom Objective-C subclasses and manual memory management code to ensure compatibility with clang's ARC rules for initializers, especially if relying on the old 'partially initialized' state.","message":"Version 11.1 introduced a change in how PyObjC models Automatic Reference Counting (ARC) for Objective-C initializer methods (`init` family). It now correctly reflects that these methods steal a reference to `self` and return a new one, which changed previous behavior where `alloc()` proxies were marked as 'partially initialized'. This may affect custom Objective-C subclasses or complex memory management patterns.","severity":"breaking","affected_versions":">=11.1"},{"fix":"For custom `__new__` in Python subclasses, ensure you call the superclass's `__new__` and then explicitly call `init` methods on the Objective-C object returned. Avoid using `__init__` if `__new__` is not user-defined, or carefully test its interaction.","message":"When subclassing Objective-C classes in Python and providing a custom `__new__` method, using `__init__` had a regression in v10.3. While v10.3.1 restored this functionality for user-defined `__new__` implementations, classes relying on PyObjC's default `__new__` still cannot use `__init__` for initialization.","severity":"gotcha","affected_versions":"10.3"},{"fix":"Always check PyObjC release notes for removed framework bindings, especially when upgrading to versions that support newer macOS SDKs. Migrate away from deprecated macOS frameworks in your applications.","message":"Framework bindings can be removed if the underlying macOS framework is deprecated and removed by Apple. For instance, PyObjC 10.0 removed bindings for the `IMServicePlugIn` framework, as it was deprecated in macOS 10.13 and fully removed in macOS 14.","severity":"breaking","affected_versions":"10.0"},{"fix":"If you have Python-defined subclasses of `NSProxy` and were relying on KVO, be aware that it is now automatically disabled. Consider alternative observation patterns or review your use case.","message":"PyObjC version 12.1 automatically disables Key-Value Observing (KVO) usage for subclasses of `NSProxy` that are defined in Python. This change was implemented to prevent potential `SystemError` issues.","severity":"gotcha","affected_versions":">=12.1"},{"fix":"Install Xcode or the Command Line Tools via `xcode-select --install`. For most users, using binary wheels (`pip install ...`) is the recommended and easier approach as it avoids compiler requirements.","message":"Building PyObjC, including individual framework wrappers like `pyobjc-framework-social`, from source (e.g., with `--no-binary :all:` or from a Git checkout) requires Apple's Xcode or Command Line Tools to be installed. A compatible macOS SDK (ideally the latest or newer than your current OS version) is necessary; using an older SDK may lead to build errors.","severity":"gotcha","affected_versions":"All versions (when building from source)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}