Skip to content

Commit

Permalink
ref: Replace deprecated function (#3327)
Browse files Browse the repository at this point in the history
Replaced macOS OS version retrieval from a deprecated API to a new one
  • Loading branch information
brustolin authored Oct 4, 2023
1 parent 3f6c30b commit 2e88e64
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions Sources/Sentry/SentryDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,9 @@
#elif SENTRY_HAS_UIKIT
return UIDevice.currentDevice.systemVersion;
#else
// based off of
// https://github.com/lmirosevic/GBDeviceInfo/blob/98dd3c75bb0e1f87f3e0fd909e52dcf0da4aa47d/GBDeviceInfo/GBDeviceInfo_OSX.m#L107-L133
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
const auto version = [[NSProcessInfo processInfo] operatingSystemVersion];
return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion,
(long)version.minorVersion, (long)version.patchVersion];
} else {
SInt32 major, minor, patch;

# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
Gestalt(gestaltSystemVersionMajor, &major);
Gestalt(gestaltSystemVersionMinor, &minor);
Gestalt(gestaltSystemVersionBugFix, &patch);
# pragma clang diagnostic pop

return [NSString stringWithFormat:@"%d.%d.%d", major, minor, patch];
}
const auto version = [[NSProcessInfo processInfo] operatingSystemVersion];
return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion,
(long)version.minorVersion, (long)version.patchVersion];
#endif // SENTRY_HAS_UIKIT
}

Expand Down

0 comments on commit 2e88e64

Please sign in to comment.