Skip to content

Commit 728b656

Browse files
Use uname to obtain iOS Device Model for physical devices (#938)
1 parent 2478811 commit 728b656

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/pal/posix/sysinfo_utils_ios.mm

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "sysinfo_utils_apple.hpp"
77
#import <Foundation/Foundation.h>
8+
#import <sys/utsname.h>
89
#import <UIKit/UIKit.h>
910

1011
std::string GetDeviceModel()
@@ -14,7 +15,18 @@
1415
NSString* modelId = NSProcessInfo.processInfo.environment[@"SIMULATOR_MODEL_IDENTIFIER"];
1516
return std::string([modelId UTF8String]);
1617
#else
17-
std::string deviceModel { [[[UIDevice currentDevice] model] UTF8String] };
18+
std::string deviceModel { };
19+
struct utsname systemInfo;
20+
if (uname(&systemInfo) < 0)
21+
{
22+
// Fallback to UIDevice in case of error
23+
deviceModel = [[[UIDevice currentDevice] model] UTF8String];
24+
}
25+
else
26+
{
27+
deviceModel = systemInfo.machine;
28+
}
29+
1830
return deviceModel;
1931
#endif
2032
}

0 commit comments

Comments
 (0)