How to load a metallib into Xcode?
12:55 27 Dec 2025

After reading all documentations and posts I could find, I absolutely do not understand how this works.

I have a metallib file that i compiled following the Apple's documentation: works fine, compiling this using CLion, works fine.

Now i need to compile and build this in XCode to eventually get this on the store, but I failed all approaches to do so.

1- Using a post build copy command to copy the metallib to the asset folder of the app:

This doesn't work because xcode complains that file isn't signed, getting the error: "code object is not signed at all"

If i sign the file prior to building, it doesn't work as the copy command seem to lose the signature, i do not understand that process.

2- Adding a MetalLibrary in my target:

Added a "Test" library with nothing in it, just to test. It compiles, but then, using once again the Apple documentation https://developer.apple.com/documentation/metal/building-a-shader-library-by-precompiling-source-files?language=objc here, i'm doing a:

    NSURL *libraryURL = [[NSBundle mainBundle] URLForResource:@"Test"
                                                withExtension:@"metallib"];

But the URL is nil, as it can't find it.

I do not understand where is that library located ?

Would that also mean that i need to copy paste all my metallib shader code into that new "Test" library ?

Is there a way to add an external metallib to xcode ?

What would be the URL to load it from then ?

xcode metal