---
title: MTLLibrary
framework: metal
role: symbol
role_heading: Protocol
path: metal/mtllibrary
---

# MTLLibrary

A collection of Metal shader functions.

## Declaration

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

## Mentioned in

Building a shader library by precompiling source files Logging shader debug messages

## Overview

Overview An 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 protocol. To create an MTLLibrary from a precompiled Metal library binary, call one of these MTLDevice methods: makeDefaultLibrary() makeLibrary(filepath:) makeLibrary(data:) To create an MTLLibrary by compiling source code at runtime, call one of these MTLDevice methods: makeLibrary(source:options:completionHandler:) makeLibrary(source:options:)

## Topics

### Querying basic library attributes

- [installName](metal/mtllibrary/installname.md)
- [type](metal/mtllibrary/type.md)

### Querying library contents

- [functionNames](metal/mtllibrary/functionnames.md)

### Creating shader function instances

- [makeFunction(name:)](metal/mtllibrary/makefunction(name:).md)
- [makeFunction(name:constantValues:completionHandler:)](metal/mtllibrary/makefunction(name:constantvalues:completionhandler:).md)
- [makeFunction(name:constantValues:)](metal/mtllibrary/makefunction(name:constantvalues:).md)
- [makeFunction(descriptor:completionHandler:)](metal/mtllibrary/makefunction(descriptor:completionhandler:).md)
- [makeFunction(descriptor:)](metal/mtllibrary/makefunction(descriptor:).md)

### Creating intersection function instances

- [makeIntersectionFunction(descriptor:completionHandler:)](metal/mtllibrary/makeintersectionfunction(descriptor:completionhandler:).md)
- [makeIntersectionFunction(descriptor:)](metal/mtllibrary/makeintersectionfunction(descriptor:).md)

### Identifying the library

- [device](metal/mtllibrary/device.md)
- [label](metal/mtllibrary/label.md)

### Instance Methods

- [reflection(functionName:)](metal/mtllibrary/reflection(functionname:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Shader library management

- [MTLDynamicLibrary](metal/mtldynamiclibrary.md)
- [MTLBinaryArchive](metal/mtlbinaryarchive.md)
- [MTLCompileOptions](metal/mtlcompileoptions.md)
- [MTLLibraryType](metal/mtllibrarytype.md)
- [MTLLanguageVersion](metal/mtllanguageversion.md)
- [MTLCompileSymbolVisibility](metal/mtlcompilesymbolvisibility.md)
- [MTLLibraryOptimizationLevel](metal/mtllibraryoptimizationlevel.md)
