PyObjC-framework-gameplaykit provides Python bindings for Apple's GameplayKit framework on macOS. It enables Python applications to leverage game development utilities, including random number generation, pathfinding, AI behaviors, and more, directly from Python. The current version is 12.1, with releases generally aligning with macOS SDK updates.
pip install pyobjc-framework-gameplaykitVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use a basic GameplayKit feature, `GKARC4RandomSource`, to generate random numbers and shuffle arrays. It highlights the `alloc().init()` pattern for Objective-C object instantiation via PyObjC.
Upgrade to Python 3.10 or newer, or pin pyobjc-framework-gameplaykit to an older version compatible with your Python environment.
Review code that directly calls `alloc().init()` or other `init` family methods, especially if custom memory management or unusual object lifecycles are involved. Most high-level usage should be unaffected.
Avoid using PyObjC with Python 3.13's experimental free-threading features until explicitly announced as stable. If free-threading is critical, consider using PyObjC 12.x or later with a Python version where free-threading is stable, or use traditional threading models.
If experiencing issues with `__init__` not being called, ensure your class or its superclasses provide a custom `__new__` if you intend to use `__init__`. Otherwise, adapt your object initialization to Objective-C patterns (e.g., using factory methods or designated initializers).
If you need to work with `NSURL` objects that might not represent local filesystem paths, avoid `os.fspath()`. Use `NSURL`'s methods (e.g., `absoluteString()`, `path()`) or convert to a Python string explicitly, verifying it's a local path first if needed.