Skip to content

Commit

Permalink
Remove unnecessary min macro checks (#2318)
Browse files Browse the repository at this point in the history
Minimum OS preprocessor checks should only be used when compiler may generate compile warnings for deprecated APIs when the deployment target is raised.
  • Loading branch information
zorgiepoo authored Feb 12, 2023
1 parent ffc203b commit 06edf56
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 40 deletions.
5 changes: 1 addition & 4 deletions Autoupdate/SUDiskImageUnarchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ - (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier SPU_OBJC_DIRECT

[inputPipe.fileHandleForWriting writeData:promptData];

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
if (@available(macOS 10.15, *))
#endif
{
if (@available(macOS 10.15, *)) {
if (![inputPipe.fileHandleForWriting writeData:promptData error:&error]) {
goto reportError;
}
Expand Down
10 changes: 2 additions & 8 deletions Autoupdate/SUPipedUnarchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ - (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray
}
while(bytesWritten < expectedLength);

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
if (@available(macOS 10.15, *))
#endif
{
if (@available(macOS 10.15, *)) {
NSError *archiveOutputCloseError = nil;
if (![archiveOutput closeAndReturnError:&archiveOutputCloseError]) {
SULog(SULogLevelError, @"Failed to close pipe with error %@", archiveOutputCloseError);
Expand All @@ -204,10 +201,7 @@ - (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray
}
#endif

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
if (@available(macOS 10.15, *))
#endif
{
if (@available(macOS 10.15, *)) {
NSError *archiveInputCloseError = nil;
if (![archiveInput closeAndReturnError:&archiveInputCloseError]) {
SULog(SULogLevelError, @"Failed to close archive input with error %@", archiveInputCloseError);
Expand Down
5 changes: 1 addition & 4 deletions InstallerLauncher/SUInstallerLauncher.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,7 @@ - (SUInstallerLauncherStatus)submitInstallerAtPath:(NSString *)installerPath wit
tempIconDestinationURL = [NSURL fileURLWithPath:path];

CGImageDestinationRef imageDestination = NULL;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
if (@available(macOS 11, *))
#endif
{
if (@available(macOS 11, *)) {
CFStringRef uti = (__bridge CFStringRef)[UTTypePNG identifier];
imageDestination = CGImageDestinationCreateWithURL((CFURLRef)tempIconDestinationURL, uti, 1, NULL);
}
Expand Down
5 changes: 1 addition & 4 deletions Sparkle/SPUInstallerDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ - (void)_reportInstallerError:(nullable NSError *)currentInstallerError genericE
}];

// macOS 13 and later introduce a policy where Gatekeeper can block app modifications if the apps have different Team IDs
#if !defined(MAC_OS_VERSION_13_0) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_13_0
if (@available(macOS 13, *))
#endif
{
if (@available(macOS 13, *)) {
NSBundle *mainBundle = [NSBundle mainBundle];
if (![mainBundle isEqual:_host.bundle]) {
SUHost *mainBundleHost = [[SUHost alloc] initWithBundle:mainBundle];
Expand Down
5 changes: 1 addition & 4 deletions Sparkle/SUApplicationInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ + (NSImage *)bestIconForHost:(SUHost *)host
// but still better than nothing if no icon was included
BOOL isMainBundle = [host.bundle isEqualTo:[NSBundle mainBundle]];

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
if (@available(macOS 11, *))
#endif
{
if (@available(macOS 11, *)) {
UTType *contentType = isMainBundle ? UTTypeApplication : UTTypeBundle;
icon = [[NSWorkspace sharedWorkspace] iconForContentType:contentType];
}
Expand Down
5 changes: 1 addition & 4 deletions Sparkle/SUPlainTextReleaseNotesView.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ - (void)_loadString:(NSString *)contents completionHandler:(void (^)(NSError * _
_textView.usesFontPanel = NO;
_textView.editable = NO;

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
if (@available(macOS 10.14, *))
#endif
{
if (@available(macOS 10.14, *)) {
_textView.usesAdaptiveColorMappingForDarkAppearance = YES;
}

Expand Down
15 changes: 3 additions & 12 deletions Sparkle/SUUpdateAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,15 @@ - (void)displayReleaseNotesSpinner SPU_OBJC_DIRECT
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(__attribute__((unused)) NSDictionary<NSKeyValueChangeKey,id> *)change context:(__attribute__((unused)) void *)context {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
if (@available(macOS 10.14, *))
#endif
{
if (@available(macOS 10.14, *)) {
if (object == _releaseNotesView.view && [keyPath isEqualToString:@"effectiveAppearance"]) {
[self adaptReleaseNotesAppearance];
}
}
}

- (void)dealloc {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
if (@available(macOS 10.14, *))
#endif
{
if (@available(macOS 10.14, *)) {
if (_observingAppearance) {
[_releaseNotesView.view removeObserver:self forKeyPath:@"effectiveAppearance"];
_observingAppearance = NO;
Expand All @@ -209,10 +203,7 @@ - (void)dealloc {

- (void)adaptReleaseNotesAppearance SPU_OBJC_DIRECT
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
if (@available(macOS 10.14, *))
#endif
{
if (@available(macOS 10.14, *)) {
NSAppearanceName bestAppearance = [_releaseNotesView.view.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
if ([bestAppearance isEqualToString:NSAppearanceNameDarkAqua])
{
Expand Down

0 comments on commit 06edf56

Please sign in to comment.