Open dionysuzx opened 5 days ago
I don't have an iphone so I can't fix this bug myself. The code to retrieve the brand of a CPU is here. From what I can see, there seems to be no way to query this information on iOS.
is there anything i can do to help, or run some diagnostics against my iphone? otherwise i can close the issue. i just assumed it worked on iOS
because i saw iOS
was supported under the sysinfo
docs; but i understand iOS may not allow access into this.
You have as much information as I do. So feel free to search around. If you find a fix, please send a PR. :)
adding some more info here. it seems like we cannot fetch the cpu brand() but we may be able to get the device type: and because iOS devices don't have an interchangeable CPU, we can just maintain a mapping of iOS devices to their processors, something like:
func getCPUModel(for identifier: String) -> String? {
let mapping: [String: String] = [
"iPhone14,2": "A16 Bionic",
"iPhone13,2": "A15 Bionic",
"iPad13,4": "M1",
// Add more mappings as needed
]
return mapping[identifier]
}
func getCPUName() -> String? {
var size = 0
sysctlbyname("hw.machine", nil, &size, nil, 0)
var machine = [CChar](repeating: 0, count: size)
sysctlbyname("hw.machine", &machine, &size, nil, 0)
let identifier = String(cString: machine)
return getCPUModel(for: identifier)
}
if let cpuName = getCPUName() {
print("CPU Name: \(cpuName)")
} else {
print("Unknown CPU Model")
}
Oh nice. A PR with this add would be greatly appreciated. :)
Describe the bug
I am running it on an iPhone 15 pro. I'm on:
To Reproduce Try fetch the
brand()
on iOS device like iPhone 15 pro. For example my code snippet here returns empty: