{"id":2702,"library":"pyobjc-framework-cocoa","title":"PyObjC Framework - Cocoa","description":"PyObjC-framework-Cocoa provides Python wrappers for the core Cocoa frameworks on macOS, including CoreFoundation, Foundation, and AppKit. It acts as a bidirectional bridge, enabling Python developers to leverage Objective-C libraries and build full-featured macOS applications. Version 12.1 is currently available, with the project demonstrating active and sustainable maintenance, receiving regular updates.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","cocoa","gui","objective-c","bridge"],"install":[{"cmd":"pip install pyobjc-framework-cocoa","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Provides the core Python-Objective-C bridge functionality upon which all framework wrappers are built.","package":"pyobjc-core","optional":false}],"imports":[{"note":"Imports the Foundation framework, providing basic Objective-C classes like NSObject, NSDate, etc.","symbol":"Foundation","correct":"import Foundation"},{"note":"Imports the AppKit framework, essential for building macOS graphical user interfaces.","symbol":"AppKit","correct":"import AppKit"},{"note":"Imports the core PyObjC bridge module, providing utilities and decorators like objc.IBOutlet and objc.IBAction.","symbol":"objc","correct":"import objc"},{"note":"Provides various utility functions and classes for PyObjC development, such as AppHelper for running Cocoa event loops.","symbol":"PyObjCTools","correct":"from PyObjCTools import AppHelper"}],"quickstart":{"code":"import Foundation\nimport objc\n\ndef main():\n    print(f\"Current date and time: {Foundation.NSDate.date()}\")\n    Foundation.NSLog(\"Hello from PyObjC!\")\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"This simple example demonstrates importing and using a basic class (NSDate) and a function (NSLog) from the Foundation framework, showing direct interaction with Objective-C APIs via PyObjC."},"warnings":[{"fix":"Upgrade Python to 3.10 or a newer supported version (e.g., `pyenv install 3.10.x` and `pyenv local 3.10.x`).","message":"PyObjC 12.0 dropped support for Python 3.9. Ensure your Python environment is 3.10 or later.","severity":"breaking","affected_versions":"12.0 and later"},{"fix":"Upgrade Python to 3.9 or a newer supported version.","message":"PyObjC 11.0 dropped support for Python 3.8. Python 3.9 and later were supported in this version.","severity":"breaking","affected_versions":"11.0 and later"},{"fix":"Migrate away from the `IMServicePlugIn` framework to supported macOS APIs if your application relies on instant messaging services.","message":"The `IMServicePlugIn` framework bindings were removed in PyObjC 10.0, as the framework was deprecated in macOS 10.13 and removed in macOS 14.","severity":"breaking","affected_versions":"10.0 and later"},{"fix":"Review classes with custom `__new__` and `__init__` for compatibility; avoid using `__init__` for classes relying on the default PyObjC `__new__`.","message":"Changes in PyObjC 10.3 initially prevented the use of `__init__` when a user implemented `__new__`. While partially re-enabled in 10.3.1 for custom `__new__` implementations, classes relying on the `__new__` provided by PyObjC still cannot use `__init__`.","severity":"breaking","affected_versions":"10.3, 10.3.1"},{"fix":"Applications interacting with Objective-C initializer methods may need to review their memory management assumptions, though for most Python users, this change makes PyObjC more compliant with underlying Objective-C semantics.","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 reference.","severity":"breaking","affected_versions":"11.1 and later"},{"fix":"Replace Python lists with `NSMutableArray` and Python dicts with `NSMutableDictionary` for KVO-observed attributes.","message":"Key-Value Observing (KVO) with Python collections (lists, dictionaries) is not automatically supported. For instance variables that will be observed and contain a sequence or mapping, use `NSMutableArray` or `NSMutableDictionary` instances instead of Python lists or dictionaries.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install Xcode Command Line Tools by running `xcode-select --install` in the terminal.","message":"Developing PyObjC applications requires Xcode Command Line Tools to be installed on macOS for building and compilation.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}