<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ShaderLibrary",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13ShaderLibraryV"
  },
  "title" : "ShaderLibrary"
}
-->

# ShaderLibrary

A Metal shader library.

```
@dynamicMemberLookup struct ShaderLibrary
```

## Topics

### Getting the default shader library

[`default`](/documentation/SwiftUI/ShaderLibrary/default)

The default shader library of the main (i.e. app) bundle.

[`bundle(_:)`](/documentation/SwiftUI/ShaderLibrary/bundle(_:))

Returns the default shader library of the specified bundle.

### Creating a shader library

[`init(url:)`](/documentation/SwiftUI/ShaderLibrary/init(url:))

Creates a new Metal shader library from the contents of `url`,
which must be the location  of precompiled Metal library.
Functions compiled from the returned library will only be
cached as long as the returned library exists.

[`init(data:)`](/documentation/SwiftUI/ShaderLibrary/init(data:))

Creates a new Metal shader library from `data`, which must be
the contents of precompiled Metal library. Functions compiled
from the returned library will only be cached as long as the
returned library exists.

### Access shader functions

[`subscript(dynamicMember:)`](/documentation/SwiftUI/ShaderLibrary/subscript(dynamicMember:)-swift.type.subscript)

Returns a new shader function representing the stitchable MSL
function called `name` in the default shader library.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

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)