In migrating custom Core Image filter kernels to Metal Shading Language, I encountered an error with building the default Metal library (default.metallib):
metallib: error: exactly one input file required
I was under the impression these could be in separate .metal files. Attempting to merge them into one file leads to this error:
Metal library creation failed: Error Domain=MTLLibraryErrorDomain Code=3 "Filters module must contain no vertex/fragment/kernel functions but contains 1 kernel function"
Namespacing to metal and to coreimage prevent the compute kernel from showing up as an available function in the default library.
Found this SO answer, which recommends building separate libraries:
 
                        
You can’t use the default Metal build pipeline for compiling multiple
.metalfiles containing Core Image kernels into one library right now. The linker doesn’t allow merging multiple.airfiles into one.metallibwhen setting the-cikernelflag.You either have to put all your kernels into one
.metalfile or use the solution I posted in the answer you linked to above.