<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/shader-library-and-archive-creation",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Shader library and archive creation"
}
-->

# Shader library and archive creation

Create static and dynamic shader libraries, and binary shader archives.

## Topics

### Creating shader libraries

[`-  newDefaultLibrary`](/documentation/Metal/MTLDevice/makeDefaultLibrary())

Creates a Metal library instance that contains the functions from your app’s default Metal library.

[`-  newDefaultLibraryWithBundle:error:`](/documentation/Metal/MTLDevice/makeDefaultLibrary(bundle:))

Creates a Metal library instance that contains the functions in a bundle’s default Metal library.

[`-  newLibraryWithURL:error:`](/documentation/Metal/MTLDevice/makeLibrary(URL:))

Creates a Metal library instance that contains the functions in the Metal library file at a URL.

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

Synchronously creates a Metal library instance by compiling the functions in a source string.

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

Asynchronously creates a Metal library instance by compiling the functions in a source string.

[`-  newLibraryWithStitchedDescriptor:error:`](/documentation/Metal/MTLDevice/makeLibrary(stitchedDescriptor:))

Synchronously creates a Metal library from the function stitching graphs in a descriptor.

[`-  newLibraryWithStitchedDescriptor:completionHandler:`](/documentation/Metal/MTLDevice/makeLibrary(stitchedDescriptor:completionHandler:))

Asynchronously creates a Metal library from the function stitching graphs in a descriptor.

[`makeLibrary(data:)`](/documentation/Metal/MTLDevice/makeLibrary(data:)-7khmh)

Creates a Metal library instance that contains the functions in a precompiled Metal library.

[`-  newLibraryWithData:error:`](/documentation/Metal/MTLDevice/makeLibrary(data:))

Creates a Metal library instance from a dispatch-data instance that contains the functions in a precompiled Metal library.

[`MTLNewLibraryCompletionHandler`](/documentation/Metal/MTLNewLibraryCompletionHandler)

A completion handler signature a method calls when it finishes creating a Metal library.

[`-  newLibraryWithFile:error:`](/documentation/Metal/MTLDevice/makeLibrary(filepath:))

Creates a Metal library instance that contains the functions in the Metal library file at a file path.

### Creating dynamic shader libraries

[`supportsDynamicLibraries`](/documentation/Metal/MTLDevice/supportsDynamicLibraries)

A Boolean value that indicates whether the GPU device can create and use dynamic libraries in compute pipelines.

[`supportsRenderDynamicLibraries`](/documentation/Metal/MTLDevice/supportsRenderDynamicLibraries)

A Boolean value that indicates whether the GPU device can create and use dynamic libraries in render pipelines.

[`-  newDynamicLibrary:error:`](/documentation/Metal/MTLDevice/makeDynamicLibrary(library:))

Creates a Metal dynamic library instance from a Metal library instance.

[`-  newDynamicLibraryWithURL:error:`](/documentation/Metal/MTLDevice/makeDynamicLibrary(url:))

Creates a Metal dynamic library instance that contains the functions in the Metal library file at a URL.

[`Code`](/documentation/Metal/MTLDynamicLibraryError-swift.struct/Code)

Error codes that Metal can generate when creating dynamic libraries.

[`MTLDynamicLibraryDomain`](/documentation/Metal/MTLDynamicLibraryDomain)

The domain for Metal dynamic library errors.

### Creating binary shader archives

[`-  newBinaryArchiveWithDescriptor:error:`](/documentation/Metal/MTLDevice/makeBinaryArchive(descriptor:))

Creates a Metal binary archive instance.

[`MTLBinaryArchiveDescriptor`](/documentation/Metal/MTLBinaryArchiveDescriptor)

A description of a binary shader archive that you want to create.

[`Code`](/documentation/Metal/MTLBinaryArchiveError-swift.struct/Code)

Error codes when creating binary archives of compiled shader code.

[`MTLBinaryArchiveDomain`](/documentation/Metal/MTLBinaryArchiveDomain)

The domain for Metal binary archive errors.



---

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)