Left as an exercise
Left as an exercise

Reputation: 517

Accessing a custom Metal library from another project

I am looking to create my own Metal library target in Xcode. The makeLibrary(filepath:) described here requires a file with the .metallib extension. Do I have to create the .metallib file manually using each of the metal files in the Metal library target as described here and load it at runtime? Or can I embed it somehow in my app to allow the shaders to be compiled at compile time? The first strategy seems inefficient, and there must be some use for the target.

Upvotes: 0

Views: 504

Answers (1)

Frank Rupprecht
Frank Rupprecht

Reputation: 10383

I did not find a better way to tell Xcode to embed the metallib into my other target (in my case a framework), so I set up a custom build phase in my framework target to copy the library like this:

enter image description here

I also added the Metal library target as a dependency to my framework target to ensure that it's always built first.

Upvotes: 2

Related Questions