---
title: "makeLibrary(data:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtldevice/makelibrary(data:)-7khmh"
---

# makeLibrary(data:)

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

## Declaration

```swift
func makeLibrary(data: DispatchData) throws -> any MTLLibrary
```

## Parameters

- `data`: The data from a precompiled Metal library. For more information, see doc://com.apple.metal/documentation/Metal/building-a-shader-library-by-precompiling-source-files.

## Return Value

Return Value A new MTLLibrary instance if the method completes successfully; otherwise Swift throws an error and Objective-C returns nil.

## Discussion

Discussion Use this method if your application manages its own archiving system for libraries — for example, if your app uses a single file that contains several libraries. note: This is a Swift default implementation for the makeLibrary(data:) method.

## See Also

### Creating shader libraries

- [makeDefaultLibrary()](metal/mtldevice/makedefaultlibrary().md)
- [makeDefaultLibrary(bundle:)](metal/mtldevice/makedefaultlibrary(bundle:).md)
- [makeLibrary(URL:)](metal/mtldevice/makelibrary(url:).md)
- [makeLibrary(source:options:)](metal/mtldevice/makelibrary(source:options:).md)
- [makeLibrary(source:options:completionHandler:)](metal/mtldevice/makelibrary(source:options:completionhandler:).md)
- [makeLibrary(stitchedDescriptor:)](metal/mtldevice/makelibrary(stitcheddescriptor:).md)
- [makeLibrary(stitchedDescriptor:completionHandler:)](metal/mtldevice/makelibrary(stitcheddescriptor:completionhandler:).md)
- [makeLibrary(data:)](metal/mtldevice/makelibrary(data:).md)
- [MTLNewLibraryCompletionHandler](metal/mtlnewlibrarycompletionhandler.md)
- [makeLibrary(filepath:)](metal/mtldevice/makelibrary(filepath:).md)
