Browse Source

iOS: Return the device model name from SystemStats::getDeviceDescription() when running in the simulator

tags/2021-05-28
ed 6 years ago
parent
commit
1bc7fdd1ec
1 changed files with 19 additions and 2 deletions
  1. +19
    -2
      modules/juce_core/native/juce_mac_SystemStats.mm

+ 19
- 2
modules/juce_core/native/juce_mac_SystemStats.mm View File

@@ -159,11 +159,28 @@ String SystemStats::getDeviceDescription()
#endif
size_t size;
if (sysctlbyname (name, nullptr, &size, nullptr, 0) >= 0)
{
HeapBlock<char> model (size);
if (sysctlbyname (name, model, &size, nullptr, 0) >= 0)
return model.get();
if (sysctlbyname (name, model, &size, nullptr, 0) >= 0)
{
String description (model.get());
#if JUCE_IOS
if (description == "x86_64") // running in the simulator
{
if (auto* userInfo = [[NSProcessInfo processInfo] environment])
{
if (auto* simDeviceName = [userInfo objectForKey: @"SIMULATOR_DEVICE_NAME"])
return nsStringToJuce (simDeviceName);
}
}
#endif
return description;
}
}
return {};


Loading…
Cancel
Save