Status quo:
I have an Xcode "Command Line Tool" project written mainly in Swift. In that same project there's a .metal file with some image manipulation code. When I build and archive that project, Xcode produces an executable binary plus a default.metallib
library that is needed to run the executable.
What I want to achieve:
I want Xcode to produce a single executable binary. The default.metallib
should be statically linked.
I tried to add the compiled default.metallib
to "Frameworks and Libraries" in the project "General" settings, which also added that lib to "Link Binary With Libraries" in "Build Phases", but that did nothing.
Is this even possible or do I have a completely wrong idea about the whole workflow?
Status quo:
I have an Xcode "Command Line Tool" project written mainly in Swift. In that same project there's a .metal file with some image manipulation code. When I build and archive that project, Xcode produces an executable binary plus a default.metallib
library that is needed to run the executable.
What I want to achieve:
I want Xcode to produce a single executable binary. The default.metallib
should be statically linked.
I tried to add the compiled default.metallib
to "Frameworks and Libraries" in the project "General" settings, which also added that lib to "Link Binary With Libraries" in "Build Phases", but that did nothing.
Is this even possible or do I have a completely wrong idea about the whole workflow?
Share Improve this question asked Mar 3 at 13:23 limebagellimebagel 213 bronze badges 1- What you want is not to link the metallic file into your executable, which makes no sense, but to embed it. Check out this question stackoverflow/questions/34641373/… – Spo1ler Commented Mar 3 at 16:16
1 Answer
Reset to default 1You cannot link the binary with the .metallib
file, but you could include the Metal shader source in the source code, using a raw string, and create the library with:
func makeLibrary(
source: String,
options: MTLCompileOptions?
) throws -> any MTLLibrary
Reference.