<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLLibrary/makeFunction(descriptor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLLibrary(im)newFunctionWithDescriptor:error:"
  },
  "title" : "makeFunction(descriptor:)"
}
-->

# makeFunction(descriptor:)

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

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

## Parameters

`descriptor`

The description of the function object to create.

## Return Value

A new [`MTLFunction`](/documentation/Metal/MTLFunction) instance if the method finds the function in the library;
otherwise Swift throws an error and Objective-C returns `nil`.

## Discussion

---

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)