<!--
{
  "availability" : [
    "iOS: 8.0.0 - 16.0.0",
    "iPadOS: 8.0.0 - 16.0.0",
    "macCatalyst: 13.1.0 - 16.0.0",
    "macOS: 10.11.0 - 13.0.0",
    "tvOS: -",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLDevice/makeLibrary(filepath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLDevice(im)newLibraryWithFile:error:"
  },
  "title" : "makeLibrary(filepath:)"
}
-->

# makeLibrary(filepath:)

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

```
func makeLibrary(filepath: String) throws -> any MTLLibrary
```

## Parameters

`filepath`

A string of the absolute file path to a Metal library file (ending in `.metallib`).

## Return Value

A new [`MTLLibrary`](/documentation/Metal/MTLLibrary) instance if the method completes successfully;
otherwise Swift throws an error and Objective-C returns `nil`.

## Discussion

---

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)