<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLCompileOptions",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(cs)MTLCompileOptions"
  },
  "title" : "MTLCompileOptions"
}
-->

# MTLCompileOptions

Compilation settings for a Metal shader library.

```
class MTLCompileOptions
```

## Overview

You can configure the Metal compiler’s options by setting any or all of an [`MTLCompileOptions`](/documentation/Metal/MTLCompileOptions) instance’s properties, including the following:

- Target previous OS releases by assigning the [`languageVersion`](/documentation/Metal/MTLCompileOptions/languageVersion) property to an [`MTLLanguageVersion`](/documentation/Metal/MTLLanguageVersion) case.
- Set preprocessor macros for the Metal compiler by assigning a dictionary to the [`preprocessorMacros`](/documentation/Metal/MTLCompileOptions/preprocessorMacros) property.
- Choose what the Metal compiler’s optimizer prioritizes by setting the [`optimizationLevel`](/documentation/Metal/MTLCompileOptions/optimizationLevel) property to an [`MTLLibraryOptimizationLevel`](/documentation/Metal/MTLLibraryOptimizationLevel) case.
- Allow the compiler to optimize for floating-point arithmetic that may violate the IEEE 754 standard by setting [`mathMode`](/documentation/Metal/MTLCompileOptions/mathMode) to [`MTLMathMode.fast`](/documentation/Metal/MTLMathMode/fast).

You can compile a library with your compile options instance by calling an [`MTLDevice`](/documentation/Metal/MTLDevice) instance’s [`makeLibrary(source:options:)`](/documentation/Metal/MTLDevice/makeLibrary(source:options:)) or [`makeLibrary(source:options:completionHandler:)`](/documentation/Metal/MTLDevice/makeLibrary(source:options:completionHandler:)) method.

## Topics

### Configuring the compiler options

[`enableLogging`](/documentation/Metal/MTLCompileOptions/enableLogging)

A Boolean value that enables shader logging.

[`mathMode`](/documentation/Metal/MTLCompileOptions/mathMode)

An indication of whether the compiler can perform optimizations for floating-point arithmetic that may violate the IEEE 754 standard.

[`mathFloatingPointFunctions`](/documentation/Metal/MTLCompileOptions/mathFloatingPointFunctions)

The FP32 math functions Metal uses.

[`preserveInvariance`](/documentation/Metal/MTLCompileOptions/preserveInvariance)

A Boolean value that indicates whether the compiler compiles vertex shaders conservatively to generate consistent position calculations.

[`languageVersion`](/documentation/Metal/MTLCompileOptions/languageVersion)

The language version for interpreting the library source code.

[`preprocessorMacros`](/documentation/Metal/MTLCompileOptions/preprocessorMacros)

A list of preprocessor macros to apply when compiling the library source.

[`optimizationLevel`](/documentation/Metal/MTLCompileOptions/optimizationLevel)

An option that tells the compiler what to prioritize when it compiles Metal shader code.

[`libraries`](/documentation/Metal/MTLCompileOptions/libraries)

An array of dynamic libraries the Metal compiler links against.

[`fastMathEnabled`](/documentation/Metal/MTLCompileOptions/fastMathEnabled)

A Boolean value that indicates whether the compiler can perform optimizations for floating-point arithmetic that may violate the IEEE 754 standard.

### Configuring the library output options

[`libraryType`](/documentation/Metal/MTLCompileOptions/libraryType)

The kind of library to create.

[`installName`](/documentation/Metal/MTLCompileOptions/installName)

For a dynamic library, the name to use when installing the library.



---

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)