{"id":6163,"library":"pyobjc-framework-scenekit","title":"PyObjC SceneKit Framework","description":"PyObjC is the bridge between Python and the Objective-C programming language, used to develop applications for macOS. This specific package, `pyobjc-framework-scenekit` (currently at version 12.1), provides Python wrappers for Apple's SceneKit framework, enabling 3D graphics and game development. PyObjC generally follows the macOS SDK release cycle for updates.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","gui","framework","scenekit","3d","apple","objective-c"],"install":[{"cmd":"pip install pyobjc-framework-scenekit","lang":"bash","label":"Install only SceneKit bindings"},{"cmd":"pip install 'pyobjc[allbindings]'","lang":"bash","label":"Install core PyObjC and all framework bindings"}],"dependencies":[{"reason":"The core PyObjC bridge is required for all framework bindings.","package":"pyobjc","optional":false}],"imports":[{"note":"Provides access to all SceneKit classes, functions, and constants, e.g., SceneKit.SCNView, SceneKit.SCNScene.","symbol":"SceneKit","correct":"import SceneKit"},{"note":"Required for basic macOS application structure like windows and application loops.","symbol":"Cocoa","correct":"from Cocoa import NSApplication, NSWindow, NSView"},{"note":"Utility for managing the Cocoa application event loop.","symbol":"AppHelper","correct":"from PyObjCTools import AppHelper"}],"quickstart":{"code":"import SceneKit\nfrom Cocoa import NSApplication, NSWindow, NSView, NSRect, NSMakeRect\nfrom PyObjCTools import AppHelper\nimport objc\n\nclass AppDelegate(objc.NSObject):\n    def applicationDidFinishLaunching_(self, aNotification):\n        print(\"SceneKit app launched!\")\n\n        # Create a window\n        rect = NSMakeRect(100, 100, 640, 480)\n        self.window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(\n            rect, \n            (1 << 0) | (1 << 1) | (1 << 2), # NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable\n            2, # NSBackingStoreBuffered\n            False\n        )\n        self.window.setTitle_(\"PyObjC SceneKit Cube\")\n        \n        # Create an SCNView (SceneKit view)\n        self.scnView = SceneKit.SCNView.alloc().initWithFrame_(rect)\n        self.window.setContentView_(self.scnView)\n\n        # Create a scene\n        scene = SceneKit.SCNScene.scene()\n        self.scnView.setScene_(scene)\n\n        # Create a camera and add it to a node\n        camera = SceneKit.SCNCamera.camera()\n        cameraNode = SceneKit.SCNNode.node()\n        cameraNode.setCamera_(camera)\n        cameraNode.setPosition_(SceneKit.SCNVector3(0, 0, 15))\n        scene.rootNode().addChildNode_(cameraNode)\n        self.scnView.setPointOfView_(cameraNode)\n\n        # Create a light and add it to a node\n        light = SceneKit.SCNLight.light()\n        light.setType_(SceneKit.SCNLightTypeOmni)\n        lightNode = SceneKit.SCNNode.node()\n        lightNode.setLight_(light)\n        lightNode.setPosition_(SceneKit.SCNVector3(0, 10, 10))\n        scene.rootNode().addChildNode_(lightNode)\n\n        # Create an ambient light\n        ambientLight = SceneKit.SCNLight.light()\n        ambientLight.setType_(SceneKit.SCNLightTypeAmbient)\n        ambientLight.setColor_(SceneKit.SCNColor.colorWithRed_green_blue_alpha_(0.1, 0.1, 0.1, 1.0))\n        ambientLightNode = SceneKit.SCNNode.node()\n        ambientLightNode.setLight_(ambientLight)\n        scene.rootNode().addChildNode_(ambientLightNode)\n\n        # Create a cube geometry\n        box = SceneKit.SCNBox.boxWithWidth_height_length_chamferRadius_(5.0, 5.0, 5.0, 0.5)\n        boxNode = SceneKit.SCNNode.nodeWithGeometry_(box)\n        scene.rootNode().addChildNode_(boxNode)\n        \n        # Allow the user to manipulate the camera\n        self.scnView.setAllowsCameraControl_(True)\n\n        self.window.makeKeyAndOrderFront_(None)\n\ndef main():\n    app = NSApplication.sharedApplication()\n    delegate = AppDelegate.alloc().init()\n    app.setDelegate_(delegate)\n    AppHelper.runEventLoop()\n\nif __name__ == '__main__':\n    main()\n","lang":"python","description":"This quickstart code initializes a basic macOS application window and embeds an SCNView. It then sets up a SceneKit scene with a camera, lights, and a simple rotating cube, allowing user camera control. The `AppHelper.runEventLoop()` ensures the Cocoa application event loop is started and managed."},"warnings":[{"fix":"Upgrade your Python installation to 3.10 or a newer supported version.","message":"Python 3.9 support was dropped in PyObjC 12.0. Ensure your Python environment is 3.10 or later.","severity":"breaking","affected_versions":">=12.0"},{"fix":"Upgrade your Python installation to 3.9 or a newer supported version.","message":"Python 3.8 support was dropped in PyObjC 11.0. Ensure your Python environment is 3.9 or later.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review code that relies on precise reference counting for 'init' methods. In most cases, this change aligns with expected Objective-C behavior and should not require manual adjustments unless managing references explicitly.","message":"PyObjC 11.1 changed how it models initializer methods ('init' family) to align with Clang's Automatic Reference Counting (ARC) documentation. Methods in the 'init' family now correctly steal a reference to `self` and return a new one.","severity":"gotcha","affected_versions":">=11.1"},{"fix":"Ensure `__init__` is used correctly with `__new__` implementations, or avoid using `__init__` for classes relying on PyObjC's default `__new__`.","message":"In PyObjC 10.3, support for calling `__init__` on Python classes that implement `__new__` was temporarily broken, then partially reintroduced in 10.3.1. If a class or its superclass has a user-implemented `__new__`, `__init__` can be used. Otherwise, if relying on PyObjC's `__new__`, `__init__` cannot be used.","severity":"gotcha","affected_versions":"10.3 - 10.3.1"},{"fix":"If you are subclassing `NSProxy` in Python and relying on KVO, be aware that it will be automatically disabled. Consider alternative observation patterns or verify behavior.","message":"PyObjC 12.1 automatically disables Key-Value Observing (KVO) usage for subclasses of `NSProxy` defined in Python to fix `SystemError` issues.","severity":"gotcha","affected_versions":">=12.1"},{"fix":"Use alternative methods for vector manipulation or handle vector data manually where these specific types are involved. The `objc.simd` package may offer some related functionality but direct SceneKit binding limitations remain.","message":"SceneKit methods that expect or return `vector_float3` or `vector_float4` arguments are not fully available from Python due to limitations in PyObjC's core bridge. This includes `SCNVector3ToFloat3` and `SCNVector3FromFloat3`.","severity":"gotcha","affected_versions":"all"},{"fix":"Consult Apple's developer documentation (e.g., via Xcode or online) for `SceneKit` classes and methods when working with `pyobjc-framework-scenekit`.","message":"PyObjC framework wrappers, including SceneKit, do not include their own documentation. Refer to Apple's official SceneKit documentation for API details and usage.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}