Skip to content

Commit

Permalink
Switched source for device model information on iOS (#350)
Browse files Browse the repository at this point in the history
* Make `shared()` public.

* Switched source for device model info.
  • Loading branch information
bsneed authored May 16, 2024
1 parent 44cab1e commit 945bddc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Sources/Segment/Plugins/Platforms/Vendors/AppleUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ internal class iOSVendorSystem: VendorSystem {
}

private func deviceModel() -> String {
var name: [Int32] = [CTL_HW, HW_MACHINE]
var size: Int = 2
sysctl(&name, 2, nil, &size, nil, 0)
var hw_machine = [CChar](repeating: 0, count: Int(size))
sysctl(&name, 2, &hw_machine, &size, nil, 0)
let model = String(cString: hw_machine)
return model
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
return identifier
}
}

Expand Down

0 comments on commit 945bddc

Please sign in to comment.