PyObjC GameKit Framework

12.1 · active · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

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.

import Foundation

# Basic Objective-C object creation using the PyObjC bridge
my_string = Foundation.NSString.stringWith_("Hello from PyObjC!")
print(f"Created NSString: {my_string}")
print(f"Type of my_string: {type(my_string)}")

# To interact with the GameKit framework, you would import it similarly:
try:
    import GameKit
    print("GameKit imported successfully.")
    # Example: Accessing a GameKit class (this shows access, but doesn't 'do' anything game-related)
    _ = GameKit.GKMatch
    print(f"Accessed GameKit.GKMatch class.")
except ImportError:
    print("GameKit framework not available or could not be imported.")
except Exception as e:
    print(f"Error accessing GameKit: {e}")

# For applications needing an event loop (e.g., actual GUI or complex GameKit interactions),
# PyObjCTools.AppHelper.runEventLoop() is typically used, but requires a full application context.
# This example just demonstrates basic object interaction and framework import.

view raw JSON →