---
title: Metal libraries
framework: metal
role: collectionGroup
path: metal/metal-libraries
---

# Metal libraries

Compile and manage Metal libraries from the command line.

## Overview

Overview 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() method of an 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. To distribute GPU-specific binaries and avoid runtime shader compilation, use Metal binary archives.

## Topics

### Working with Metal intermediate representation libraries

- [Building a shader library by precompiling source files](metal/building-a-shader-library-by-precompiling-source-files.md)
- [Minimizing the binary size of a shader library](metal/minimizing-the-binary-size-of-a-shader-library.md)
- [Generating and loading a Metal library symbol file](metal/generating-and-loading-a-metal-library-symbol-file.md)

## See Also

### Shader compilation

- [Metal dynamic libraries](metal/metal-dynamic-libraries.md)
- [Metal binary archives](metal/metal-binary-archives.md)
- [MTL4Compiler](metal/mtl4compiler.md)
- [MTL4CompilerDescriptor](metal/mtl4compilerdescriptor.md)
- [MTL4CompilerTaskOptions](metal/mtl4compilertaskoptions.md)
- [MTL4CompilerTaskStatus](metal/mtl4compilertaskstatus.md)
- [MTL4Archive](metal/mtl4archive.md)
- [MTL4BinaryFunction](metal/mtl4binaryfunction.md)
- [MTL4BinaryFunctionDescriptor](metal/mtl4binaryfunctiondescriptor.md)
- [MTL4BinaryFunctionOptions](metal/mtl4binaryfunctionoptions.md)
- [MTL4PipelineStageDynamicLinkingDescriptor](metal/mtl4pipelinestagedynamiclinkingdescriptor.md)
