<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/metal-libraries",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Metal libraries"
}
-->

# Metal libraries

Compile and manage Metal libraries from the command line.

## Discussion

By default, your Metal shaders compile as a format called *Metal intermediate representation* (Metal IR), a GPU-independent bytecode. At your app’s runtime, Metal compiles this bytecode to a GPU-specific binary for the host device. If you provide your shader functions as strings, they first compile to Metal IR on device, and then go through a secondary compilation for GPU.

Metal source files you add to an app’s source compilation Build Phase compile to a Metal IR library named `default.metallib`. Load this library at runtime by calling the [`makeDefaultLibrary()`](/documentation/Metal/MTLDevice/makeDefaultLibrary()) method of an [`MTLDevice`](/documentation/Metal/MTLDevice) in your app. For more complicated projects, you may want to create individual targets for Metal libraries, modify them in build scripts, or perform other optimizations.

Compilation of Metal IR completes before executing a shader function call. When your library consists of utility functions that other shaders use, use [Metal dynamic libraries](/documentation/Metal/metal-dynamic-libraries). To distribute GPU-specific binaries and avoid runtime shader compilation, use [Metal binary archives](/documentation/Metal/metal-binary-archives).

## Topics

### Working with Metal intermediate representation libraries

[Building a shader library by precompiling source files](/documentation/Metal/building-a-shader-library-by-precompiling-source-files)

Create a shader library that you can add to an Xcode project with the Metal compiler tools in a command-line environment.

[Minimizing the binary size of a shader library](/documentation/Metal/minimizing-the-binary-size-of-a-shader-library)

Reduce the storage footprint of your shaders, and potentially reduce their compile time, by selecting the Metal compiler’s size optimization option.

[Generating and loading a Metal library symbol file](/documentation/Metal/generating-and-loading-a-metal-library-symbol-file)

Debug your Metal shaders from your production apps by
creating companion symbol files at compile time and loading them at debug time.



---

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)