{"id":6064,"library":"pyobjc-framework-accounts","title":"PyObjC Accounts Framework","description":"pyobjc-framework-accounts provides Python bindings for Apple's Accounts framework on macOS. It allows Python applications to access and manage user accounts stored in System Preferences, such as social media, mail, and other internet accounts. The library is part of the larger PyObjC project, which acts as a bridge between Python and Objective-C, and is regularly updated to align with the latest macOS SDKs. The current version is 12.1.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","cocoa","apple","framework","accounts"],"install":[{"cmd":"pip install pyobjc-framework-accounts","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides the core Python to Objective-C bridge functionality, required by all PyObjC framework bindings.","package":"pyobjc-core"}],"imports":[{"note":"Framework bindings are typically imported as a package with the same name as the macOS framework.","symbol":"Accounts","correct":"import Accounts"}],"quickstart":{"code":"import Accounts\nimport objc\n\n# Initialize the ACAccountStore, the primary entry point for the Accounts framework.\n# Note: Actual account access (e.g., requesting permissions, fetching accounts)\n# often requires a running NSApplication event loop and user interaction on macOS.\n# This example demonstrates basic object creation and type identification.\naccount_store = Accounts.ACAccountStore.alloc().init()\nprint(f\"Initialized ACAccountStore object: {account_store}\")\n\n# Get an account type identifier, e.g., for Twitter\ntwitter_type_identifier = Accounts.ACAccountTypeIdentifierTwitter\nprint(f\"Twitter Account Type Identifier: {twitter_type_identifier}\")\n\n# Retrieve the ACAccountType object for Twitter\ntwitter_account_type = account_store.accountTypeWithIdentifier_(twitter_type_identifier)\nif twitter_account_type:\n    print(f\"Retrieved ACAccountType for Twitter: {twitter_account_type.identifier()}\")\nelse:\n    print(f\"Could not retrieve ACAccountType for identifier: {twitter_type_identifier}\")\n\n# To request access or fetch accounts, you would typically use a completion handler\n# and potentially an active NSApplication runloop in a full Cocoa application.\n# For example (illustrative, not fully runnable without more setup):\n# import Foundation\n# account_store.requestAccessToAccountsWithType_options_completion_(\n#     twitter_account_type,\n#     None, # A Python dict for options, or None\n#     lambda granted, error: Foundation.NSLog(f\"Access granted: {granted}, Error: {error}\")\n# )\n","lang":"python","description":"This quickstart demonstrates how to import the `Accounts` framework and initialize the core `ACAccountStore` object, which is the entry point for interacting with user accounts. It also shows how to retrieve a specific account type. Note that actual access to user accounts and handling asynchronous operations (like requesting access) typically requires a more complete PyObjC/Cocoa application setup with a running event loop, and will often involve user prompts for permission."},"warnings":[{"fix":"Upgrade your Python environment to a version supported by the latest PyObjC, or pin your PyObjC version to one that supports your Python version.","message":"PyObjC versions frequently drop support for older Python versions to align with active Python releases and macOS SDKs. For example, PyObjC 12.0 dropped support for Python 3.9, and 11.0 dropped Python 3.8. Ensure your Python version is compatible with the PyObjC version you are using.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review classes that implement `__new__` or rely on PyObjC's default `__new__` to ensure `__init__` usage is compatible with PyObjC 10.3+ semantics.","message":"PyObjC 10.3 introduced a change where `__init__` could no longer be used when `__new__` was provided by PyObjC. While 10.3.1 partially restored this for classes with user-implemented `__new__`, code relying on `__new__` provided by PyObjC still cannot use `__init__`.","severity":"breaking","affected_versions":"10.3 - 10.3.1"},{"fix":"Developers working with custom Objective-C classes in Python should be aware of ARC rules for initializers and adjust reference counting expectations if manually managing memory or observing unexpected deallocations.","message":"PyObjC 11.1 aligned its behavior with `clang`'s Automatic Reference Counting (ARC) documentation for initializer methods. Methods in the 'init' family now correctly steal a reference to `self` and return a new one, which might change memory management expectations for custom Objective-C classes bridged to Python.","severity":"breaking","affected_versions":">=11.1"},{"fix":"If you have Python subclasses of `NSProxy` that previously relied on KVO, you may need to implement manual observation mechanisms or reconsider the class design, as automatic KVO will no longer function.","message":"Starting with PyObjC 12.1, Key-Value Observing (KVO) usage is automatically disabled for subclasses of `NSProxy` defined in Python to prevent `SystemError`.","severity":"gotcha","affected_versions":">=12.1"},{"fix":"Ensure that if you are using `os.fspath()` with Cocoa URLs, they specifically refer to local filesystem paths. Handle `TypeError` for non-local URLs or use appropriate Cocoa methods for URL manipulation.","message":"In PyObjC 10.1, the `os.fspath()` function was updated to work with Cocoa URLs (`NSURL`, `CFURLRef`) that refer to local filesystem paths. It will now raise a `TypeError` for other types of URLs, enabling more robust use of Python's filesystem APIs with Cocoa URLs.","severity":"gotcha","affected_versions":">=10.1"},{"fix":"Applications relying on `IMServicePlugIn` bindings must update their functionality to use alternative macOS APIs or adjust for the framework's deprecation and removal.","message":"The `IMServicePlugIn` framework bindings were removed in PyObjC 10.0 because the underlying macOS framework was deprecated in macOS 10.13 and completely removed in macOS 14.","severity":"breaking","affected_versions":">=10.0"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}