<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLLibrary",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLLibrary"
  },
  "title" : "MTLLibrary"
}
-->

# MTLLibrary

A collection of Metal shader functions.

```
protocol MTLLibrary : NSObjectProtocol, Sendable
```

## Overview

An [`MTLLibrary`](/documentation/Metal/MTLLibrary) instance contains Metal shading language source code compiled during an app’s build process or at runtime from a text string.

Don’t implement this protocol yourself; instead, use the library creation methods provided by the [`MTLDevice`](/documentation/Metal/MTLDevice) protocol. To create an [`MTLLibrary`](/documentation/Metal/MTLLibrary) from a precompiled Metal library binary, call one of these [`MTLDevice`](/documentation/Metal/MTLDevice) methods:

- [`makeDefaultLibrary()`](/documentation/Metal/MTLDevice/makeDefaultLibrary())
- [`makeLibrary(filepath:)`](/documentation/Metal/MTLDevice/makeLibrary(filepath:))
- [`makeLibrary(data:)`](/documentation/Metal/MTLDevice/makeLibrary(data:))

To create an [`MTLLibrary`](/documentation/Metal/MTLLibrary) by compiling source code at runtime, call one of these [`MTLDevice`](/documentation/Metal/MTLDevice) methods:

- [`makeLibrary(source:options:completionHandler:)`](/documentation/Metal/MTLDevice/makeLibrary(source:options:completionHandler:))
- [`makeLibrary(source:options:)`](/documentation/Metal/MTLDevice/makeLibrary(source:options:))

## Topics

### Querying basic library attributes

[`installName`](/documentation/Metal/MTLLibrary/installName)

The installation name for a dynamic library.

[`type`](/documentation/Metal/MTLLibrary/type)

The library’s basic type.

### Querying library contents

[`functionNames`](/documentation/Metal/MTLLibrary/functionNames)

The names of all public functions in the library.

### Creating shader function instances

[`makeFunction(name:)`](/documentation/Metal/MTLLibrary/makeFunction(name:))

Creates an instance that represents a shader function in the library.

[`makeFunction(name:constantValues:completionHandler:)`](/documentation/Metal/MTLLibrary/makeFunction(name:constantValues:completionHandler:))

Asynchronously creates a specialized shader function.

[`makeFunction(name:constantValues:)`](/documentation/Metal/MTLLibrary/makeFunction(name:constantValues:))

Synchronously creates a specialized shader function.

[`makeFunction(descriptor:completionHandler:)`](/documentation/Metal/MTLLibrary/makeFunction(descriptor:completionHandler:))

Asynchronously creates an object representing a shader function, using the specified descriptor.

[`makeFunction(descriptor:)`](/documentation/Metal/MTLLibrary/makeFunction(descriptor:))

Synchronously creates an object representing a shader function, using the specified descriptor.

### Creating intersection function instances

[`makeIntersectionFunction(descriptor:completionHandler:)`](/documentation/Metal/MTLLibrary/makeIntersectionFunction(descriptor:completionHandler:))

Asynchronously creates an object representing a ray-tracing intersection function,
using the specified descriptor.

[`makeIntersectionFunction(descriptor:)`](/documentation/Metal/MTLLibrary/makeIntersectionFunction(descriptor:))

Synchronously creates an object representing a ray-tracing intersection function, using the specified descriptor.

### Identifying the library

[`device`](/documentation/Metal/MTLLibrary/device)

The Metal device object that created the library.

[`label`](/documentation/Metal/MTLLibrary/label)

A string that identifies the library.



---

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)