<!--
{
  "availability" : [
    "Reality Composer Pro: -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ComputeGraph",
  "identifier" : "/documentation/ComputeGraph/ComputeNodeGraph/Library",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Compute Graph",
      "ComputeGraph"
    ],
    "preciseIdentifier" : "s:12ComputeGraph0a4NodeB0V7LibraryC"
  },
  "title" : "ComputeNodeGraph.Library"
}
-->

# ComputeNodeGraph.Library

A class defining a library of node definitions that can be added to a ComputeNodeGraph

```
final class Library
```

## Overview

A Library contains definitions and also stores MTLFunction implementations for
built-in nodes and you can construct new libraries containing nodes you provide.

These nodes are functions implemented using the Metal Shading Language and annotated
with the `[[stitchable]]` attribute.

## Topics

### Initializers

[`init()`](/documentation/ComputeGraph/ComputeNodeGraph/Library/init())

Creates a new empty library.

[`convenience init?(bundle: Bundle)`](/documentation/ComputeGraph/ComputeNodeGraph/Library/init(bundle:))

Creates a library from the Metal default library in the given bundle, if available.

[`convenience init(from: any MTLLibrary, bundleIdentifier: String?)`](/documentation/ComputeGraph/ComputeNodeGraph/Library/init(from:bundleIdentifier:))

Creates a library by extracting node definitions from a Metal library.

### Instance Properties

[`var definitions: [ComputeNodeGraph.NodeDefinition]`](/documentation/ComputeGraph/ComputeNodeGraph/Library/definitions)

The collection of all node definitions available in this library.

### Instance Methods

[`func definition(named: String, in: String?) -> ComputeNodeGraph.NodeDefinition?`](/documentation/ComputeGraph/ComputeNodeGraph/Library/definition(named:in:))

Returns the first node definition with the given name, or `nil` if none is found.

[`func definition(stage: ComputeNodeGraph.Stage) -> ComputeNodeGraph.NodeDefinition?`](/documentation/ComputeGraph/ComputeNodeGraph/Library/definition(stage:))

Returns a definition for the given stage.

[`func definitionsMatching(input: ComputeNodeGraph.ValueType) -> [ComputeNodeGraph.NodeDefinition]`](/documentation/ComputeGraph/ComputeNodeGraph/Library/definitionsMatching(input:))

Returns all definitions that have at least one input matching the given value type.

[`func definitionsMatching(inputs: [ComputeNodeGraph.ValueType]) -> [ComputeNodeGraph.NodeDefinition]`](/documentation/ComputeGraph/ComputeNodeGraph/Library/definitionsMatching(inputs:))

Returns all definitions whose user-editable inputs, in order, match the given value types.

[`func definitionsMatching(output: ComputeNodeGraph.ValueType) -> [ComputeNodeGraph.NodeDefinition]`](/documentation/ComputeGraph/ComputeNodeGraph/Library/definitionsMatching(output:))

Returns all definitions that have at least one output matching the given value type.

[`func merge(contentsOf: ComputeNodeGraph.Library)`](/documentation/ComputeGraph/ComputeNodeGraph/Library/merge(contentsOf:))

Merges nodes from specified library into this library.

### Type Properties

[`static let shared: ComputeNodeGraph.Library`](/documentation/ComputeGraph/ComputeNodeGraph/Library/shared)

## Relationships

### Conforms To

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

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

---

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)