How to determine the current iPhone/device model?
Asked 07 September, 2021
Viewed 805 times
  • 55
Votes

Is there a way to get the device model name (iPhone 4S, iPhone 5, iPhone 5S, etc) in Swift?

I know there is a property named UIDevice.currentDevice().model but it only returns device type (iPod touch, iPhone, iPad, iPhone Simulator, etc).

I also know it can be done easily in Objective-C with this method:

#import <sys/utsname.h>

struct utsname systemInfo;
uname(&systemInfo);

NSString* deviceModel = [NSString stringWithCString:systemInfo.machine
                          encoding:NSUTF8StringEncoding];

But I'm developing my iPhone app in Swift so could someone please help me with the equivalent way to solve this in Swift?

29 Answer