How to determine the current iPhone/device model (swift)

let modelName = UIDevice.current.modelName

Simply just extension in the project and you can use it

import UIKit

public extension UIDevice {

/// pares the deveice name as the standard name
var modelName: String {

#if targetEnvironment(simulator)
let identifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"]!
#else
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)

--

--

iOS Developer, Triple graduated, Passionate, Love workout, blogger

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mr.Javed Multani

iOS Developer, Triple graduated, Passionate, Love workout, blogger