<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKScene",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKScene"
  },
  "title" : "GKScene"
}
-->

# GKScene

A container for associating GameplayKit objects with a SpriteKit scene.

```
class GKScene
```

## Overview

When you create a scene in the Xcode SpriteKit scene editor, Xcode automatically creates a [`GKScene`](/documentation/GameplayKit/GKScene) object to manage any GameplayKit objects you add to the scene (entities, components, or pathfinding graphs) and archive them alongside the SpriteKit scene content.

To use a SpriteKit scene that contains GameplayKit objects, load the scene file with the [`GKScene`](/documentation/GameplayKit/GKScene) [`init(fileNamed:)`](/documentation/GameplayKit/GKScene/init(fileNamed:)) method. You can then use the [`entities`](/documentation/GameplayKit/GKScene/entities) and [`graphs`](/documentation/GameplayKit/GKScene/graphs) properties to access the [`GKEntity`](/documentation/GameplayKit/GKEntity) (and associated [`GKComponent`](/documentation/GameplayKit/GKComponent)) objects and [`GKGraph`](/documentation/GameplayKit/GKGraph) objects in the scene, and the [`rootNode`](/documentation/GameplayKit/GKScene/rootNode) property to access the scene’s SpriteKit content.

> Note:
> Any SpriteKit node in the scene to which you’ve attached an entity or components automatically has a ``doc://com.apple.gameplaykit/documentation/GameplayKit/GKSKNodeComponent`` object to manage the relationship between the node and the the ``doc://com.apple.gameplaykit/documentation/GameplayKit/GKEntity`` object it represents.

For more information on Entity-Component architecture and pathfinding graphs, see [Entities and Components](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/EntityComponent.html#//apple_ref/doc/uid/TP40015172-CH6) and [Pathfinding](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/Pathfinding.html#//apple_ref/doc/uid/TP40015172-CH3) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Loading a Scene File

[`+  sceneWithFileNamed:`](/documentation/GameplayKit/GKScene/init(fileNamed:))

Loads the specified SpriteKit scene file, creating a [`GKScene`](/documentation/GameplayKit/GKScene) object containing the SpriteKit scene and associated GameplayKit objects.

### Accessing the SpriteKit Scene

[`rootNode`](/documentation/GameplayKit/GKScene/rootNode)

The SpriteKit scene managed by this [`GKScene`](/documentation/GameplayKit/GKScene) object.

### Managing Entities and Components

[`entities`](/documentation/GameplayKit/GKScene/entities)

The list of GameplayKit entities managed by the scene.

[`-  addEntity:`](/documentation/GameplayKit/GKScene/addEntity(_:))

Adds a GameplayKit entity to the list of entities managed by the scene.

[`-  removeEntity:`](/documentation/GameplayKit/GKScene/removeEntity(_:))

Removes a GameplayKit entity from the list of entities managed by the scene.

### Managing Pathfinding Graphs

[`graphs`](/documentation/GameplayKit/GKScene/graphs)

The list of pathfinding graph objects managed by the scene.

[`-  removeGraph:`](/documentation/GameplayKit/GKScene/removeGraph(_:))

Removes a pathfinding graph from the list of graphs managed by the scene.

### Initializers

[`+  sceneWithFileNamed:rootNode:`](/documentation/GameplayKit/GKScene/init(fileNamed:rootNode:))

### Instance Methods

[`-  addGraph:name:`](/documentation/GameplayKit/GKScene/addGraph(_:name:))

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCopying`](/documentation/Foundation/NSCopying)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)