PyObjC ServiceManagement Framework

12.1 · active · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

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.

import ServiceManagement
import objc

# Example: Accessing a constant from the ServiceManagement framework
# Note: Actual use of ServiceManagement APIs (e.g., SMJobSubmit, SMJobBless)
# requires significant macOS-specific setup, including helper executables,
# entitlements, and proper code signing. This snippet only demonstrates
# basic framework import and constant access.

try:
    # Attempt to access a known constant
    right_name = ServiceManagement.kSMRightBlessPrivilegedHelper
    print(f"ServiceManagement constant kSMRightBlessPrivilegedHelper: {right_name}")

    # Check for a typical function to ensure framework is loaded
    if hasattr(ServiceManagement, 'SMJobCopyDictionary'):
        print("ServiceManagement framework appears to be loaded and has SMJobCopyDictionary.")

except objc.nosuchmodule_error:
    print("ServiceManagement framework not found or not importable. This library is macOS-only.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →