Get system modelId in swift.

extension UIDevice {
    
    /// Return machine model name.
    var machineType: String {
        var systemInfo = utsname()
        uname(&systemInfo)
        let modelType = withUnsafePointer(to: &systemInfo.machine) { body in
            body.withMemoryRebound(to: CChar.self, capacity: 1) { ptr in
                String(validatingUTF8: ptr)
            }
        }
        
        switch modelType {
        case "iPhone10,3", "iPhone10,6": // iPhone X
            return "iPhone X"
        case "iPhone11,8" : // iPhone XR
            return "iPhone X"
        case "iPhone11,2" :// iPhone Xs
            return "iPhone X"
        case "iPhone11,6" : // iPhone Xs Max
            return "iPhone X"
        default:
            return "iPhone"
        }
    }
    
}