---
title: MTLCompileOptions
framework: metal
role: symbol
role_heading: Class
path: metal/mtlcompileoptions
---

# MTLCompileOptions

Compilation settings for a Metal shader library.

## Declaration

```swift
class MTLCompileOptions
```

## Mentioned in

Logging shader debug messages Minimizing the binary size of a shader library

## Overview

Overview You can configure the Metal compiler’s options by setting any or all of an MTLCompileOptions instance’s properties, including the following: Target previous OS releases by assigning the languageVersion property to an MTLLanguageVersion case. Set preprocessor macros for the Metal compiler by assigning a dictionary to the preprocessorMacros property. Choose what the Metal compiler’s optimizer prioritizes by setting the optimizationLevel property to an MTLLibraryOptimizationLevel case. Allow the compiler to optimize for floating-point arithmetic that may violate the IEEE 754 standard by setting mathMode to MTLMathMode.fast. You can compile a library with your compile options instance by calling an MTLDevice instance’s makeLibrary(source:options:) or makeLibrary(source:options:completionHandler:) method.

## Topics

### Configuring the compiler options

- [enableLogging](metal/mtlcompileoptions/enablelogging.md)
- [mathMode](metal/mtlcompileoptions/mathmode.md)
- [mathFloatingPointFunctions](metal/mtlcompileoptions/mathfloatingpointfunctions.md)
- [preserveInvariance](metal/mtlcompileoptions/preserveinvariance.md)
- [languageVersion](metal/mtlcompileoptions/languageversion.md)
- [preprocessorMacros](metal/mtlcompileoptions/preprocessormacros.md)
- [optimizationLevel](metal/mtlcompileoptions/optimizationlevel.md)
- [libraries](metal/mtlcompileoptions/libraries.md)
- [fastMathEnabled](metal/mtlcompileoptions/fastmathenabled.md)

### Configuring the library output options

- [libraryType](metal/mtlcompileoptions/librarytype.md)
- [installName](metal/mtlcompileoptions/installname.md)

### Instance Properties

- [allowReferencingUndefinedSymbols](metal/mtlcompileoptions/allowreferencingundefinedsymbols.md)
- [compileSymbolVisibility](metal/mtlcompileoptions/compilesymbolvisibility.md)
- [maxTotalThreadsPerThreadgroup](metal/mtlcompileoptions/maxtotalthreadsperthreadgroup.md)
- [requiredThreadsPerThreadgroup](metal/mtlcompileoptions/requiredthreadsperthreadgroup.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Shader library management

- [MTLLibrary](metal/mtllibrary.md)
- [MTLDynamicLibrary](metal/mtldynamiclibrary.md)
- [MTLBinaryArchive](metal/mtlbinaryarchive.md)
- [MTLLibraryType](metal/mtllibrarytype.md)
- [MTLLanguageVersion](metal/mtllanguageversion.md)
- [MTLCompileSymbolVisibility](metal/mtlcompilesymbolvisibility.md)
- [MTLLibraryOptimizationLevel](metal/mtllibraryoptimizationlevel.md)
