macOS command line tool accesses Metal when run from Xcode but not from terminal

I have a cross-platform command-line tool that I can successfully build in Xcode for running on macOS.


On macOS this CLT links to a `dylib` that uses Metal under the covers. The CLT itself does not know about Metal.


I am able to build and successfully run this CLT using an Xcode scheme, but if I then try to run the built CLT directly from the command-line in a terminal, I get the following error when the linked `dylib` attempts to compile a Metal shader for its internal use:


compiler service could not be reached


Any idea why this is happening? Why should it run differently from the terminal than from within Xcode? When run from the terminal, is it possibly not linking to the necessary Metal framework at runtime? And if so, how can that be remedied?

macOS command line tool accesses Metal when run from Xcode but not from terminal
 
 
Q