From b0116ef31b577ac76ad653937774ec949a42cc1d Mon Sep 17 00:00:00 2001 From: Eitot Date: Sun, 24 Apr 2022 08:34:20 +0200 Subject: [PATCH] Remove obsolete SDK checks (#2111) Sparkle currently requires at least Xcode 12 (or the macOS 11 SDK), therefore fallbacks for older versions are no longer needed. * Remove +isOperatingSystemAtLeastVersion: method * Remove +operatingSystemVersion accessor method * Remove SUTouchBarForwardDeclarations header --- Sparkle.xcodeproj/project.pbxproj | 4 -- Sparkle/SULog.m | 20 ++---- Sparkle/SUOperatingSystem.h | 10 --- Sparkle/SUOperatingSystem.m | 48 +------------ Sparkle/SUSignatures.h | 6 -- Sparkle/SUStatusController.m | 1 - Sparkle/SUTouchBarButtonGroup.m | 6 -- Sparkle/SUTouchBarForwardDeclarations.h | 95 ------------------------- Sparkle/SUUpdateAlert.m | 9 --- Sparkle/SUUpdatePermissionPrompt.m | 1 - 10 files changed, 6 insertions(+), 194 deletions(-) delete mode 100644 Sparkle/SUTouchBarForwardDeclarations.h diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index cc6d1af6..73c4a217 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -132,7 +132,6 @@ 7205C4621E1306A600E370AE /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5711D3D895B00D1BF90 /* SUBinaryDeltaCommon.m */; }; 7205C4631E1306B500E370AE /* libxar.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 726E07681CA616A4001A286B /* libxar.tbd */; }; 7205C4641E1306BE00E370AE /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 726E076A1CA616B3001A286B /* libbz2.tbd */; }; - 720767D31E2EE9C200F9A850 /* SUTouchBarForwardDeclarations.h in Headers */ = {isa = PBXBuildFile; fileRef = 720767D21E2EE9C200F9A850 /* SUTouchBarForwardDeclarations.h */; }; 720AC2A42618E85700E25A3E /* SPUInstallationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5B51D3D8AEE00D1BF90 /* SPUInstallationInfo.m */; }; 720AC2C92618E89500E25A3E /* SUAppcastItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5FC5409C5182000B25A18 /* SUAppcastItem.m */; }; 720AC2DC2618E8A500E25A3E /* SPUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */; }; @@ -970,7 +969,6 @@ 7205C46E1E13254500E370AE /* ConfigUITestDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestDebug.xcconfig; sourceTree = ""; }; 7205C46F1E13255900E370AE /* ConfigUITestRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestRelease.xcconfig; sourceTree = ""; }; 720767D11E2EB86200F9A850 /* AppKitPrevention.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppKitPrevention.h; sourceTree = ""; }; - 720767D21E2EE9C200F9A850 /* SUTouchBarForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTouchBarForwardDeclarations.h; sourceTree = ""; }; 720B16421C66433D006985FB /* UITests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "UITests-Info.plist"; path = "UITests/UITests-Info.plist"; sourceTree = SOURCE_ROOT; }; 720B16431C66433D006985FB /* SUTestApplicationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SUTestApplicationTest.swift; path = UITests/SUTestApplicationTest.swift; sourceTree = SOURCE_ROOT; }; 720B4C2325EBFAFD005A0592 /* link-tools.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "link-tools.sh"; sourceTree = ""; }; @@ -1912,7 +1910,6 @@ 723AC036259DBF1B00BDB4FA /* Web View */, 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */, 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */, - 720767D21E2EE9C200F9A850 /* SUTouchBarForwardDeclarations.h */, 723C8A521E2D60DB00C14942 /* SUTouchBarButtonGroup.h */, 723C8A531E2D60DB00C14942 /* SUTouchBarButtonGroup.m */, 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */, @@ -2462,7 +2459,6 @@ 61B5FC7009C51F4A00B25A18 /* SUAppcastItem.h in Headers */, 725602D51C83551C00DAA70E /* SUApplicationInfo.h in Headers */, 7214B8811D456A8500CB5CED /* SUBundleIcon.h in Headers */, - 720767D31E2EE9C200F9A850 /* SUTouchBarForwardDeclarations.h in Headers */, 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */, 14652F8419A978C200959E44 /* SUExport.h in Headers */, 7267E5E51D3D90AA00D1BF90 /* SUFileManager.h in Headers */, diff --git a/Sparkle/SULog.m b/Sparkle/SULog.m index 288bb8fc..75a216e1 100644 --- a/Sparkle/SULog.m +++ b/Sparkle/SULog.m @@ -10,18 +10,7 @@ #include #include - -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 #include -#else - -typedef struct os_log_s *os_log_t; -#define os_log_create(subsystem, category) nil - -#define os_log(log, format, ...) -#define os_log_error(log, format, ...) - -#endif #include "AppKitPrevention.h" #import "SUOperatingSystem.h" @@ -45,10 +34,11 @@ void SULog(SULogLevel level, NSString *format, ...) dispatch_once(&onceToken, ^{ NSBundle *mainBundle = [NSBundle mainBundle]; - hasOSLogging = [SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 12, 0}]; -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101200 - hasOSLogging = NO; -#endif + if (@available(macOS 10.12, *)) { + hasOSLogging = YES; + } else { + hasOSLogging = NO; + } if (hasOSLogging) { const char *subsystem = SPARKLE_BUNDLE_IDENTIFIER; diff --git a/Sparkle/SUOperatingSystem.h b/Sparkle/SUOperatingSystem.h index e4334d90..c42bb25f 100644 --- a/Sparkle/SUOperatingSystem.h +++ b/Sparkle/SUOperatingSystem.h @@ -7,18 +7,8 @@ #import -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 -typedef struct { - NSInteger majorVersion; - NSInteger minorVersion; - NSInteger patchVersion; -} NSOperatingSystemVersion; -#endif - @interface SUOperatingSystem : NSObject -+ (NSOperatingSystemVersion)operatingSystemVersion; -+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version; + (NSString *)systemVersionString; @end diff --git a/Sparkle/SUOperatingSystem.m b/Sparkle/SUOperatingSystem.m index 6cda6499..6efb4672 100644 --- a/Sparkle/SUOperatingSystem.m +++ b/Sparkle/SUOperatingSystem.m @@ -10,57 +10,11 @@ #include "AppKitPrevention.h" -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 -@interface NSProcessInfo () -- (NSOperatingSystemVersion)operatingSystemVersion; -@end -#endif - @implementation SUOperatingSystem -+ (NSOperatingSystemVersion)operatingSystemVersion -{ -#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wselector" - // Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug? - if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) -#pragma clang diagnostic pop - { - NSOperatingSystemVersion version = { 0, 0, 0 }; - NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil]; - NSURL *url = [coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]; - assert(url != nil); - NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url]; - NSArray *components = [ (NSString *)[dictionary objectForKey: @"ProductVersion"] componentsSeparatedByString:@"."]; - version.majorVersion = components.count > 0 ? [ [components objectAtIndex:0] integerValue] : 0; - version.minorVersion = components.count > 1 ? [ [components objectAtIndex:1] integerValue] : 0; - version.patchVersion = components.count > 2 ? [ [components objectAtIndex:2] integerValue] : 0; - return version; - } -#endif - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpartial-availability" - return [[NSProcessInfo processInfo] operatingSystemVersion]; -#pragma clang diagnostic pop -} - -+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version -{ - const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion; - if (systemVersion.majorVersion == version.majorVersion) { - if (systemVersion.minorVersion == version.minorVersion) { - return systemVersion.patchVersion >= version.patchVersion; - } - return systemVersion.minorVersion >= version.minorVersion; - } - return systemVersion.majorVersion >= version.majorVersion; -} - + (NSString *)systemVersionString { - NSOperatingSystemVersion version = self.operatingSystemVersion; + NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion]; } diff --git a/Sparkle/SUSignatures.h b/Sparkle/SUSignatures.h index ccd76b29..9a98dc7e 100644 --- a/Sparkle/SUSignatures.h +++ b/Sparkle/SUSignatures.h @@ -8,12 +8,6 @@ #import -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090 -@interface NSData (SUSignatureVerifier) -- (id)initWithBase64Encoding:(NSString *)base64String; -@end -#endif - NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(uint8_t, SUSigningInputStatus) { diff --git a/Sparkle/SUStatusController.m b/Sparkle/SUStatusController.m index 5787f073..b3c6c256 100644 --- a/Sparkle/SUStatusController.m +++ b/Sparkle/SUStatusController.m @@ -13,7 +13,6 @@ #import "SUApplicationInfo.h" #import "SULocalizations.h" #import "SUOperatingSystem.h" -#import "SUTouchBarForwardDeclarations.h" #import "SUTouchBarButtonGroup.h" static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDENTIFIER ".SUStatusController"; diff --git a/Sparkle/SUTouchBarButtonGroup.m b/Sparkle/SUTouchBarButtonGroup.m index 82f5cff6..22408961 100644 --- a/Sparkle/SUTouchBarButtonGroup.m +++ b/Sparkle/SUTouchBarButtonGroup.m @@ -10,12 +10,6 @@ #import "SUTouchBarButtonGroup.h" -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101200 -@interface NSButton (SierraSDK) -+ (instancetype)buttonWithTitle:(NSString*)title target:(id)target action:(SEL)action; -@end -#endif - @implementation SUTouchBarButtonGroup @synthesize buttons = _buttons; diff --git a/Sparkle/SUTouchBarForwardDeclarations.h b/Sparkle/SUTouchBarForwardDeclarations.h deleted file mode 100644 index 71489911..00000000 --- a/Sparkle/SUTouchBarForwardDeclarations.h +++ /dev/null @@ -1,95 +0,0 @@ -// -// SUTouchBarForwardDeclarations.h -// Sparkle -// -// Created by Yuxin Wang on 18/01/2017. -// Copyright © 2017 Sparkle Project. All rights reserved. -// - -#if SPARKLE_BUILD_UI_BITS - -// Once Sparkle no longer supports OSX 10.12.0, this file can be deleted. - -#import - -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101201 - -NS_ASSUME_NONNULL_BEGIN - -@class NSTouchBar; -@class NSTouchBarItem; -@class NSCustomTouchBarItem; - -typedef NSString * NSTouchBarItemIdentifier; -typedef NSString * NSTouchBarCustomizationIdentifier; - -@protocol NSTouchBarDelegate; - -NS_CLASS_AVAILABLE_MAC(10_12_2) -@interface NSTouchBar : NSObject - -- (instancetype)init NS_DESIGNATED_INITIALIZER; -- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; - -@property (copy, nullable) NSTouchBarCustomizationIdentifier customizationIdentifier; -@property (copy) NSArray *customizationAllowedItemIdentifiers; -@property (copy) NSArray *customizationRequiredItemIdentifiers; -@property (copy) NSArray *defaultItemIdentifiers; -@property (copy, readonly) NSArray *itemIdentifiers; -@property (copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier; -@property (copy, nullable) NSTouchBarItemIdentifier escapeKeyReplacementItemIdentifier; -@property (copy) NSSet *templateItems; -@property (nullable, weak) id delegate; -- (nullable __kindof NSTouchBarItem *)itemForIdentifier:(NSTouchBarItemIdentifier)identifier; -@property (readonly, getter=isVisible) BOOL visible; - -@end - -@protocol NSTouchBarDelegate -@optional -- (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar - makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier; -@end - -typedef float NSTouchBarItemPriority; - -NS_CLASS_AVAILABLE_MAC(10_12_2) -@interface NSTouchBarItem : NSObject - -- (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier NS_DESIGNATED_INITIALIZER; -- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; -- (instancetype)init NS_UNAVAILABLE; - -@property (readonly, copy) NSTouchBarItemIdentifier identifier; -@property NSTouchBarItemPriority visibilityPriority; -@property (readonly, nullable) NSView *view; -@property (readonly, nullable) NSViewController *viewController; -@property (readonly, copy) NSString *customizationLabel; -@property (readonly, getter=isVisible) BOOL visible; - -@end - -NS_CLASS_AVAILABLE_MAC(10_12_2) -@interface NSCustomTouchBarItem : NSTouchBarItem - -@property (readwrite, strong) __kindof NSView *view; -@property (readwrite, strong, nullable) __kindof NSViewController *viewController; -@property (readwrite, copy, null_resettable) NSString *customizationLabel; - -@end - -NS_ASSUME_NONNULL_END - -#else - -// When compiling against the 10.12.1 SDK or later, just provide forward -// declarations to suppress the partial availability warnings. - -@class NSTouchBar; -@protocol NSTouchBarDelegate; -@class NSTouchBarItem; -@class NSCustomTouchBarItem; - -#endif - -#endif diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index f88f114a..81e16fec 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -26,7 +26,6 @@ #import "SPUDownloadData.h" #import "SUApplicationInfo.h" #import "SPUUpdaterSettings.h" -#import "SUTouchBarForwardDeclarations.h" #import "SUTouchBarButtonGroup.h" #import "SPUXPCServiceInfo.h" #import "SPUUserUpdateState.h" @@ -153,14 +152,12 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE { [self adaptReleaseNotesAppearance]; -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 if (@available(macOS 10.14, *)) { if (!self.observingAppearance) { [self.webView.view addObserver:self forKeyPath:@"effectiveAppearance" options:0 context:nil]; self.observingAppearance = YES; } } -#endif // Stick a nice big spinner in the middle of the web view until the page is loaded. NSRect frame = [[self.webView.view superview] frame]; @@ -187,29 +184,24 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(__attribute__((unused)) NSDictionary *)change context:(__attribute__((unused)) void *)context { -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 if (@available(macOS 10.14, *)) { if (object == self.webView.view && [keyPath isEqualToString:@"effectiveAppearance"]) { [self adaptReleaseNotesAppearance]; } } -#endif } - (void)dealloc { -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 if (@available(macOS 10.14, *)) { if (self.observingAppearance) { [self.webView.view removeObserver:self forKeyPath:@"effectiveAppearance"]; self.observingAppearance = NO; } } -#endif } - (void)adaptReleaseNotesAppearance { -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 if (@available(macOS 10.14, *)) { NSAppearanceName bestAppearance = [self.webView.view.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; @@ -241,7 +233,6 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE [self.webView setDrawsBackground:YES]; } } -#endif } - (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData diff --git a/Sparkle/SUUpdatePermissionPrompt.m b/Sparkle/SUUpdatePermissionPrompt.m index 034adaea..134ab21f 100644 --- a/Sparkle/SUUpdatePermissionPrompt.m +++ b/Sparkle/SUUpdatePermissionPrompt.m @@ -16,7 +16,6 @@ #import "SUHost.h" #import "SUConstants.h" #import "SUApplicationInfo.h" -#import "SUTouchBarForwardDeclarations.h" #import "SUTouchBarButtonGroup.h" static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDENTIFIER ".SUUpdatePermissionPrompt";