Right now we only return the model name when running the Swift SDK in macOS. Instead, it should return the hardware identifier.
Using IOKit:
public func getMacModel() -> String? {
let service = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching("IOPlatformExpertDevice"))
var modelIdentifier: String?
if let modelData = IORegistryEntryCreateCFProperty(service, "model" as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data {
if let modelIdentifierCString = String(data: modelData, encoding: .utf8)?.cString(using: .utf8) {
modelIdentifier = String(cString: modelIdentifierCString)
}
}
IOObjectRelease(service)
return modelIdentifier
}
This will have to be gated with "if OS macOS" calls, so that the SDK still compiles for iOS and Linux.
Right now we only return the model name when running the Swift SDK in macOS. Instead, it should return the hardware identifier.
Using IOKit:
This will have to be gated with "if OS macOS" calls, so that the SDK still compiles for iOS and Linux.