{"id":6111,"library":"pyobjc-framework-gamekit","title":"PyObjC GameKit Framework","description":"PyObjC is a bridge between Python and Objective-C, allowing Python scripts to use and extend existing Objective-C class libraries, including macOS frameworks. The `pyobjc-framework-gamekit` package provides Python wrappers for the GameKit framework on macOS, enabling Python applications to leverage GameKit functionalities. It is currently at version 12.1 and is actively maintained with releases often tied to macOS SDK updates.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","gamekit","framework","apple","gui"],"install":[{"cmd":"pip install pyobjc-framework-gamekit","lang":"bash","label":"Install PyObjC GameKit"}],"dependencies":[{"reason":"The core bridging library between Python and Objective-C.","package":"pyobjc-core","optional":false},{"reason":"Common runtime dependency for many PyObjC applications interacting with macOS frameworks.","package":"pyobjc-framework-cocoa","optional":true}],"imports":[{"note":"GameKit classes are imported directly from the 'GameKit' package.","symbol":"GKMatch","correct":"from GameKit import GKMatch"},{"note":"Many PyObjC applications also interact with the foundational 'Foundation' framework.","symbol":"NSString","correct":"from Foundation import NSString"}],"quickstart":{"code":"import Foundation\n\n# Basic Objective-C object creation using the PyObjC bridge\nmy_string = Foundation.NSString.stringWith_(\"Hello from PyObjC!\")\nprint(f\"Created NSString: {my_string}\")\nprint(f\"Type of my_string: {type(my_string)}\")\n\n# To interact with the GameKit framework, you would import it similarly:\ntry:\n    import GameKit\n    print(\"GameKit imported successfully.\")\n    # Example: Accessing a GameKit class (this shows access, but doesn't 'do' anything game-related)\n    _ = GameKit.GKMatch\n    print(f\"Accessed GameKit.GKMatch class.\")\nexcept ImportError:\n    print(\"GameKit framework not available or could not be imported.\")\nexcept Exception as e:\n    print(f\"Error accessing GameKit: {e}\")\n\n# For applications needing an event loop (e.g., actual GUI or complex GameKit interactions),\n# PyObjCTools.AppHelper.runEventLoop() is typically used, but requires a full application context.\n# This example just demonstrates basic object interaction and framework import.","lang":"python","description":"This quickstart demonstrates how to import and interact with basic Objective-C objects via the PyObjC bridge, and how GameKit classes would be imported. Full GameKit functionality typically requires a complete macOS application context, which is beyond a simple script."},"warnings":[{"fix":"Upgrade Python to version 3.10 or newer, or use an older PyObjC version compatible with your Python runtime.","message":"PyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 dropped support for Python 3.8. Ensure your Python version is 3.10 or higher for PyObjC 12.x.","severity":"breaking","affected_versions":"11.0, 12.0+"},{"fix":"Review Python subclasses of Objective-C classes for `__init__` and `__new__` interactions. For new code, prefer the `SomeClass(...)` instantiation pattern introduced in 10.4. For existing code, ensure `__new__` is explicitly implemented if `__init__` is used, or adapt to the new instantiation rules.","message":"In PyObjC 10.3, the behavior around `__init__` and `__new__` for Python subclasses of Objective-C classes changed significantly, potentially breaking existing code. While 10.3.1 partially reintroduced `__init__` support when `__new__` is implemented by the user, code relying on PyObjC's `__new__` cannot use `__init__`. PyObjC 10.4 introduced a more Pythonic instantiation interface, making `SomeClass(...)` equivalent to `SomeClass.alloc().init...()`.","severity":"breaking","affected_versions":"10.3, 10.3.1, 10.4+"},{"fix":"If your code directly interacts with the `alloc().init...()` pattern and relies on specific reference counting behavior during object initialization, review against ARC principles. The new behavior is generally more correct but might impact custom memory management or complex initialization chains.","message":"PyObjC 11.1 aligned its behavior for initializer methods (those in the 'init' family) with `clang`'s Automatic Reference Counting (ARC) documentation. This means `init` methods now correctly steal a reference to `self` and return a new reference, changing previous `[NSObject alloc]` proxy behavior.","severity":"breaking","affected_versions":"11.1+"},{"fix":"Avoid using PyObjC in Python 3.13 environments where the experimental free-threading mode is enabled, as it is not officially supported.","message":"While PyObjC 10.3 and later may have binary wheels for Python 3.13, PyObjC does *not* currently support the experimental free-threading feature (PEP 703) in Python 3.13.","severity":"gotcha","affected_versions":"10.3+"},{"fix":"Upgrade to PyObjC 10.1 or newer to ensure correct `os.fspath` behavior with Cocoa URLs. For older versions, explicitly convert `NSURL` to a Python path string if needed.","message":"Prior to PyObjC 10.1, `os.fspath(someURL)` would not correctly handle Cocoa URLs (`NSURL`, `CFURLRef`) referring to local filesystem paths, raising `TypeError` for other URLs. This was fixed in 10.1.","severity":"gotcha","affected_versions":"< 10.1"},{"fix":"Upgrade to PyObjC 12.1 or newer to ensure correct KVO behavior with Python subclasses of `NSProxy`.","message":"Before PyObjC 12.1, there was an issue where Key-Value Observing (KVO) usage for subclasses of `NSProxy` defined in Python was not automatically disabled, which has since been fixed.","severity":"gotcha","affected_versions":"< 12.1"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}