How to determine which devices your app is running on

hello.

I'm stuck with a certain problem.

My app is for iPhone, iPad and mac (Designed for iPad). It supports three devices.

I want to distinguish when it runs on a mac.

I used UIDevice.current.userInterfaceIdiom, but it is not differentiated by mac, but by pad.

How can I tell if it's a mac?

Well, there's UIDevice.model, but then you'd need to know all the possible model strings. Also UIKit might lie on a Mac...

The bigger question is - why do you need to know this? What is it about the running on a Mac which should make your app behave differently? You should test for the specific difference, not "is this a Mac", because the specific difference might disappear in iOS 18 or macOS 15.

How to determine which devices your app is running on
 
 
Q