{"id":6173,"library":"pyobjc-framework-servicemanagement","title":"PyObjC ServiceManagement Framework","description":"pyobjc-framework-servicemanagement provides Python wrappers for Apple's ServiceManagement framework on macOS. This framework offers a secure and object-oriented interface for interacting with `launchd`, primarily used for managing privileged helper tools. The library is actively maintained, with version 12.1 being the current release, and follows a regular release cadence with updates aligning to new macOS SDKs and Python versions.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","cocoa","framework","system services","launchd","automation"],"install":[{"cmd":"pip install pyobjc-framework-servicemanagement","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"},{"reason":"A meta-package that installs pyobjc-core and all available framework wrappers. While not a direct dependency of individual framework packages, it's often installed to get the full suite.","package":"pyobjc","optional":true}],"imports":[{"note":"The ServiceManagement framework and its symbols are typically imported directly under the `ServiceManagement` namespace.","symbol":"ServiceManagement","correct":"import ServiceManagement"}],"quickstart":{"code":"import ServiceManagement\nimport objc\n\n# Example: Accessing a constant from the ServiceManagement framework\n# Note: Actual use of ServiceManagement APIs (e.g., SMJobSubmit, SMJobBless)\n# requires significant macOS-specific setup, including helper executables,\n# entitlements, and proper code signing. This snippet only demonstrates\n# basic framework import and constant access.\n\ntry:\n    # Attempt to access a known constant\n    right_name = ServiceManagement.kSMRightBlessPrivilegedHelper\n    print(f\"ServiceManagement constant kSMRightBlessPrivilegedHelper: {right_name}\")\n\n    # Check for a typical function to ensure framework is loaded\n    if hasattr(ServiceManagement, 'SMJobCopyDictionary'):\n        print(\"ServiceManagement framework appears to be loaded and has SMJobCopyDictionary.\")\n\nexcept objc.nosuchmodule_error:\n    print(\"ServiceManagement framework not found or not importable. This library is macOS-only.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to import the `ServiceManagement` framework and access a common constant. Full utilization of the `ServiceManagement` APIs requires extensive macOS-specific configurations, including setting up privileged helper tools, managing entitlements, and code signing, which are beyond a simple quickstart example."},"warnings":[{"fix":"Upgrade to PyObjC 12.1 (which fixed metadata issues for 3.9 users but still officially drops support) or pin PyObjC to <12 for Python 3.9 environments. Consider upgrading Python to 3.10+.","message":"PyObjC 12.0 dropped support for Python 3.9. Projects requiring Python 3.9 must use PyObjC 11.1 or older.","severity":"breaking","affected_versions":">=12.0"},{"fix":"Upgrade Python to 3.9+ or pin PyObjC to <11 for Python 3.8 environments.","message":"PyObjC 11.0 dropped support for Python 3.8. Projects requiring Python 3.8 must use PyObjC 10.3 or older.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Upgrade to PyObjC 12.1, which corrected the metadata issue. Python 3.9 is still not officially supported by PyObjC 12.x.","message":"PyObjC 12.0 was temporarily yanked from PyPI due to incorrect `python_requires` metadata, erroneously claiming support for Python 3.9. Users attempting to install PyObjC 12.0 on Python 3.9 would encounter build errors.","severity":"breaking","affected_versions":"12.0"},{"fix":"Ensure you are using PyObjC 10.3.1 or later if your code relies on Python subclasses implementing both `__new__` and `__init__`.","message":"The behavior of `__init__` for Python subclasses that also implement `__new__` was changed in PyObjC 10.3, leading to unexpected breakage for some projects. This change was partially reverted in 10.3.1 to reintroduce the ability to use `__init__` when a user implements `__new__`.","severity":"breaking","affected_versions":"10.3"},{"fix":"Ensure the development and deployment environment is macOS. For cross-platform development, consider alternative libraries.","message":"PyObjC is a macOS-specific library and will not function on other operating systems like Linux or Windows.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review custom Python wrappers for Objective-C objects that override `init` methods to ensure they correctly handle reference counting based on ARC semantics.","message":"PyObjC 11.1 aligned the behavior of 'init' family methods (initializers) with Objective-C's Automatic Reference Counting (ARC) semantics. These methods now correctly 'steal' a reference to `self` and return a new retained object, which might affect custom memory management or complex instantiation patterns.","severity":"gotcha","affected_versions":">=11.1"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}