Exclude metal files from simulator build

I'm working on an app that includes some Metal code, when building for the simulator we stub out the parts that need Metal using #if targetEnvironment(simulator), which works fine by itself


However, the simulator build still fails on trying to compile the .metal file itself, as there is no metal compiler for the simulator. Since there is no need to compile the Metal file for the simulator, I would like to remove the .metal file from the build in case we're building for the simulator, so we can test the rest of the app on the simulator using stubs for our metal code.


Is there a way to exclude metal files from the build when building for a simulator ?

Are you saying that by doing stub outs your app runs ok on a device, or the app is immediately crippled?


According to Simulator Help, "The Metal, MetalKit, and Metal Performance Shaders frameworks are provided only as stubs. Calls to functions in these frameworks have no effect."


Which I take to mean you aren't required to cut them manually...but if that means you end up w/a borked app, then you may need to effort a simulator-only version, sans metal entirely.

Exclude metal files from simulator build
 
 
Q