It's good that you are looking for something specific for Metal - as a rule, iOS version checks and hardware name checks are fragile because they rely on your application to know all versions of the OS and devices that could ever run it. If Apple came back and released an iOS 7.x version that added Metal support (well, it seems unlikely), or a device that supports Metal, but is not one of the hardware names that you are looking at (it seems much more likely ).), you will be stuck with the need to track all of these things and update your application to manage them.
In any case, the best way to check if the device you are running on is enough for your awesome graphics code? Just try to get the MTLDevice object:
id<MTLDevice> device = MTLCreateSystemDefaultDevice(); if (device) {
Please note that just checking for the presence of the Metal Framework class does not help - these classes are on any device running iOS 8 (up to iPhone 4s and iPad 2), regardless of whether this device has Metal support. GPU
In Simulator Metal, it has been supported since iOS 13 / tvOS 13 on macOS 10.15. Use the same strategy: call MTLCreateSystemDefaultDevice() . If it returns an object, then your simulator code works in an environment where the simulator accelerates hardware. If it returns nil then you are working on an older simulator or in an environment where Metal is not available.
source share