UIDeviceHardware is a class originally created in a gist by Jaybles. It allows querying of the current users device, and returns a human formatted string.
It is written as a class method, to allow use without direct instantiation.
I don't use this helper much anymore, so I'm not keeping up to date with device models. While I welcome Pull Requests to update the model, I'd recommend moving over to something more modern, like DeviceKit.
// "iPhone 5C (GSM)"
NSString *platformString = [UIDeviceHardware platformString];
// "iPhone 5C"
NSString *simpleString = [UIDeviceHardware platformStringSimple];
This class can be installed with Swift Package Manager, Cocoapods, or by directly copying the files into your source code.
Add the package to your Package.swift file:
dependencies: [
.package(url: "https://github.com/squarefrog/UIDeviceIdentifier", .upToNextMajor(from: "1.7.0"))
],
Then import as follows:
// ObjC
@import UIDeviceIdentifier;
// Swift
import UIDeviceIdentifier
Add the cocoapod to your Podfile:
pod 'UIDeviceIdentifier', :git => 'https://github.com/squarefrog/UIDeviceIdentifier.git'
Import the file into your Objective-C file:
// ObjC
#import <UIDeviceIdentifier/UIDeviceHardware.h>
Copy UIDeviceHardware.{h/m}
into your project. Then just import the header:
#import "UIDeviceHardware.h"
UIDeviceHardware is available under the MIT licence. See the LICENCE file for more info.