Compiling and running the metal examples

2019-04-20 14:48发布

问题:

It has been a while since I have used XCode, but since Apple revieled XCode 6 and the new Metal API I had to check it out.

They have released examples, e.g. a converted version of their Basic3D example. I am having problems making them compile and run, though. I had to add paths the Quatz and Metal frameworks for compilation and linking to work - thought that should have worked out of the box with build-in libraries?

Also the metal shader compilation step fails, it can not find the metal compiler. Where in XCode is that path setup?

If I ignore the shader compilation step I get an error that the application will not run on any of the simulators. Can metal based 3D applications only run on actual hardware and not in simulator mode?

回答1:

You can't run metal on simulator but you can use this workaround so that it will still compile as long as you have a fallback for the code.

http://medium.com/@jscampbell/bare-metal-working-with-metal-and-the-simulator-70e085e3a45



回答2:

According to a staff on Apple dev forums, Metal does not run in the simulator.

See: https://devforums.apple.com/message/971605#971605

If you look at other samples/app templates there is no need to explicitly link any framework, indeed everything runs out of the box.



回答3:

I started with the hello triangle example they give you to download. It contains all the platform #if's you need to know about. I recommend you get that project and take a look.

https://developer.apple.com/documentation/metal/hello_triangle

#if TARGET_OS_SIMULATOR
#error No simulator support for Metal API.  Must build for a device
#endif


标签: ios xcode6 metal