From d80452a6b48e8057338cba8570d7dc78746ec741 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 10 Jun 2026 17:54:01 -0700 Subject: [PATCH] Bump minimum deployment target to 12.0 (#2883) To support building Sparkle in Xcode 27 (beta 1), we need to bump the deployment target. --- Autoupdate/SUDiskImageUnarchiver.m | 16 +-- Autoupdate/SUPipedUnarchiver.m | 127 ++++-------------- Configurations/ConfigCommon.xcconfig | 2 +- InstallerLauncher/SUInstallerLauncher.m | 10 +- Package.swift | 2 +- README.markdown | 2 +- Resources/SampleAppcast.xml | 6 +- Sparkle.podspec | 2 +- .../InstallerProgressAppController.m | 2 +- Sparkle/SUAppcastItem.h | 2 +- Sparkle/SULog+NSError.m | 10 +- Sparkle/SUStatusController.m | 2 +- Sparkle/SUTextViewReleaseNotesView.m | 59 ++++---- Sparkle/SUUpdateAlert.m | 30 ++--- Sparkle/SUUpdateValidator.m | 4 +- common_cli/Secret.swift | 28 ++-- generate_appcast/ArchiveItem.swift | 26 +--- 17 files changed, 96 insertions(+), 234 deletions(-) diff --git a/Autoupdate/SUDiskImageUnarchiver.m b/Autoupdate/SUDiskImageUnarchiver.m index fce32604..1fc39803 100644 --- a/Autoupdate/SUDiskImageUnarchiver.m +++ b/Autoupdate/SUDiskImageUnarchiver.m @@ -165,21 +165,9 @@ static NSUInteger fileCountForDirectory(NSFileManager *fileManager, NSString *it goto reportError; } - if (@available(macOS 10.15, *)) { - if (![inputPipe.fileHandleForWriting writeData:inputData error:&error]) { - goto reportError; - } + if (![inputPipe.fileHandleForWriting writeData:inputData error:&error]) { + goto reportError; } -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 - else - { - @try { - [inputPipe.fileHandleForWriting writeData:inputData]; - } @catch (NSException *) { - goto reportError; - } - } -#endif [inputPipe.fileHandleForWriting closeFile]; diff --git a/Autoupdate/SUPipedUnarchiver.m b/Autoupdate/SUPipedUnarchiver.m index 97fd1811..af5f2beb 100644 --- a/Autoupdate/SUPipedUnarchiver.m +++ b/Autoupdate/SUPipedUnarchiver.m @@ -41,25 +41,12 @@ static NSArray * _Nullable argumentsConformingToTypeOfPath(NSString @".tar.lzma" : extractTXZ, } mutableCopy]; - // At least the latest versions of 10.15 understand how to extract aar files - // Versions before 10.15 do not understand extracting newly created aar files - // Note encrypted aea files are supported in macOS 12 onwards, if we ever want to support those one day - if (@available(macOS 10.15.7, *)) { - NSString *appleArchiveCommand; - if (@available(macOS 11, *)) { - appleArchiveCommand = @"/usr/bin/aa"; - } else { - // In 10.15 the utility was named yaa, which was later renamed to aar - appleArchiveCommand = @"/usr/bin/yaa"; - } - - NSArray *extractAppleArchive = @[appleArchiveCommand, @"extract", @"-d"]; - - [extractCommandDictionary addEntriesFromDictionary:@{ - @".aar" : extractAppleArchive, - @".yaa" : extractAppleArchive, - }]; - } + NSArray *extractAppleArchive = @[@"/usr/bin/aa", @"extract", @"-d"]; + + [extractCommandDictionary addEntriesFromDictionary:@{ + @".aar" : extractAppleArchive, + @".yaa" : extractAppleArchive, + }]; NSString *lastPathComponent = [path lastPathComponent]; for (NSString *currentType in extractCommandDictionary) @@ -234,38 +221,12 @@ static NSArray * _Nullable argumentsConformingToTypeOfPath(NSString NSFileHandle *archiveOutput = [pipe fileHandleForWriting]; -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 - BOOL hasIOErrorMethods; - if (@available(macOS 10.15, *)) { - hasIOErrorMethods = YES; - } else { - hasIOErrorMethods = NO; - } -#endif - do { - NSData *data; -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 - if (!hasIOErrorMethods) { - @try { - data = [archiveInput readDataOfLength:256*1024]; - } @catch (NSException *exception) { - SULog(SULogLevelError, @"Failed to read data from archive with exception reason %@", exception.reason); - data = nil; - } - } - else -#endif - { - NSError *readError = nil; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpartial-availability" - data = [archiveInput readDataUpToLength:256*1024 error:&readError]; -#pragma clang diagnostic pop - if (data == nil) { - SULog(SULogLevelError, @"Failed to read data from archive with error %@", readError); - underlyingOutError = readError; - } + NSError *readError = nil; + NSData *data = [archiveInput readDataUpToLength:256*1024 error:&readError]; + if (data == nil) { + SULog(SULogLevelError, @"Failed to read data from archive with error %@", readError); + underlyingOutError = readError; } NSUInteger len = [data length]; @@ -274,37 +235,13 @@ static NSArray * _Nullable argumentsConformingToTypeOfPath(NSString } NSError *writeError = nil; -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 - if (!hasIOErrorMethods) { - @try { - [archiveOutput writeData:data]; - } @catch (NSException *exception) { - SULog(SULogLevelError, @"Failed to write data to pipe with exception reason %@", exception.reason); - - if ([exception.name isEqualToString:NSFileHandleOperationException]) { - NSError *underlyingFileHandleError = exception.userInfo[@"NSFileHandleOperationExceptionUnderlyingError"]; - NSError *underlyingPOSIXError = underlyingFileHandleError.userInfo[NSUnderlyingErrorKey]; - - underlyingOutError = underlyingPOSIXError; - } - - break; - } - } - else -#endif - { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpartial-availability" - if (![archiveOutput writeData:data error:&writeError]) { -#pragma clang diagnostic pop - SULog(SULogLevelError, @"Failed to write data to pipe with error %@", writeError); - - NSError *underlyingPOSIXError = writeError.userInfo[NSUnderlyingErrorKey]; - - underlyingOutError = underlyingPOSIXError; - break; - } + if (![archiveOutput writeData:data error:&writeError]) { + SULog(SULogLevelError, @"Failed to write data to pipe with error %@", writeError); + + NSError *underlyingPOSIXError = writeError.userInfo[NSUnderlyingErrorKey]; + + underlyingOutError = underlyingPOSIXError; + break; } bytesWritten += len; @@ -313,31 +250,15 @@ static NSArray * _Nullable argumentsConformingToTypeOfPath(NSString } while(bytesWritten < expectedLength); - if (@available(macOS 10.15, *)) { - NSError *archiveOutputCloseError = nil; - if (![archiveOutput closeAndReturnError:&archiveOutputCloseError]) { - SULog(SULogLevelError, @"Failed to close pipe with error %@", archiveOutputCloseError); - } + NSError *archiveOutputCloseError = nil; + if (![archiveOutput closeAndReturnError:&archiveOutputCloseError]) { + SULog(SULogLevelError, @"Failed to close pipe with error %@", archiveOutputCloseError); } -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 - else - { - [archiveOutput closeFile]; - } -#endif - if (@available(macOS 10.15, *)) { - NSError *archiveInputCloseError = nil; - if (![archiveInput closeAndReturnError:&archiveInputCloseError]) { - SULog(SULogLevelError, @"Failed to close archive input with error %@", archiveInputCloseError); - } + NSError *archiveInputCloseError = nil; + if (![archiveInput closeAndReturnError:&archiveInputCloseError]) { + SULog(SULogLevelError, @"Failed to close archive input with error %@", archiveInputCloseError); } -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 - else - { - [archiveInput closeFile]; - } -#endif } [task waitUntilExit]; diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 56bc2604..a0a168b2 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -46,7 +46,7 @@ SPARKLE_COPY_LOCALIZATIONS = 1 OTHER_SWIFT_FLAGS_COMMON = -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT -DSPARKLE_BUILD_PACKAGE_SUPPORT // Minimum supported macOS version -MACOSX_DEPLOYMENT_TARGET = 10.13 +MACOSX_DEPLOYMENT_TARGET = 12.0 // Archs to use for Sparkle // You can change this for example to add arm64e or remove x86_64 diff --git a/InstallerLauncher/SUInstallerLauncher.m b/InstallerLauncher/SUInstallerLauncher.m index bac0352e..2ddf0ae0 100644 --- a/InstallerLauncher/SUInstallerLauncher.m +++ b/InstallerLauncher/SUInstallerLauncher.m @@ -192,15 +192,7 @@ NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:iconBundlePath]; // Creating a bitmap representation at a specific size is much cheaper than asking for icon's TIFFRepresentation - // On older OS's we must create a 32x32 image otherwise it won't be scaled correctly in the dialog - // On newer OS's we can use a slightly higher resolution image - NSInteger imageDimensions; - if (@available(macOS 10.15, *)) { - imageDimensions = 64; - } else { - imageDimensions = 32; - } - + const NSInteger imageDimensions = 64; NSBitmapImageRep *iconBitmapRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:imageDimensions pixelsHigh:imageDimensions bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0]; [NSGraphicsContext saveGraphicsState]; diff --git a/Package.swift b/Package.swift index d0bb453a..dafadccb 100644 --- a/Package.swift +++ b/Package.swift @@ -10,7 +10,7 @@ let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/S let package = Package( name: "Sparkle", - platforms: [.macOS(.v10_13)], // leaving "10.13" as a breadcrumb for searching + platforms: [.macOS(.v12)], // leaving "12.0" as a breadcrumb for searching products: [ .library( name: "Sparkle", diff --git a/README.markdown b/README.markdown index db5c1386..75308cbb 100644 --- a/README.markdown +++ b/README.markdown @@ -29,7 +29,7 @@ Please visit [Sparkle's website](http://sparkle-project.org) for up to date docu ## Requirements -* Runtime: macOS 10.13 or later. +* Runtime: macOS 12.0 or later on `2.x`, macOS 10.13 or later on `2.9.3`. * Build: Latest major Xcode (stable or beta, whichever is latest) and one major version less. * HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/)) diff --git a/Resources/SampleAppcast.xml b/Resources/SampleAppcast.xml index 237298b8..6deb818c 100755 --- a/Resources/SampleAppcast.xml +++ b/Resources/SampleAppcast.xml @@ -16,7 +16,7 @@ Wed, 09 Jan 2006 19:20:11 +0000 - 10.13 + 12.0 @@ -31,7 +31,7 @@ Wed, 01 Jan 2006 12:20:11 +0000 - 10.13 + 12.0 @@ -48,7 +48,7 @@ 1.4 Wed, 25 Dec 2005 12:20:11 +0000 - 10.13 + 12.0 diff --git a/Sparkle.podspec b/Sparkle.podspec index 8357737d..49163a2c 100644 --- a/Sparkle.podspec +++ b/Sparkle.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| 'Andy Matuschak' => 'andy@andymatuschak.org', } - s.platform = :osx, '10.13' + s.platform = :osx, '12.0' s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.xz" } s.source_files = 'Sparkle.framework/Versions/B/Headers/*.h' diff --git a/Sparkle/InstallerProgress/InstallerProgressAppController.m b/Sparkle/InstallerProgress/InstallerProgressAppController.m index 3e276aa1..79b783e0 100644 --- a/Sparkle/InstallerProgress/InstallerProgressAppController.m +++ b/Sparkle/InstallerProgress/InstallerProgressAppController.m @@ -231,7 +231,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3; NSMutableArray *potentialMatchingTranslocatedRunningApplications = [[NSMutableArray alloc] init]; BOOL needsToHandleImproperBundles; - if (@available(macOS 16, *)) { + if (@available(macOS 26, *)) { needsToHandleImproperBundles = NO; } else { needsToHandleImproperBundles = YES; diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index 68270656..0480b0b6 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -188,7 +188,7 @@ SU_EXPORT NS_SWIFT_SENDABLE @interface SUAppcastItem : NSObject This version string should contain three period-separated components. - Example: @c 10.13.0 + Example: @c 12.0.0 Use `minimumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement. diff --git a/Sparkle/SULog+NSError.m b/Sparkle/SULog+NSError.m index 0630968d..7e21c810 100644 --- a/Sparkle/SULog+NSError.m +++ b/Sparkle/SULog+NSError.m @@ -22,12 +22,10 @@ static void SULogErrors(NSArray *errors, int recursionLimit) NSDictionary *userInfo = error.userInfo; - if (@available(macOS 11.3, *)) { - NSArray *underlyingErrors = userInfo[NSMultipleUnderlyingErrorsKey]; - if (underlyingErrors != nil) { - SULogErrors(underlyingErrors, recursionLimit - 1); - continue; - } + NSArray *underlyingErrors = userInfo[NSMultipleUnderlyingErrorsKey]; + if (underlyingErrors != nil) { + SULogErrors(underlyingErrors, recursionLimit - 1); + continue; } NSError *underlyingError = userInfo[NSUnderlyingErrorKey]; diff --git a/Sparkle/SUStatusController.m b/Sparkle/SUStatusController.m index b6835a5c..22f277bb 100644 --- a/Sparkle/SUStatusController.m +++ b/Sparkle/SUStatusController.m @@ -88,7 +88,7 @@ static NSString *const SUStatusControllerTouchBarIdentifier = @"" SPARKLE_BUNDLE [_progressBar setUsesThreadedAnimation:YES]; [_statusTextField setFont:[NSFont monospacedDigitSystemFontOfSize:0 weight:NSFontWeightRegular]]; - if (@available(macOS 16, *)) { + if (@available(macOS 26, *)) { _actionButton.controlSize = NSControlSizeLarge; } diff --git a/Sparkle/SUTextViewReleaseNotesView.m b/Sparkle/SUTextViewReleaseNotesView.m index f402775c..0343e0dc 100644 --- a/Sparkle/SUTextViewReleaseNotesView.m +++ b/Sparkle/SUTextViewReleaseNotesView.m @@ -55,7 +55,7 @@ // So even though macOS 12 supports TextKit 2 we do not use it there. // My development machines are currently on macOS 26 so I know TextKit 2 works well there. // macOS 13 - 15 requires more testing if we care to make the switch there. - if (@available(macOS 16, *)) { + if (@available(macOS 26, *)) { // Create NSTextView using TextKit 2 // https://developer.apple.com/documentation/appkit/nstextview/1449347-initwithframe @@ -363,45 +363,38 @@ static NSAttributedString *formatMarkdownAttributedString(NSAttributedString *or [_textView setContinuousSpellCheckingEnabled:NO]; _textView.usesFontPanel = NO; _textView.editable = NO; - - if (@available(macOS 10.14, *)) { - _textView.usesAdaptiveColorMappingForDarkAppearance = YES; - } + _textView.usesAdaptiveColorMappingForDarkAppearance = YES; [_scrollView setHasVerticalScroller:YES]; [_scrollView setHasHorizontalScroller:NO]; if (_prefersMarkdown) { - if (@available(macOS 12, *)) { - dispatch_queue_attr_t queuePriority = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0); + dispatch_queue_attr_t queuePriority = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0); + + dispatch_queue_t markdownDispatchQueue = dispatch_queue_create("org.sparkle-project.markdown-loader", queuePriority); + + dispatch_async(markdownDispatchQueue, ^{ + NSError *loadMarkdownError = nil; + NSAttributedString *originalMarkdownAttributedString = [[NSAttributedString alloc] initWithMarkdownString:contents options:nil baseURL:baseURL error:&loadMarkdownError]; - dispatch_queue_t markdownDispatchQueue = dispatch_queue_create("org.sparkle-project.markdown-loader", queuePriority); - - dispatch_async(markdownDispatchQueue, ^{ - NSError *loadMarkdownError = nil; - NSAttributedString *originalMarkdownAttributedString = [[NSAttributedString alloc] initWithMarkdownString:contents options:nil baseURL:baseURL error:&loadMarkdownError]; + if (originalMarkdownAttributedString == nil) { + // Fallback to plain-text - if (originalMarkdownAttributedString == nil) { - // Fallback to plain-text - - NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:contents attributes:@{ NSFontAttributeName : [NSFont systemFontOfSize:(CGFloat)self->_fontPointSize] }]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [self _loadAttributedString:attributedString completionHandler:completionHandler]; - }); - } else { - NSAttributedString *formattedAttributedString = formatMarkdownAttributedString(originalMarkdownAttributedString, (CGFloat)self->_fontPointSize); - - dispatch_async(dispatch_get_main_queue(), ^{ - [self _loadAttributedString:formattedAttributedString completionHandler:completionHandler]; - }); - } - }); - - return; - } else { - SULog(SULogLevelDefault, @"Warning: falling back to plain text because markdown support requires macOS 12 or newer"); - } + NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:contents attributes:@{ NSFontAttributeName : [NSFont systemFontOfSize:(CGFloat)self->_fontPointSize] }]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self _loadAttributedString:attributedString completionHandler:completionHandler]; + }); + } else { + NSAttributedString *formattedAttributedString = formatMarkdownAttributedString(originalMarkdownAttributedString, (CGFloat)self->_fontPointSize); + + dispatch_async(dispatch_get_main_queue(), ^{ + [self _loadAttributedString:formattedAttributedString completionHandler:completionHandler]; + }); + } + }); + + return; } NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:contents attributes:@{ NSFontAttributeName : [NSFont systemFontOfSize:(CGFloat)_fontPointSize] }]; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 7a5673bf..5222d153 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -299,14 +299,10 @@ typedef NS_ENUM(NSInteger, SUReleaseNotesFormat) usedReleaseNotesFormat = preferredReleaseNotesFormat; break; case SUReleaseNotesFormatHTML: - if (@available(macOS 10.15, *)) { - if ([[NSProcessInfo processInfo] isMacCatalystApp]) { - usedReleaseNotesFormat = SUReleaseNotesFormatPlainText; - - SULog(SULogLevelError, @"Error: Showing HTML release notes for Catalyst apps is not supported. The release notes will be interpreted as plain text. Please serve a plain-text (.txt) or markdown (.md) release notes file. If you are using a element then please specify the %@=\"plain-text\" or %@=\"markdown\" attribute in that element.", SUAppcastAttributeFormat, SUAppcastAttributeFormat); - } else { - usedReleaseNotesFormat = preferredReleaseNotesFormat; - } + if ([[NSProcessInfo processInfo] isMacCatalystApp]) { + usedReleaseNotesFormat = SUReleaseNotesFormatPlainText; + + SULog(SULogLevelError, @"Error: Showing HTML release notes for Catalyst apps is not supported. The release notes will be interpreted as plain text. Please serve a plain-text (.txt) or markdown (.md) release notes file. If you are using a element then please specify the %@=\"plain-text\" or %@=\"markdown\" attribute in that element.", SUAppcastAttributeFormat, SUAppcastAttributeFormat); } else { usedReleaseNotesFormat = preferredReleaseNotesFormat; } @@ -377,12 +373,10 @@ typedef NS_ENUM(NSInteger, SUReleaseNotesFormat) _releaseNotesView.view.frame = _releaseNotesContentView.bounds; _releaseNotesView.view.autoresizingMask = (NSAutoresizingMaskOptions)(NSViewWidthSizable | NSViewHeightSizable); - if (@available(macOS 10.14, *)) { - // We need a transparent background - // This avoids a "white flash" that may be present when the webview initially loads in dark mode - // This also is necessary for macOS 10.14, otherwise the background may stay white on 10.14 (but not in later OS's) - [_releaseNotesView setDrawsBackground:NO]; - } + // We need a transparent background + // This avoids a "white flash" that may be present when the webview initially loads in dark mode + // This also is necessary for macOS 10.14, otherwise the background may stay white on 10.14 (but not in later OS's) + [_releaseNotesView setDrawsBackground:NO]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context @@ -413,11 +407,7 @@ typedef NS_ENUM(NSInteger, SUReleaseNotesFormat) _releaseNotesBoxView.boxType = NSBoxCustom; _releaseNotesBoxView.cornerRadius = boxCornerRadius; - if (@available(macOS 10.14, *)) { - _releaseNotesBoxView.borderColor = NSColor.separatorColor; - } else { - _releaseNotesBoxView.borderColor = [NSColor colorWithCalibratedWhite:0.84 alpha:1.0]; - } + _releaseNotesBoxView.borderColor = NSColor.separatorColor; _releaseNotesBoxView.borderWidth = boxBorderWidth; _releaseNotesBoxView.fillColor = NSColor.textBackgroundColor; @@ -436,7 +426,7 @@ typedef NS_ENUM(NSInteger, SUReleaseNotesFormat) _installButton.title = SULocalizedStringFromTableInBundle(@"Install Update", SPARKLE_TABLE, sparkleBundle, @""); _automaticallyInstallUpdatesButton.title = SULocalizedStringFromTableInBundle(@"Automatically download and install updates in the future", SPARKLE_TABLE, sparkleBundle, @""); - if (@available(macOS 16, *)) { + if (@available(macOS 26, *)) { _skipButton.controlSize = NSControlSizeLarge; _laterButton.controlSize = NSControlSizeLarge; _installButton.controlSize = NSControlSizeLarge; diff --git a/Sparkle/SUUpdateValidator.m b/Sparkle/SUUpdateValidator.m index 07d45e12..fa952cda 100644 --- a/Sparkle/SUUpdateValidator.m +++ b/Sparkle/SUUpdateValidator.m @@ -104,9 +104,7 @@ } if (underlyingErrors.count > 1) { - if (@available(macOS 11.3, *)) { - userInfo[NSMultipleUnderlyingErrorsKey] = [underlyingErrors copy]; - } + userInfo[NSMultipleUnderlyingErrorsKey] = [underlyingErrors copy]; } *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[userInfo copy]]; diff --git a/common_cli/Secret.swift b/common_cli/Secret.swift index aab9da98..06d23b14 100644 --- a/common_cli/Secret.swift +++ b/common_cli/Secret.swift @@ -62,24 +62,18 @@ enum DecodeSecretStringError : LocalizedError { // Reads secret base64 string from a file func decodeSecretString(filePath: String) throws -> String { - let privateKeyString: String - if #available(macOS 10.15.4, *) { - // Prefer to use FileHandle which supports process substitution: - // https://github.com/sparkle-project/Sparkle/issues/2605 - let fileHandle = try FileHandle(forReadingFrom: URL(fileURLWithPath: filePath)) - - guard let data = try fileHandle.readToEnd() else { - throw DecodeSecretStringError.unableToReadData - } - - guard let decodedPrivateKeyString = String(data: data, encoding: .utf8) else { - throw DecodeSecretStringError.unableToDecodeDataAsUTF8String - } - - privateKeyString = decodedPrivateKeyString - } else { - privateKeyString = try String(contentsOf: URL(fileURLWithPath: filePath)) + // Use FileHandle because it supports process substitution: + // https://github.com/sparkle-project/Sparkle/issues/2605 + let fileHandle = try FileHandle(forReadingFrom: URL(fileURLWithPath: filePath)) + + guard let data = try fileHandle.readToEnd() else { + throw DecodeSecretStringError.unableToReadData } + guard let decodedPrivateKeyString = String(data: data, encoding: .utf8) else { + throw DecodeSecretStringError.unableToDecodeDataAsUTF8String + } + + let privateKeyString = decodedPrivateKeyString return privateKeyString.trimmingCharacters(in: .whitespacesAndNewlines) } diff --git a/generate_appcast/ArchiveItem.swift b/generate_appcast/ArchiveItem.swift index 8478d355..af3c779d 100644 --- a/generate_appcast/ArchiveItem.swift +++ b/generate_appcast/ArchiveItem.swift @@ -89,7 +89,6 @@ class ArchiveItem: CustomStringConvertible { var releaseNotesURLPrefix: URL? var signingError: Error? - @available(macOS 10.15.4, *) private static func binaryContainsPreARMSlice(_ fileURL: URL) -> Bool? { guard let fileHandle = try? FileHandle(forReadingFrom: fileURL) else { return nil @@ -180,7 +179,7 @@ class ArchiveItem: CustomStringConvertible { self._shortVersion = shortVersion self.feedURL = feedURL self.requiresSignedAppcast = requiresSignedAppcast - self.minimumSystemVersion = minimumSystemVersion ?? "10.13" + self.minimumSystemVersion = minimumSystemVersion ?? "12.0" self.hardwareRequirements = hardwareRequirements self.frameworkVersion = frameworkVersion self.sparkleExecutableFileSize = sparkleExecutableFileSize @@ -199,21 +198,12 @@ class ArchiveItem: CustomStringConvertible { } convenience init(fromArchive archivePath: URL, unarchivedDir: URL, validateBundle: Bool, disableNestedCodeCheck: Bool) throws { - let resourceKeys: [URLResourceKey] - if #available(macOS 11, *) { - resourceKeys = [.contentTypeKey] - } else { - resourceKeys = [.typeIdentifierKey] - } + let resourceKeys: [URLResourceKey] = [.contentTypeKey] let items = try FileManager.default.contentsOfDirectory(at: unarchivedDir, includingPropertiesForKeys: resourceKeys, options: .skipsHiddenFiles) let bundles = items.filter({ if let resourceValues = try? $0.resourceValues(forKeys: Set(resourceKeys)) { - if #available(macOS 11, *) { - return resourceValues.contentType!.conforms(to: .bundle) - } else { - return UTTypeConformsTo(resourceValues.typeIdentifier! as CFString, kUTTypeBundle) - } + return resourceValues.contentType!.conforms(to: .bundle) } else { return false } @@ -273,12 +263,10 @@ class ArchiveItem: CustomStringConvertible { var hardwareRequirements: String? = nil if mayNeedHardwareRequirement { - if #available(macOS 10.15.4, *) { - if let executableName = infoPlist[kCFBundleExecutableKey as String] as? String { - let executablePath = appPath.appendingPathComponent("Contents/MacOS/\(executableName)") - if let containsPreARMSlice = Self.binaryContainsPreARMSlice(executablePath), !containsPreARMSlice { - hardwareRequirements = SUAppcastElementHardwareRequirementARM64 - } + if let executableName = infoPlist[kCFBundleExecutableKey as String] as? String { + let executablePath = appPath.appendingPathComponent("Contents/MacOS/\(executableName)") + if let containsPreARMSlice = Self.binaryContainsPreARMSlice(executablePath), !containsPreARMSlice { + hardwareRequirements = SUAppcastElementHardwareRequirementARM64 } } }