Dynamically compile shader and access it through SwiftUI's ShaderLibrary

Is it possible to dynamically compile a shader (at runtime) using something like MTLDevices makeLibrary, and convert that over to a SwiftUI ShaderLibrary?

In theory it looks like it should be possible - ShaderLibrary can be initialised with a data parameter which according to the docs is a compiled shader library, but I'm not sure how I'd go about converting a MTLLibrary to data.

Is this possible at all?

Dynamically compile shader and access it through SwiftUI's ShaderLibrary
 
 
Q