---
title: "makeFunction(descriptor:completionHandler:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtllibrary/makefunction(descriptor:completionhandler:)"
---

# makeFunction(descriptor:completionHandler:)

Asynchronously creates an object representing a shader function, using the specified descriptor.

## Declaration

```swift
func makeFunction(descriptor: MTLFunctionDescriptor, completionHandler: @escaping @Sendable ((any MTLFunction)?, (any Error)?) -> Void)
```

```swift
func makeFunction(descriptor: MTLFunctionDescriptor) async throws -> any MTLFunction
```

## Parameters

- `descriptor`: The description of the function object to create.
- `completionHandler`: A Swift closure or an Objective-C block that Metal calls after it creates the function.

## See Also

### Creating shader function instances

- [makeFunction(name:)](metal/mtllibrary/makefunction(name:).md)
- [makeFunction(name:constantValues:completionHandler:)](metal/mtllibrary/makefunction(name:constantvalues:completionhandler:).md)
- [makeFunction(name:constantValues:)](metal/mtllibrary/makefunction(name:constantvalues:).md)
- [makeFunction(descriptor:)](metal/mtllibrary/makefunction(descriptor:).md)
