PyObjC GameSave Framework
pyobjc-framework-gamesave provides Python bindings for Apple's macOS GameSave framework. It is part of the larger PyObjC bridge, which allows Python scripts to use and extend Objective-C class libraries, primarily the Cocoa frameworks. The library is actively maintained, with releases frequently aligning with new macOS SDK versions, and its current version is 12.1.
Warnings
- breaking PyObjC 12.0 (which introduced `pyobjc-framework-gamesave`) dropped support for Python 3.9. Users on Python 3.9 or older must use an earlier PyObjC version or upgrade Python.
- breaking PyObjC 11.0 dropped support for Python 3.8. Ensure your Python environment is 3.9 or later if using PyObjC 11.x, or 3.10+ for 12.x.
- gotcha `pyobjc-framework-gamesave` bindings were first introduced in PyObjC version 12.0. This package is not available for PyObjC versions older than 12.0.
- gotcha PyObjC 12.0 incorrectly indicated support for Python 3.9 in its packaging metadata. This was fixed in PyObjC 12.1.
- gotcha PyObjC's handling of `__init__` when a user implements `__new__` changed in v10.3, then partially reverted in v10.3.1. If you are subclassing Objective-C classes in Python and using custom `__new__`, be aware of potential breakage around object initialization.
- gotcha Experimental free-threading (PEP 703) in Python 3.13 is not fully supported by PyObjC 10.3. While experimental support was introduced in PyObjC 11.0, significant changes were required in the core. Exercise caution if using PyObjC with free-threaded Python 3.13.
Install
-
pip install pyobjc-framework-gamesave
Imports
- GSGameSaveManager
from GameSave import GSGameSaveManager
Quickstart
from GameSave import GSGameSaveManager
from Foundation import NSObject # Common base class for Objective-C objects
def main():
print('Attempting to interact with GSGameSaveManager...')
# In Objective-C, objects are typically allocated then initialized.
# PyObjC follows this pattern for many Cocoa classes.
try:
manager = GSGameSaveManager.alloc().init()
print(f'Successfully initialized GSGameSaveManager: {manager.description()}.')
# Further GameSave API calls would go here.
# Example: manager.loadGameSavesWithCompletionHandler_(...)
except Exception as e:
print(f'Error initializing GSGameSaveManager: {e}')
print('Note: GameSave framework might require specific application entitlements or context.')
if __name__ == '__main__':
# For Cocoa applications, an event loop is often required.
# For simple script usage, direct execution might suffice or need AppKit integration.
# import AppKit
# AppKit.NSApplication.sharedApplication()
# main()
# AppKit.NSApp.run()
main()