<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLLibrary/reflection(functionName:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLLibrary(im)reflectionForFunctionWithName:"
  },
  "title" : "reflection(functionName:)"
}
-->

# reflection(functionName:)

Retrieves reflection information for a function in the library.

```
func reflection(functionName: String) -> MTLFunctionReflection?
```

## Parameters

`functionName`

The name of a GPU function in the library.
The name needs to match one of the elements in the string array of library’s [`functionNames`](/documentation/Metal/MTLLibrary/functionNames) property.

## Return Value

An `MTLFunctionReflection` instance when the method succeeds; otherwise `nil`.

## Discussion

The reflection instance contains metadata information about a specific GPU function,
which can include:

- Function parameters
- Return types
- Bindings
- Annotations from a developer, if available

> Note: The Metal compiler generates the function’s reflection information
> when you or Xcode build the library.

The method only returns reflection information if all of the following conditions apply:

- The library has a function with a name that matches `functionName`.
- The deployment target is macOS 13.0 or later, or iOS 16.0 or later, or visionOS 2.0 or later.

---

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)