diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a81c804c..260c9762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,17 +10,17 @@ jobs: build: strategy: matrix: - xcode: ['xcode12.2', 'xcode11.7'] + xcode: ['xcode12.5', 'xcode13'] include: - - xcode: 'xcode12.2' - xcode-path: '/Applications/Xcode_12.2.app/Contents/Developer' + - xcode: 'xcode12.5' + xcode-path: '/Applications/Xcode_12.5.app/Contents/Developer' upload-dist: true - - xcode: 'xcode11.7' - xcode-path: '/Applications/Xcode_11.7.app/Contents/Developer' - upload-dist: false # No arm64 slice, so no upload + - xcode: 'xcode13' + xcode-path: '/Applications/Xcode_13.0.app/Contents/Developer' + upload-dist: false # In Beta, so no upload name: Build and Test Sparkle - runs-on: macos-10.15 + runs-on: macos-11 steps: - name: Checkout diff --git a/Autoupdate/SUUnarchiverNotifier.m b/Autoupdate/SUUnarchiverNotifier.m index 643f0eb9..4fd5e37d 100644 --- a/Autoupdate/SUUnarchiverNotifier.m +++ b/Autoupdate/SUUnarchiverNotifier.m @@ -31,6 +31,8 @@ if (self != nil) { _completionBlock = [completionBlock copy]; _progressBlock = [progressBlock copy]; + } else { + assert(false); } return self; } diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index fff4a6e2..c204a5d8 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -41,6 +41,7 @@ DOWNLOADER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.Downloader GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\" CODE_SIGN_IDENTITY = - +SDKROOT = macosx ENABLE_HARDENED_RUNTIME = YES CLANG_ENABLE_OBJC_ARC = YES GCC_ENABLE_PASCAL_STRINGS = NO diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index b77632b7..69ef9330 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 895C5DC524D78E460058A82D /* ShellScript */, ); dependencies = ( + 72EF30B926747E39008CE987 /* PBXTargetDependency */, ); name = XCFrameworks; productName = Sparkle.xcframework; @@ -298,6 +299,8 @@ 726E4A2B1C87D56200C57C6A /* SUTestWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */; }; 726E4A301C87DC1700C57C6A /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; }; 726E4A371C89116000C57C6A /* SPUStandardUserDriverDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E4A361C89116000C57C6A /* SPUStandardUserDriverDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 726F168626747CEB005BEA89 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; }; + 726F168726747CEB005BEA89 /* Sparkle.framework in Copy Sparkle */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */; }; 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; @@ -369,6 +372,7 @@ 72EF30C32675CF67008CE987 /* SPUAppcastItemStateResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EF30BC2675CF38008CE987 /* SPUAppcastItemStateResolver.m */; }; 72EF30C42675CFA1008CE987 /* SPUAppcastItemState.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EF30BB2675CF38008CE987 /* SPUAppcastItemState.m */; }; 72EF30C52675CFA1008CE987 /* SPUAppcastItemStateResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EF30BC2675CF38008CE987 /* SPUAppcastItemStateResolver.m */; }; + 72EF30C7267C716A008CE987 /* SUAppcastItem+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EF30C6267C716A008CE987 /* SUAppcastItem+Private.h */; }; 72F94F581CC44DE1002DEE68 /* SPUXPCServiceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F94F561CC44DE1002DEE68 /* SPUXPCServiceInfo.h */; }; 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F94F571CC44DE1002DEE68 /* SPUXPCServiceInfo.m */; }; 72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */; }; @@ -586,6 +590,13 @@ remoteGlobalIDString = 726E4A151C86C88F00C57C6A; remoteInfo = TestAppHelper; }; + 726F168826747CEB005BEA89 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8DC2EF4F0486A6940098B216; + remoteInfo = Sparkle; + }; 72A5D5AB1D6929260009E5AC /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -607,6 +618,13 @@ remoteGlobalIDString = 72D9549D1CBB415B006F28BD; remoteInfo = "sparkle-cli"; }; + 72EF30B826747E39008CE987 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8DC2EF4F0486A6940098B216; + remoteInfo = Sparkle; + }; 72F94F611CC48669002DEE68 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -727,6 +745,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 726F168726747CEB005BEA89 /* Sparkle.framework in Copy Sparkle */, ); name = "Copy Sparkle"; runOnlyForDeploymentPostprocessing = 0; @@ -1091,7 +1110,6 @@ 725CB9581C7121830064365A /* SPUStandardUserDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUStandardUserDriver.h; sourceTree = ""; }; 725CB9591C7121830064365A /* SPUStandardUserDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUStandardUserDriver.m; sourceTree = ""; }; 725DED72263D10C400E7FA8F /* SUAppcast+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SUAppcast+Private.h"; sourceTree = ""; }; - 725DED73263D123900E7FA8F /* SUAppcastItem+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SUAppcastItem+Private.h"; sourceTree = ""; }; 725F97741C8A62F500265BE4 /* SUAdHocCodeSigning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAdHocCodeSigning.h; sourceTree = ""; }; 725F97751C8A62F500265BE4 /* SUAdHocCodeSigning.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAdHocCodeSigning.m; sourceTree = ""; }; 725F97821C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPopUpTitlebarUserDriver.h; sourceTree = ""; }; @@ -1257,6 +1275,7 @@ 72EF30BB2675CF38008CE987 /* SPUAppcastItemState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUAppcastItemState.m; sourceTree = ""; }; 72EF30BC2675CF38008CE987 /* SPUAppcastItemStateResolver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUAppcastItemStateResolver.m; sourceTree = ""; }; 72EF30BD2675CF38008CE987 /* SPUAppcastItemState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUAppcastItemState.h; sourceTree = ""; }; + 72EF30C6267C716A008CE987 /* SUAppcastItem+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SUAppcastItem+Private.h"; sourceTree = ""; }; 72F94ED51CC3441A002DEE68 /* ConfigInstallerLauncherDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigInstallerLauncherDebug.xcconfig; sourceTree = ""; }; 72F94ED61CC344A7002DEE68 /* ConfigDownloaderDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigDownloaderDebug.xcconfig; sourceTree = ""; }; 72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTestAppDebug.xcconfig; sourceTree = ""; }; @@ -1449,6 +1468,7 @@ buildActionMask = 2147483647; files = ( 724F76F91D6EAD0D00ECD062 /* Cocoa.framework in Frameworks */, + 726F168626747CEB005BEA89 /* Sparkle.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1761,7 +1781,7 @@ 725DED72263D10C400E7FA8F /* SUAppcast+Private.h */, 61B5FB9509C4F04600B25A18 /* SUAppcast.m */, 61B5FC5309C5182000B25A18 /* SUAppcastItem.h */, - 725DED73263D123900E7FA8F /* SUAppcastItem+Private.h */, + 72EF30C6267C716A008CE987 /* SUAppcastItem+Private.h */, 61B5FC5409C5182000B25A18 /* SUAppcastItem.m */, 72EF30BD2675CF38008CE987 /* SPUAppcastItemState.h */, 72EF30BB2675CF38008CE987 /* SPUAppcastItemState.m */, @@ -2320,6 +2340,7 @@ 726E078D1CA891E9001A286B /* SPUUpdaterSettings.h in Headers */, 72F9EC3F1D5E823F004AC8B6 /* SPUUpdaterTimer.h in Headers */, 7269E494264798200088C213 /* SPUSkippedUpdate.h in Headers */, + 72EF30C7267C716A008CE987 /* SUAppcastItem+Private.h in Headers */, 723ABFC4259D4CB300BDB4FA /* SUWKWebView.h in Headers */, 7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */, 725CB9571C7120410064365A /* SPUUserDriver.h in Headers */, @@ -2640,6 +2661,7 @@ buildRules = ( ); dependencies = ( + 726F168926747CEB005BEA89 /* PBXTargetDependency */, ); name = "sparkle-cli"; productName = "sparkle-cli"; @@ -2745,7 +2767,7 @@ attributes = { CLASSPREFIX = SU; LastSwiftUpdateCheck = 1020; - LastUpgradeCheck = 1250; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "Sparkle Project"; TargetAttributes = { 612279D80DB5470200AB99EA = { @@ -3608,6 +3630,11 @@ target = 726E4A151C86C88F00C57C6A /* TestAppHelper */; targetProxy = 726E4A1F1C86C88F00C57C6A /* PBXContainerItemProxy */; }; + 726F168926747CEB005BEA89 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8DC2EF4F0486A6940098B216 /* Sparkle */; + targetProxy = 726F168826747CEB005BEA89 /* PBXContainerItemProxy */; + }; 72A5D5AC1D6929260009E5AC /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72B398D11D3D879300EE297F /* Autoupdate */; @@ -3623,6 +3650,11 @@ target = 72D9549D1CBB415B006F28BD /* sparkle-cli */; targetProxy = 72DBA3791D5FDE95002594A8 /* PBXContainerItemProxy */; }; + 72EF30B926747E39008CE987 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8DC2EF4F0486A6940098B216 /* Sparkle */; + targetProxy = 72EF30B826747E39008CE987 /* PBXContainerItemProxy */; + }; 72F94F621CC48669002DEE68 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; @@ -4177,6 +4209,7 @@ baseConfigurationReference = 72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; }; name = Debug; }; @@ -4185,6 +4218,7 @@ baseConfigurationReference = 72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; }; name = Coverage; }; @@ -4193,6 +4227,7 @@ baseConfigurationReference = 72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; }; name = Release; }; diff --git a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index 3ebded4e..3006563a 100644 --- a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -1,9 +1,9 @@ )__unused resumableUpdate completion:(SPUUpdateDriverCompletion)__unused completionBlock +#pragma clang diagnostic pop { // Nothing really to do here.. this shouldn't be called. SULog(SULogLevelError, @"Error: resumeDownloadedUpdate:completion: called on SPUAutomaticUpdateDriver"); diff --git a/Sparkle/SPUBasicUpdateDriver.m b/Sparkle/SPUBasicUpdateDriver.m index 94927ba9..de54abf3 100644 --- a/Sparkle/SPUBasicUpdateDriver.m +++ b/Sparkle/SPUBasicUpdateDriver.m @@ -187,11 +187,11 @@ break; case NSOrderedAscending: // This means a new update doesn't match the OS requirements - if (!latestAppcastItem.state.minimumOperatingSystemVersionIsOK) { + if (!latestAppcastItem.minimumOperatingSystemVersionIsOK) { localizedDescription = SULocalizedString(@"Your macOS version is too old", nil); recoverySuggestion = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ is available but your macOS version is too old to install it. At least macOS %3$@ is required.", nil), [self.host name], latestAppcastItem.versionString, latestAppcastItem.minimumSystemVersion]; - } else if (!latestAppcastItem.state.maximumOperatingSystemVersionIsOK) { + } else if (!latestAppcastItem.maximumOperatingSystemVersionIsOK) { localizedDescription = SULocalizedString(@"Your macOS version is too new", nil); recoverySuggestion = [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ is available but your macOS version is too new for this update. This update only supports up to macOS %3$@.", nil), [self.host name], latestAppcastItem.versionString, latestAppcastItem.maximumSystemVersion]; diff --git a/Sparkle/SPUInstallerDriver.m b/Sparkle/SPUInstallerDriver.m index dc2c47d0..e4903c4d 100644 --- a/Sparkle/SPUInstallerDriver.m +++ b/Sparkle/SPUInstallerDriver.m @@ -346,7 +346,10 @@ launcherConnection.invalidationHandler = ^{ dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!madeReply) { +#pragma clang diagnostic pop // If something went horribly wrong, just guess that we won't require authorization reply(NO); @@ -367,7 +370,10 @@ [installerLauncher checkIfApplicationInstallationRequiresAuthorizationWithHostBundlePath:self.host.bundlePath reply:^(BOOL requiresAuthorization) { dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!madeReply) { +#pragma clang diagnostic pop madeReply = YES; [launcherConnection invalidate]; @@ -403,7 +409,10 @@ launcherConnection.invalidationHandler = ^{ dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!retrievedLaunchStatus) { +#pragma clang diagnostic pop NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey:SULocalizedString(@"An error occurred while connecting to the installer. Please try again later.", nil) }]; diff --git a/Sparkle/SPUProbeInstallStatus.m b/Sparkle/SPUProbeInstallStatus.m index d44aac2d..298bb94c 100644 --- a/Sparkle/SPUProbeInstallStatus.m +++ b/Sparkle/SPUProbeInstallStatus.m @@ -38,7 +38,10 @@ [installerStatus setInvalidationHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!handledCompletion) { +#pragma clang diagnostic pop completionHandler(NO); handledCompletion = YES; } @@ -50,7 +53,10 @@ [installerStatus probeStatusConnectivityWithReply:^{ dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!handledCompletion) { +#pragma clang diagnostic pop completionHandler(YES); handledCompletion = YES; } @@ -58,8 +64,11 @@ [installerStatus invalidate]; }]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(PROBE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (!handledCompletion) { +#pragma clang diagnostic pop if (usesXPC) { SULog(SULogLevelError, @"Timed out while probing installer progress. Please see https://sparkle-project.org/documentation/sandboxing/#testing for potential cause."); } else { @@ -86,7 +95,10 @@ [installerStatus setInvalidationHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!handledCompletion) { +#pragma clang diagnostic pop completionHandler(nil); handledCompletion = YES; } @@ -103,7 +115,10 @@ } dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" if (!handledCompletion) { +#pragma clang diagnostic pop completionHandler(installationInfo); handledCompletion = YES; } @@ -112,8 +127,11 @@ [installerStatus invalidate]; }]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcompletion-handler" dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(PROBE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (!handledCompletion) { +#pragma clang diagnostic pop if (usesXPC) { SULog(SULogLevelDefault, @"Timed out while probing installer info data. Please see https://sparkle-project.org/documentation/sandboxing/#testing for potential cause."); } else { diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 9c7f13b6..d0f4ceef 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -42,6 +42,8 @@ if (self != nil) { _downloadDriver = [[SPUDownloadDriver alloc] initWithRequestURL:releaseNotesURL host:host userAgent:nil httpHeaders:nil inBackground:NO delegate:self]; _completionHandler = [completionHandler copy]; + } else { + assert(false); } return self; } diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index f2ec1d59..7dc5c806 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -228,7 +228,7 @@ BOOL hostPassesSkippedMajorVersion = [SPUAppcastItemStateResolver isMinimumAutoupdateVersionOK:skippedUpdate.majorVersion hostVersion:hostVersion versionComparator:versionComparator]; return [appcast copyByFilteringItems:^(SUAppcastItem *item) { - BOOL passesOSVersion = (!testOSVersion || (item.state.minimumOperatingSystemVersionIsOK && item.state.maximumOperatingSystemVersionIsOK)); + BOOL passesOSVersion = (!testOSVersion || (item.minimumOperatingSystemVersionIsOK && item.maximumOperatingSystemVersionIsOK)); BOOL passesPhasedRollout = [self itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup currentDate:currentDate hostVersion:hostVersion versionComparator:versionComparator]; diff --git a/Sparkle/SUAppcastItem+Private.h b/Sparkle/SUAppcastItem+Private.h index df503533..5073cf3e 100644 --- a/Sparkle/SUAppcastItem+Private.h +++ b/Sparkle/SUAppcastItem+Private.h @@ -22,17 +22,13 @@ NS_ASSUME_NONNULL_BEGIN -@class SPUAppcastItemState, SPUAppcastItemStateResolver; +@class SPUAppcastItemStateResolver; @interface SUAppcastItem (Private) // Initializes with data from a dictionary provided by the RSS class and state resolver - (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL stateResolver:(SPUAppcastItemStateResolver *)stateResolver failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error; -// Convenience wrapper properties (such as isCriticalUpdate) should be added to SUAppcastItem rather than -// exposing the state as public API -@property (nonatomic, readonly) SPUAppcastItemState *state; - @end NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index ed9c3be1..331aecaa 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -59,9 +59,17 @@ SU_EXPORT @interface SUAppcastItem : NSObject @property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate; @property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate; +@property (nonatomic, readonly) BOOL minimumOperatingSystemVersionIsOK; +@property (nonatomic, readonly) BOOL maximumOperatingSystemVersionIsOK; + // Returns the dictionary representing the appcast item; this might be useful later for extensions. @property (readonly, copy) NSDictionary *propertiesDictionary; +// Deprecated initializers +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict __deprecated_msg("Extended properties that depend on the system or application version are not supported when used with this deprecated initializer. Please adopt supported APIs instead or contact us to describue your use case."); +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error __deprecated_msg("Extended properties that depend on the system or application version are not supported when used with this deprecated initializer. Please adopt supported APIs instead or contact us to describue your use case."); +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error __deprecated_msg("Extended properties that depend on the system or application version are not supported when used with this deprecated initializer. Please adopt supported APIs instead or contact us to describue your use case."); + @end NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 6294e153..e3001c6e 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -7,7 +7,6 @@ // #import "SUAppcastItem.h" -#import "SUAppcastItem+Private.h" #import "SUVersionComparisonProtocol.h" #import "SULog.h" #import "SUConstants.h" @@ -37,7 +36,13 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; @interface SUAppcastItem () -@property (nonatomic, readonly) SPUAppcastItemState *state; +// Auxillary appcast item state that needs to be evaluated based on the host state +// This may be nil if the client creates an SUAppcastItem with a deprecated initializer +// In that case we will need to fallback to safe behavior +@property (nonatomic, readonly, nullable) SPUAppcastItemState *state; + +// Indicates if we have any critical information. Used as a fallback if state is nil +@property (nonatomic, readonly) BOOL hasCriticalInformation; @end @@ -62,6 +67,7 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; @synthesize minimumAutoupdateVersion = _minimumAutoupdateVersion; @synthesize phasedRolloutInterval = _phasedRolloutInterval; @synthesize state = _state; +@synthesize hasCriticalInformation = _hasCriticalInformation; + (BOOL)supportsSecureCoding { @@ -91,9 +97,6 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; } SPUAppcastItemState *state = [decoder decodeObjectOfClass:[SPUAppcastItemState class] forKey:SUAppcastItemStateKey]; - if (state == nil) { - return nil; - } _state = state; _installationType = [installationType copy]; @@ -167,7 +170,9 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; [encoder encodeObject:self.minimumAutoupdateVersion forKey:SUAppcastElementMinimumAutoupdateVersion]; } - [encoder encodeObject:self.state forKey:SUAppcastItemStateKey]; + if (self.state != nil) { + [encoder encodeObject:self.state forKey:SUAppcastItemStateKey]; + } if (self.releaseNotesURL != nil) { [encoder encodeObject:self.releaseNotesURL forKey:SUAppcastItemReleaseNotesURLKey]; @@ -206,12 +211,38 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; - (BOOL)isCriticalUpdate { - return self.state.criticalUpdate; + if (self.state != nil) { + return self.state.criticalUpdate; + } else { + return self.hasCriticalInformation; + } } - (BOOL)isMajorUpgrade { - return self.state.majorUpgrade; + if (self.state != nil) { + return self.state.majorUpgrade; + } else { + return NO; + } +} + +- (BOOL)minimumOperatingSystemVersionIsOK +{ + if (self.state != nil) { + return self.state.minimumOperatingSystemVersionIsOK; + } else { + return YES; + } +} + +- (BOOL)maximumOperatingSystemVersionIsOK +{ + if (self.state != nil) { + return self.state.maximumOperatingSystemVersionIsOK; + } else { + return YES; + } } - (BOOL)isMacOsUpdate @@ -238,16 +269,36 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; return self.infoURL && !self.fileURL; } -- (instancetype)initWithDictionary:(NSDictionary *)dict state:(SPUAppcastItemState *)state +// Used for making delta items +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL state:(SPUAppcastItemState *)state { return [self initWithDictionary:dict relativeToURL:nil stateResolver:nil resolvedState:state failureReason:nil]; } +// Deprecated - (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL stateResolver:(SPUAppcastItemStateResolver *)stateResolver failureReason:(NSString *__autoreleasing *)error { return [self initWithDictionary:dict relativeToURL:appcastURL stateResolver:stateResolver resolvedState:nil failureReason:error]; } +// Deprecated +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict +{ + return [self initWithDictionary:dict relativeToURL:nil stateResolver:nil resolvedState:nil failureReason:nil]; +} + +// Deprecated +- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString *__autoreleasing *)error +{ + return [self initWithDictionary:dict relativeToURL:nil stateResolver:nil resolvedState:nil failureReason:error]; +} + +// Deprecated +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString *__autoreleasing *)error +{ + return [self initWithDictionary:dict relativeToURL:appcastURL stateResolver:nil resolvedState:nil failureReason:error]; +} + - (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL stateResolver:(SPUAppcastItemStateResolver * _Nullable)stateResolver resolvedState:(SPUAppcastItemState * _Nullable)resolvedState failureReason:(NSString *__autoreleasing *)error { self = [super init]; @@ -362,10 +413,12 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; criticalUpdateDictionary = nil; } + _hasCriticalInformation = (criticalUpdateDictionary != nil); + _state = [(SPUAppcastItemStateResolver * _Nonnull)stateResolver resolveStateWithMinimumOperatingSystemVersion:_minimumSystemVersion maximumOperatingSystemVersion:_maximumSystemVersion minimumAutoupdateVersion:_minimumAutoupdateVersion criticalUpdateDictionary:criticalUpdateDictionary]; } else { - assert(resolvedState != nil); - _state = (SPUAppcastItemState * _Nonnull)resolvedState; + // Note state still may be nil if a deprecated initializer is used + _state = resolvedState; } NSString* rolloutIntervalString = [(NSString *)[dict objectForKey:SUAppcastElementPhasedRolloutInterval] copy]; @@ -440,7 +493,7 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; NSMutableDictionary *fakeAppCastDict = [dict mutableCopy]; [fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas]; [fakeAppCastDict setObject:deltaDictionary forKey:SURSSElementEnclosure]; - SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict state:_state]; + SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict relativeToURL:appcastURL state:_state]; if (deltaItem != nil) { [deltas setObject:deltaItem forKey:deltaFrom]; diff --git a/Sparkle/SUUpdatePermissionPrompt.m b/Sparkle/SUUpdatePermissionPrompt.m index cdde16fe..034adaea 100644 --- a/Sparkle/SUUpdatePermissionPrompt.m +++ b/Sparkle/SUUpdatePermissionPrompt.m @@ -72,6 +72,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE _shouldSendProfile = [self shouldAskAboutProfile]; _systemProfileInformationArray = request.systemProfile; [self setShouldCascadeWindows:NO]; + } else { + assert(false); } return self; } diff --git a/TestApplication/SUInstallUpdateViewController.m b/TestApplication/SUInstallUpdateViewController.m index 86363981..ba22b103 100644 --- a/TestApplication/SUInstallUpdateViewController.m +++ b/TestApplication/SUInstallUpdateViewController.m @@ -32,6 +32,8 @@ if (self != nil) { _appcastItem = appcastItem; self.reply = reply; + } else { + assert(false); } return self; }