Compilation settings for a Metal shader library.


@interface MTLCompileOptions : NSObject


Use a MTLCompileOptions object to specify how a new Metal shader library should be compiled. If you want to set the following options, use standard allocation and initialization techniques to create a MTLCompileOptions object and then set any or all of these properties:

  • To allow the compiler to perform optimizations for floating-point arithmetic that may violate the IEEE 754 standard, set fastMathEnabled to YES.

  • To target previous OS releases, set languageVersion to a supported Metal shading language version.

  • Set preprocessorMacros to a list of preprocessor macros to be considered when compiling this code.

The MTLCompileOptions object is used with either the newLibraryWithSource:options:error: or newLibraryWithSource:options:completionHandler: method of MTLDevice to compile shading language functions into a new library.


Specifying Compiler Options


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


The language version used to interpret the library source code.


Metal shading language versions.


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


Inherits From

Conforms To

See Also


Understanding the Metal Shading Language Filename Extension

Use the .metal filename extension to gain access to Metal's build, profile, and debug tools.

Building a Library with Metal's Command-Line Tools

Use command-line tools to run the Metal compiler toolchain.


A collection of Metal shader functions.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software