diff --git a/Configurations/ConfigCommonCoverage.xcconfig b/Configurations/ConfigCommonCoverage.xcconfig index 4eface42..6473d933 100644 --- a/Configurations/ConfigCommonCoverage.xcconfig +++ b/Configurations/ConfigCommonCoverage.xcconfig @@ -1,6 +1,5 @@ #include "ConfigCommonDebug.xcconfig" -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1 GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; diff --git a/Configurations/ConfigCommonDebug.xcconfig b/Configurations/ConfigCommonDebug.xcconfig index cbf15592..a47e02c6 100644 --- a/Configurations/ConfigCommonDebug.xcconfig +++ b/Configurations/ConfigCommonDebug.xcconfig @@ -2,8 +2,6 @@ // Debug only -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1 - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 04b5a510..7b16ab2e 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -2,8 +2,6 @@ // Release only -SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 0 - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; diff --git a/Configurations/codesign_xpc_service.py b/Configurations/codesign_xpc_service.py new file mode 100644 index 00000000..6c3836db --- /dev/null +++ b/Configurations/codesign_xpc_service.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +import os, sys, subprocess, tempfile, pathlib + +PRODUCT_BUNDLE_ID_MACRO = "$(PRODUCT_BUNDLE_IDENTIFIER)" + +def log_message(message): + sys.stderr.write(message + "\n") + +#Surround a token with double quotes if it has a space in it +def sanitize(argument): + return ('"' + argument + '"' if ' ' in argument else argument) + +def _codesign_service(identity, path, entitlements_path=None): + command = ["codesign", "-o", "runtime", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path]) + log_message(" ".join(map(sanitize, command))) + + process = subprocess.Popen(command, stdout=subprocess.PIPE) + process.communicate() + if process.returncode != 0: + log_message("Error: Failed to codesign %s" % (path)) + sys.exit(1) + +def codesign_service(service_name, identity, path, entitlements_path=None): + #Sign the auxiliary executables (if any) + executables_path = os.path.join(path, "Contents/MacOS/") + if os.path.exists(executables_path): + for executable in os.listdir(executables_path): + if executable != service_name: + _codesign_service(identity, os.path.join(executables_path, executable), entitlements_path) + + #Sign the service bundle + _codesign_service(identity, path, entitlements_path) + +# Returns entitlements back with a bundle id applied if needed +def applied_entitlements_path(entitlements_path, bundle_id, temp_dir): + entitlements_str = pathlib.Path(entitlements_path).read_text() + if PRODUCT_BUNDLE_ID_MACRO in entitlements_str: + if bundle_id is None: + return None + else: + new_entitlements_str = entitlements_str.replace(PRODUCT_BUNDLE_ID_MACRO, bundle_id) + new_entitlements_path = os.path.join(temp_dir, os.path.basename(entitlements_path)) + pathlib.Path(new_entitlements_path).write_text(new_entitlements_str) + return new_entitlements_path + else: + return entitlements_path + +def print_usage(): + log_message("Usage:\n\t%s code-signing-identity [-b app-bundle-id] service1 service2 ..." % (sys.argv[0])) + log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices/org.sparkle-project.InstallerLauncher.xpc" % (sys.argv[0])) + log_message("") + log_message("Use this script to sign XPC Services to include in your Sandboxed application.") + log_message("") + log_message("bundle-id is optional and only needs to be provided when signing InstallerConnection and InstallerStatus services. Most applications do not need to use these services and can provide additional entitlements to their application instead.") + log_message("") + log_message("This script may not be needed for common development workflows. Please visit https://sparkle-project.org/documentation/sandboxing/ for more details and instructions.") + +if __name__ == "__main__": + if len(sys.argv) < 3: + print_usage() + sys.exit(1) + + signing_identity = sys.argv[1] + remaining_args = sys.argv[2:] + bundle_id = None + if remaining_args[0] == '-b': + if len(remaining_args) < 3: + # We need the bundle-id and at least one XPC Service to sign + print_usage() + sys.exit(1) + else: + bundle_id = remaining_args[1] + services = remaining_args[2:] + else: + services = remaining_args + + with tempfile.TemporaryDirectory() as temp_dir: + for service in services: + parent, child = os.path.split(service) + service_name = os.path.splitext(child)[0] + entitlements_path = os.path.join(parent, service_name + ".entitlements") + if os.path.exists(entitlements_path): + service_entitlements_path = applied_entitlements_path(entitlements_path, bundle_id, temp_dir) + if service_entitlements_path is None: + print_usage() + log_message("") + log_message("Error: Bundle ID must be specified for signing %s. As noted in the usage above, you probably don't need to embed this service." % (service_name)) + sys.exit(1) + else: + service_entitlements_path = None + + codesign_service(service_name, signing_identity, service, service_entitlements_path) diff --git a/Configurations/make-release-package.sh b/Configurations/make-release-package.sh index ad52a215..6f28327b 100755 --- a/Configurations/make-release-package.sh +++ b/Configurations/make-release-package.sh @@ -26,6 +26,8 @@ if [ "$ACTION" = "" ] ; then cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin" cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin" cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin" + cp "$SRCROOT/Configurations/codesign_xpc_service.py" "$CONFIGURATION_BUILD_DIR/staging/bin/codesign_xpc_service" + chmod 0755 "$CONFIGURATION_BUILD_DIR/staging/bin/codesign_xpc_service" cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging" cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging-spm" cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app" "$CONFIGURATION_BUILD_DIR/staging" @@ -43,6 +45,8 @@ if [ "$ACTION" = "" ] ; then cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" cp "$SRCROOT/Downloader/$DOWNLOADER_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" + cp "$SRCROOT/InstallerConnection/$INSTALLER_CONNECTION_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" + cp "$SRCROOT/InstallerStatus/$INSTALLER_STATUS_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices" # Only copy dSYMs for Release builds, but don't check for the presence of the actual files # because missing dSYMs in a release build SHOULD trigger a build failure diff --git a/Configurations/set-ats-exceptions-downloader-service.sh b/Configurations/set-ats-exceptions-downloader-service.sh deleted file mode 100755 index 9b5fa1b9..00000000 --- a/Configurations/set-ats-exceptions-downloader-service.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# http://stackoverflow.com/questions/32390228/is-it-possible-to-disable-ats-in-ios-9-just-for-debug-environment -INFOPLIST="${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}" -case "${SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS}" in -"YES"|"1") -/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${INFOPLIST}" -;; -"NO"|"0") -/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads NO" "${INFOPLIST}" -;; -esac diff --git a/Configurations/set-ats-exceptions-test-app.sh b/Configurations/set-ats-exceptions-test-app.sh deleted file mode 100755 index 53ccfc36..00000000 --- a/Configurations/set-ats-exceptions-test-app.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# We should make sure ATS is off for the test app - -DOWNLOADER_INFO_PLIST="${TARGET_BUILD_DIR}"/"${CONTENTS_FOLDER_PATH}"/XPCServices/"${DOWNLOADER_BUNDLE_ID}".xpc/Contents/Info.plist - -#Only alter bundles if code signing is off, else we'll invalidate the signature on them -#If code signing is enabled (as in debug mode), then we rely on another script for turning ATS exceptions on for these services -#In release mode however, those services do not have ATS exceptions set up which is why we have to set up exceptions *here* -if [ -z "${CODE_SIGN_IDENTITY}" ] ; then - /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${DOWNLOADER_INFO_PLIST}" -fi diff --git a/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements b/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements new file mode 100644 index 00000000..fa7d47e6 --- /dev/null +++ b/InstallerConnection/org.sparkle-project.InstallerConnection.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spki + + + diff --git a/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements b/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements new file mode 100644 index 00000000..0cceb6d0 --- /dev/null +++ b/InstallerStatus/org.sparkle-project.InstallerStatus.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spks + + + diff --git a/Resources/SampleAppcast.xml b/Resources/SampleAppcast.xml index e16412e5..79eb5f3f 100755 --- a/Resources/SampleAppcast.xml +++ b/Resources/SampleAppcast.xml @@ -10,8 +10,7 @@ http://you.com/app/2.0.html Wed, 09 Jan 2006 19:20:11 +0000 - - + 10.9 @@ -21,8 +20,7 @@ http://you.com/app/1.5.html Wed, 01 Jan 2006 12:20:11 +0000 - - + 10.9 @@ -33,8 +31,7 @@ http://you.com/app/1.4.html Wed, 25 Dec 2005 12:20:11 +0000 - - + 10.9 diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index d38c7db3..c071001f 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -200,13 +200,11 @@ 7246E0A41C83B685003B4E75 /* SPUStandardUpdaterController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7246E0A21C83B685003B4E75 /* SPUStandardUpdaterController.m */; }; 724BB3711D31D0B7005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; }; 724BB3731D31D0B7005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3721D31D0B7005D534A /* main.m */; }; - 724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB36C1D31D0B7005D534A /* org.sparkle-project.InstallerConnection.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 724BB3871D32A167005D534A /* SUXPCInstallerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 724BB3851D32A167005D534A /* SUXPCInstallerConnection.h */; }; 724BB3881D32A167005D534A /* SUXPCInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3861D32A167005D534A /* SUXPCInstallerConnection.m */; }; 724BB3891D32B915005D534A /* SUInstallerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3701D31D0B7005D534A /* SUInstallerConnection.m */; }; 724BB3981D333832005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; }; 724BB39A1D333832005D534A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3991D333832005D534A /* main.m */; }; - 724BB39E1D333832005D534A /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 724BB3931D333832005D534A /* org.sparkle-project.InstallerStatus.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 724BB3A81D33461B005D534A /* SUXPCInstallerStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 724BB3A61D33461B005D534A /* SUXPCInstallerStatus.h */; }; 724BB3A91D33461B005D534A /* SUXPCInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3A71D33461B005D534A /* SUXPCInstallerStatus.m */; }; 724BB3AA1D3347C2005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; }; @@ -220,8 +218,6 @@ 725CB95B1C7121830064365A /* SPUStandardUserDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 725CB9591C7121830064365A /* SPUStandardUserDriver.m */; }; 725F97771C8A62F500265BE4 /* SUAdHocCodeSigning.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97751C8A62F500265BE4 /* SUAdHocCodeSigning.m */; }; 725F97781C8A65AC00265BE4 /* SUAdHocCodeSigning.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97751C8A62F500265BE4 /* SUAdHocCodeSigning.m */; }; - 725F977B1C8A896F00265BE4 /* SPUUserDriverCoreComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 725F977C1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */; }; 725F97841C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97831C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m */; }; 725F97A51C8B304D00265BE4 /* SUInstallUpdateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F97A31C8B304D00265BE4 /* SUInstallUpdateViewController.m */; }; 725F97A61C8B304D00265BE4 /* SUInstallUpdateViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 725F97A41C8B304D00265BE4 /* SUInstallUpdateViewController.xib */; }; @@ -365,7 +361,6 @@ 72A5D5D71D6929F80009E5AC /* SUUpdatePermissionResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 72A450521C69A68900D67EEA /* SUUpdatePermissionResponse.m */; }; 72A5D5D81D6929F80009E5AC /* SPUUpdaterCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */; }; 72A5D5D91D6929F90009E5AC /* SPUUpdaterTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EC3E1D5E823F004AC8B6 /* SPUUpdaterTimer.m */; }; - 72A5D5DA1D6929F90009E5AC /* SPUUserDriverCoreComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */; }; 72A5D5DC1D692A4E0009E5AC /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */; }; 72A5D5DE1D692ACC0009E5AC /* SparkleCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A5D5DD1D692ACC0009E5AC /* SparkleCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5DF1D692B570009E5AC /* SUAppcast.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5FB9409C4F04600B25A18 /* SUAppcast.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -379,7 +374,6 @@ 72A5D5E71D692BB00009E5AC /* SPUUpdatePermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 72DBA37B1D60CC34002594A8 /* SPUUpdatePermissionRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5E81D692BBB0009E5AC /* SUUpdatePermissionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SUUpdatePermissionResponse.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5E91D692BC80009E5AC /* SPUUserDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 725CB9561C7120410064365A /* SPUUserDriver.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 72A5D5EA1D692BC80009E5AC /* SPUUserDriverCoreComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5EB1D692BD40009E5AC /* SPUDownloadData.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A5D5EF1D692C440009E5AC /* Autoupdate in Copy Tools */ = {isa = PBXBuildFile; fileRef = 72B398D21D3D879300EE297F /* Autoupdate */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 72A5D5F01D692C4B0009E5AC /* Updater.app in Copy Tools */ = {isa = PBXBuildFile; fileRef = 721C24451CB753E6005440CB /* Updater.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -441,7 +435,6 @@ 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F94F571CC44DE1002DEE68 /* SPUXPCServiceInfo.m */; }; 72F94F5A1CC450DE002DEE68 /* SUInstallerLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */; }; 72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07AD1CAF08D6001A286B /* org.sparkle-project.InstallerLauncher.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 72F94F5E1CC455B4002DEE68 /* org.sparkle-project.Downloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* org.sparkle-project.Downloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 72F9EBE21D517E2F004AC8B6 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F9EBE01D517E2F004AC8B6 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72F9EBE31D517E2F004AC8B6 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 72F9EBE11D517E2F004AC8B6 /* SUUpdater.m */; }; 72F9EC341D5BF542004AC8B6 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; }; @@ -608,6 +601,20 @@ remoteGlobalIDString = 7205C43D1E13049400E370AE; remoteInfo = generate_appcast; }; + 7218EC322623ED94008FECF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 724BB36B1D31D0B7005D534A; + remoteInfo = SparkleInstallerConnection; + }; + 7218EC342623ED97008FECF3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 724BB3921D333832005D534A; + remoteInfo = SparkleInstallerStatus; + }; 721D8A771D4952B60032E472 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -622,20 +629,6 @@ remoteGlobalIDString = 721C24441CB753E6005440CB; remoteInfo = "Installer Progress"; }; - 724BB3821D3203A9005D534A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 724BB36B1D31D0B7005D534A; - remoteInfo = SparkleInstallerConnection; - }; - 724BB39C1D333832005D534A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 724BB3921D333832005D534A; - remoteInfo = InstallerStatus; - }; 726B2B621C645FC900388755 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -699,13 +692,6 @@ remoteGlobalIDString = 726E07AC1CAF08D6001A286B; remoteInfo = SparkleInstallerLauncher; }; - 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 726E07EE1CAF37BD001A286B; - remoteInfo = SparkleUpdateDownloader; - }; 72F94F6A1CC4A0C8002DEE68 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -805,10 +791,7 @@ dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices"; dstSubfolderSpec = 16; files = ( - 72F94F5E1CC455B4002DEE68 /* org.sparkle-project.Downloader.xpc in Embed XPC Services */, - 724BB3841D3203BA005D534A /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */, 72F94F5D1CC455B4002DEE68 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */, - 724BB39E1D333832005D534A /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */, 726E4A211C86C88F00C57C6A /* TestAppHelper.xpc in Embed XPC Services */, ); name = "Embed XPC Services"; @@ -1033,6 +1016,9 @@ 7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUInstallationType.h; sourceTree = ""; }; 72162B071C82C9600013C1C5 /* SULocalizations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULocalizations.h; sourceTree = ""; }; 721652671D3C8FED00FD13D8 /* SUInstallerLauncherStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerLauncherStatus.h; path = InstallerLauncher/SUInstallerLauncherStatus.h; sourceTree = SOURCE_ROOT; }; + 7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerConnection.entitlements"; sourceTree = ""; }; + 7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerStatus.entitlements"; sourceTree = ""; }; + 7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = codesign_xpc_service.py; sourceTree = ""; }; 721BC2061D17A532002BC71E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 721BC2081D17A553002BC71E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 721BC20A1D17A5AD002BC71E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; @@ -1203,8 +1189,6 @@ 725CB9591C7121830064365A /* SPUStandardUserDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUStandardUserDriver.m; 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 = ""; }; - 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUserDriverCoreComponent.h; sourceTree = ""; }; - 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUUserDriverCoreComponent.m; sourceTree = ""; }; 725F97821C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPopUpTitlebarUserDriver.h; sourceTree = ""; }; 725F97831C8AA90000265BE4 /* SUPopUpTitlebarUserDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPopUpTitlebarUserDriver.m; sourceTree = ""; }; 725F97A21C8B304D00265BE4 /* SUInstallUpdateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUInstallUpdateViewController.h; sourceTree = ""; }; @@ -1297,8 +1281,6 @@ 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUURLRequest.m; sourceTree = ""; }; 729924921DF4A45000DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUUpdateValidator.h; path = Sparkle/SUUpdateValidator.h; sourceTree = SOURCE_ROOT; }; 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdateValidator.m; path = Sparkle/SUUpdateValidator.m; sourceTree = SOURCE_ROOT; }; - 729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-test-app.sh"; sourceTree = ""; }; - 729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions-downloader-service.sh"; sourceTree = ""; }; 729BB3D11D503826007C4276 /* org.sparkle-project.Downloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.Downloader.entitlements"; path = "Downloader/org.sparkle-project.Downloader.entitlements"; sourceTree = SOURCE_ROOT; }; 729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = ""; }; 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = ""; }; @@ -2122,6 +2104,7 @@ 724BB36E1D31D0B7005D534A /* SUInstallerConnectionProtocol.h */, 724BB3851D32A167005D534A /* SUXPCInstallerConnection.h */, 724BB3861D32A167005D534A /* SUXPCInstallerConnection.m */, + 7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */, ); name = InstallerConnection; path = ../InstallerConnection; @@ -2138,6 +2121,7 @@ 7267E5DD1D3D8F5A00D1BF90 /* SUStatusInfoProtocol.h */, 724BB3A61D33461B005D534A /* SUXPCInstallerStatus.h */, 724BB3A71D33461B005D534A /* SUXPCInstallerStatus.m */, + 7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */, ); name = InstallerStatus; path = ../InstallerStatus; @@ -2153,8 +2137,6 @@ 726E4A361C89116000C57C6A /* SPUStandardUserDriverDelegate.h */, 726DF88D1C84277500188804 /* SPUStatusCompletionResults.h */, 725CB9561C7120410064365A /* SPUUserDriver.h */, - 725F97791C8A896F00265BE4 /* SPUUserDriverCoreComponent.h */, - 725F977A1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m */, ); name = "User Driver"; sourceTree = ""; @@ -2387,8 +2369,7 @@ EA1E285722B6622E004AA304 /* ed25519-Release.xcconfig */, EA1E285922B6622E004AA304 /* ed25519-Shared.xcconfig */, 14732BC91960F70A00593899 /* make-release-package.sh */, - 729BB3CE1D50344A007C4276 /* set-ats-exceptions-downloader-service.sh */, - 729BB3CD1D503253007C4276 /* set-ats-exceptions-test-app.sh */, + 7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */, 14652F7919A93E5F00959E44 /* set-git-version-info.sh */, 720B4C2325EBFAFD005A0592 /* link-tools.sh */, 146EC84E19A68CF8004A50C5 /* Sparkle.podspec */, @@ -2414,7 +2395,6 @@ 72A5D5E41D692B770009E5AC /* SPUUpdaterDelegate.h in Headers */, 72A5D5E31D692B770009E5AC /* SPUUpdaterSettings.h in Headers */, 72A5D5E91D692BC80009E5AC /* SPUUserDriver.h in Headers */, - 72A5D5EA1D692BC80009E5AC /* SPUUserDriverCoreComponent.h in Headers */, 72A5D5DF1D692B570009E5AC /* SUAppcast.h in Headers */, 72A5D5E01D692B570009E5AC /* SUAppcastItem.h in Headers */, 72A5D5E61D692BA20009E5AC /* SUErrors.h in Headers */, @@ -2462,7 +2442,6 @@ 723ABFC4259D4CB300BDB4FA /* SUWKWebView.h in Headers */, 7293A1AE1CEE933800B957A7 /* SPUURLRequest.h in Headers */, 725CB9571C7120410064365A /* SPUUserDriver.h in Headers */, - 725F977B1C8A896F00265BE4 /* SPUUserDriverCoreComponent.h in Headers */, 72B767DE1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.h in Headers */, 72F94F581CC44DE1002DEE68 /* SPUXPCServiceInfo.h in Headers */, 61B5FC0D09C4FC8200B25A18 /* SUAppcast.h in Headers */, @@ -2531,6 +2510,8 @@ 72DBA37A1D5FDE95002594A8 /* PBXTargetDependency */, 72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */, 72F94F6D1CC4A0C8002DEE68 /* PBXTargetDependency */, + 7218EC352623ED97008FECF3 /* PBXTargetDependency */, + 7218EC332623ED94008FECF3 /* PBXTargetDependency */, 1454BA1619637EDB00344E57 /* PBXTargetDependency */, 14732BCF1960F73500593899 /* PBXTargetDependency */, 7205C46B1E13070300E370AE /* PBXTargetDependency */, @@ -2592,17 +2573,13 @@ 61B5F90009C4CEE200B25A18 /* Frameworks */, 61B5FB4D09C4E9FA00B25A18 /* Copy Frameworks */, 726E4A261C86C88F00C57C6A /* Embed XPC Services */, - 729BB3CC1D501A8F007C4276 /* Run Script */, ); buildRules = ( ); dependencies = ( 61B5F91C09C4CF7200B25A18 /* PBXTargetDependency */, - 724BB3831D3203A9005D534A /* PBXTargetDependency */, 72F94F621CC48669002DEE68 /* PBXTargetDependency */, - 72F94F641CC48669002DEE68 /* PBXTargetDependency */, 726E4A201C86C88F00C57C6A /* PBXTargetDependency */, - 724BB39D1D333832005D534A /* PBXTargetDependency */, ); name = "Sparkle Test App"; productName = "Test Application"; @@ -2721,7 +2698,6 @@ 726E07EB1CAF37BD001A286B /* Sources */, 726E07EC1CAF37BD001A286B /* Frameworks */, 726E07ED1CAF37BD001A286B /* Resources */, - 729BB3D01D50354C007C4276 /* ShellScript */, ); buildRules = ( ); @@ -3231,33 +3207,6 @@ shellPath = /bin/sh; shellScript = "\"$SRCROOT/Configurations/link-tools.sh\"\n"; }; - 729BB3CC1D501A8F007C4276 /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Configurations/set-ats-exceptions-test-app.sh\"\n"; - }; - 729BB3D01D50354C007C4276 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Configurations/set-ats-exceptions-downloader-service.sh\"\n"; - }; 72A5D5F11D692C860009E5AC /* Run Script: Set Git Version Info */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -3512,7 +3461,6 @@ 72A5D5D91D6929F90009E5AC /* SPUUpdaterTimer.m in Sources */, 72A5D5BB1D6929F80009E5AC /* SPUURLDownload.m in Sources */, 72A5D5BC1D6929F80009E5AC /* SPUURLRequest.m in Sources */, - 72A5D5DA1D6929F90009E5AC /* SPUUserDriverCoreComponent.m in Sources */, 72A5D5C81D6929F80009E5AC /* SPUUserInitiatedUpdateDriver.m in Sources */, 72A5D5AD1D6929F80009E5AC /* SPUXPCServiceInfo.m in Sources */, 72A5D5B91D6929F80009E5AC /* SUAppcast.m in Sources */, @@ -3624,7 +3572,6 @@ 72F9EC401D5E823F004AC8B6 /* SPUUpdaterTimer.m in Sources */, 72B09CE81CE6BCBD0052EF9E /* SPUURLDownload.m in Sources */, 7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */, - 725F977C1C8A896F00265BE4 /* SPUUserDriverCoreComponent.m in Sources */, 72B767DF1C9CDB9700A07552 /* SPUUserInitiatedUpdateDriver.m in Sources */, 72F94F591CC44DE1002DEE68 /* SPUXPCServiceInfo.m in Sources */, 61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */, @@ -3784,6 +3731,16 @@ target = 7205C43D1E13049400E370AE /* generate_appcast */; targetProxy = 7205C46A1E13070300E370AE /* PBXContainerItemProxy */; }; + 7218EC332623ED94008FECF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */; + targetProxy = 7218EC322623ED94008FECF3 /* PBXContainerItemProxy */; + }; + 7218EC352623ED97008FECF3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 724BB3921D333832005D534A /* SparkleInstallerStatus */; + targetProxy = 7218EC342623ED97008FECF3 /* PBXContainerItemProxy */; + }; 721D8A781D4952B60032E472 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72B398D11D3D879300EE297F /* Autoupdate */; @@ -3794,16 +3751,6 @@ target = 721C24441CB753E6005440CB /* Installer Progress */; targetProxy = 721D8A791D4952B60032E472 /* PBXContainerItemProxy */; }; - 724BB3831D3203A9005D534A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 724BB36B1D31D0B7005D534A /* SparkleInstallerConnection */; - targetProxy = 724BB3821D3203A9005D534A /* PBXContainerItemProxy */; - }; - 724BB39D1D333832005D534A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 724BB3921D333832005D534A /* SparkleInstallerStatus */; - targetProxy = 724BB39C1D333832005D534A /* PBXContainerItemProxy */; - }; 726B2B631C645FC900388755 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */; @@ -3849,11 +3796,6 @@ target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; targetProxy = 72F94F611CC48669002DEE68 /* PBXContainerItemProxy */; }; - 72F94F641CC48669002DEE68 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 726E07EE1CAF37BD001A286B /* SparkleDownloader */; - targetProxy = 72F94F631CC48669002DEE68 /* PBXContainerItemProxy */; - }; 72F94F6B1CC4A0C8002DEE68 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */; diff --git a/Sparkle/SPUStandardUpdaterController.h b/Sparkle/SPUStandardUpdaterController.h index da1e011b..a877e485 100644 --- a/Sparkle/SPUStandardUpdaterController.h +++ b/Sparkle/SPUStandardUpdaterController.h @@ -32,11 +32,9 @@ NS_ASSUME_NONNULL_BEGIN up the updater's and user driver's delegates. This controller class may not be valuable to you if: - * You want to control or defer the instantiation of an SPUUpdater, or don't want to be tied into a nib's instantiation, or don't want to use a nib + * You want to control or defer starting the SPUUpdater, or don't want to be tied into a nib's instantiation, or don't want to use a nib * You want to target a bundle that's not the main bundle - * You want to provide a custom user interface, or perhaps one that provides little-to-none - * You don't want to use a convenience class that provides very little glue ;) - + * You want to provide a custom user interface (SPUUserDriver), or perhaps one that provides little-to-none */ SU_EXPORT @interface SPUStandardUpdaterController : NSObject diff --git a/Sparkle/SPUStandardUserDriver.m b/Sparkle/SPUStandardUserDriver.m index ebc5d600..a1808635 100644 --- a/Sparkle/SPUStandardUserDriver.m +++ b/Sparkle/SPUStandardUserDriver.m @@ -7,7 +7,6 @@ // #import "SPUStandardUserDriver.h" -#import "SPUUserDriverCoreComponent.h" #import "SPUStandardUserDriverDelegate.h" #import "SUAppcastItem.h" #import "SUVersionDisplayProtocol.h" @@ -27,9 +26,11 @@ @property (nonatomic, readonly) NSString *oldHostName; @property (nonatomic, readonly) NSURL *oldHostBundleURL; -@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic, weak, nullable, readonly) id delegate; +@property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus); +@property (nonatomic, copy) void (^cancellation)(void); + @property (nonatomic) SUStatusController *checkingController; @property (nonatomic) SUUpdateAlert *activeUpdateAlert; @property (nonatomic) SUStatusController *statusController; @@ -42,7 +43,8 @@ @synthesize host = _host; @synthesize oldHostName = _oldHostName; @synthesize oldHostBundleURL = _oldHostBundleURL; -@synthesize coreComponent = _coreComponent; +@synthesize installUpdateHandler = _installUpdateHandler; +@synthesize cancellation = _cancellation; @synthesize delegate = _delegate; @synthesize checkingController = _checkingController; @synthesize activeUpdateAlert = _activeUpdateAlert; @@ -59,7 +61,6 @@ _oldHostName = _host.name; _oldHostBundleURL = hostBundle.bundleURL; _delegate = delegate; - _coreComponent = [[SPUUserDriverCoreComponent alloc] init]; } return self; } @@ -215,21 +216,24 @@ [[self.statusController window] makeKeyAndOrderFront:self]; [NSApp requestUserAttention:NSInformationalRequest]; - [self.coreComponent registerInstallUpdateHandler:installUpdateHandler]; + self.installUpdateHandler = installUpdateHandler; } - (void)installAndRestart:(id)__unused sender { - [self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + if (self.installUpdateHandler != nil) { + self.installUpdateHandler(SPUInstallAndRelaunchUpdateNow); + self.installUpdateHandler = nil; + } } #pragma mark Check for Updates -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation { assert(NSThread.isMainThread); - [self.coreComponent registerUpdateCheckStatusHandler:updateCheckStatusCompletion]; + self.cancellation = cancellation; self.checkingController = [[SUStatusController alloc] initWithHost:self.host]; [[self.checkingController window] center]; // Force the checking controller to load its window. @@ -256,7 +260,10 @@ - (void)cancelCheckForUpdates:(id)__unused sender { - [self.coreComponent cancelUpdateCheckStatus]; + if (self.cancellation != nil) { + self.cancellation(); + self.cancellation = nil; + } [self closeCheckingWindow]; } @@ -264,7 +271,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent completeUpdateCheckStatus]; + self.cancellation = nil; [self closeCheckingWindow]; } @@ -274,28 +281,24 @@ { assert(NSThread.isMainThread); - [self.coreComponent registerAcknowledgement:acknowledgement]; - NSAlert *alert = [[NSAlert alloc] init]; alert.messageText = SULocalizedString(@"Update Error!", nil); alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]]; [alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)]; [self showAlert:alert]; - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { assert(NSThread.isMainThread); - [self.coreComponent registerAcknowledgement:acknowledgement]; - NSAlert *alert = [NSAlert alertWithError:error]; alert.alertStyle = NSAlertStyleInformational; [self showAlert:alert]; - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } - (void)showAlert:(NSAlert *)alert @@ -328,11 +331,11 @@ } } -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation { assert(NSThread.isMainThread); - [self.coreComponent registerDownloadStatusHandler:downloadUpdateStatusCompletion]; + self.cancellation = cancellation; [self showStatusController]; [self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; @@ -341,7 +344,10 @@ - (void)cancelDownload:(id)__unused sender { - [self.coreComponent cancelDownloadStatus]; + if (self.cancellation != nil) { + self.cancellation(); + self.cancellation = nil; + } } - (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength @@ -403,7 +409,7 @@ { assert(NSThread.isMainThread); - [self.coreComponent completeDownloadStatus]; + self.cancellation = nil; [self showStatusController]; [self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; @@ -437,8 +443,6 @@ [self.statusController close]; self.statusController = nil; - [self.coreComponent registerAcknowledgement:acknowledgement]; - // Only show installed prompt when the app is not relaunched // When the app is relaunched, there is enough of a UI from relaunching the app. if (!relaunched) { @@ -467,7 +471,7 @@ [self showAlert:alert]; } - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } #pragma mark Aborting Everything @@ -487,7 +491,8 @@ { assert(NSThread.isMainThread); - [self.coreComponent dismissUpdateInstallation]; + self.installUpdateHandler = nil; + self.cancellation = nil; [self closeCheckingWindow]; diff --git a/Sparkle/SPUStatusCompletionResults.h b/Sparkle/SPUStatusCompletionResults.h index 38d5a6a4..0283c119 100644 --- a/Sparkle/SPUStatusCompletionResults.h +++ b/Sparkle/SPUStatusCompletionResults.h @@ -18,16 +18,6 @@ #import #endif -typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) { - SPUUserInitiatedCheckDone, - SPUUserInitiatedCheckCanceled -}; - -typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) { - SPUDownloadUpdateDone, - SPUDownloadUpdateCanceled -}; - typedef NS_ENUM(NSUInteger, SPUInstallUpdateStatus) { SPUInstallUpdateNow, SPUInstallAndRelaunchUpdateNow, @@ -45,4 +35,16 @@ typedef NS_ENUM(NSInteger, SPUInformationalUpdateAlertChoice) { SPUSkipThisInformationalVersionChoice }; +// Deprecated +typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) { + SPUUserInitiatedCheckDone, + SPUUserInitiatedCheckCanceled +}; + +// Deprecated +typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) { + SPUDownloadUpdateDone, + SPUDownloadUpdateCanceled +}; + #endif /* SPUStatusCompletionResults_h */ diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 192f2277..a52fcc76 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -201,21 +201,32 @@ - (void)downloadDriverWillBeginDownload { - [self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) { - switch (downloadCompletionStatus) { - case SPUDownloadUpdateDone: - break; - case SPUDownloadUpdateCanceled: - dispatch_async(dispatch_get_main_queue(), ^{ - if ([self.updaterDelegate respondsToSelector:@selector((userDidCancelDownload:))]) { - [self.updaterDelegate userDidCancelDownload:self.updater]; - } - - [self.delegate uiDriverIsRequestingAbortUpdateWithError:nil]; - }); - break; - } - }]; + void (^cancelDownload)(void) = ^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if ([self.updaterDelegate respondsToSelector:@selector((userDidCancelDownload:))]) { + [self.updaterDelegate userDidCancelDownload:self.updater]; + } + + [self.delegate uiDriverIsRequestingAbortUpdateWithError:nil]; + }); + }; + + if ([self.userDriver respondsToSelector:@selector(showDownloadInitiatedWithCancellation:)]) { + [self.userDriver showDownloadInitiatedWithCancellation:cancelDownload]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [self.userDriver showDownloadInitiatedWithCompletion:^(SPUDownloadUpdateStatus downloadCompletionStatus) { + switch (downloadCompletionStatus) { +#pragma clang diagnostic pop + case SPUDownloadUpdateDone: + break; + case SPUDownloadUpdateCanceled: + cancelDownload(); + break; + } + }]; + } } - (void)downloadDriverDidReceiveExpectedContentLength:(uint64_t)expectedContentLength diff --git a/Sparkle/SPUUpdater.h b/Sparkle/SPUUpdater.h index 33e256f2..ff896eb3 100644 --- a/Sparkle/SPUUpdater.h +++ b/Sparkle/SPUUpdater.h @@ -48,6 +48,13 @@ SU_EXPORT @interface SPUUpdater : NSObject */ - (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate; +/*! + Use -initWithHostBundle:applicationBundle:userDriver:delegate: or SPUStandardUpdaterController standard adapter instead. + + If you want to drop an updater into a nib, use SPUStandardUpdaterController. + */ +- (instancetype)init NS_UNAVAILABLE; + /*! Starts the updater. diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index c4fe937c..2971837e 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -310,12 +310,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification __weak SPUUpdater *weakSelf = self; [self.userDriver showUpdatePermissionRequest:updatePermissionRequest reply:^(SUUpdatePermissionResponse *response) { - SPUUpdater *strongSelf = weakSelf; - if (strongSelf != nil) { - [strongSelf updatePermissionRequestFinishedWithResponse:response]; - // Schedule checks, but make sure we ignore the delayed call from KVO - [strongSelf resetUpdateCycle]; - } + dispatch_async(dispatch_get_main_queue(), ^{ + SPUUpdater *strongSelf = weakSelf; + if (strongSelf != nil) { + [strongSelf updatePermissionRequestFinishedWithResponse:response]; + // Schedule checks, but make sure we ignore the delayed call from KVO + [strongSelf resetUpdateCycle]; + } + }); }]; // We start the update checks and register as observer for changes after the prompt finishes diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index 6625cde9..17151457 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -28,18 +28,7 @@ NS_ASSUME_NONNULL_BEGIN This protocol is used for implementing a user interface for the Sparkle updater. Sparkle's internal drivers tell an object that implements this protocol what actions to take and show to the user. - Every method in this protocol is required (i.e, not optional) and has a void return type and can optionally take a single parameter block, which waits for - a response back from the user driver. Note that every parameter block, or reply, *must* be responded to eventually - - that is, none can be ignored. Furthermore, they can only be replied to *once* - a reply or completion block should be considered - invalidated after it's once used. The faster a reply can be made, the more Sparkle may be able to idle, and so the better. Every method in this protocol can be assumed to be called from the main thread. - - It may be possible for an action that says to invalidate or dismiss something to be called multiple times in succession, and the implementor may choose to ignore further requests. (TODO: This should be verified if this actually can happen in practice). - - Note: Once upon a time, when first developing the user driver API, I had the user driver exist in a separate process from the rest of the framework (this is no longer supported). - If you're familiar with how the higher level XPC APIs work, this explains why some of the decisions above were made - (reply block executed on any thread, reply block replied only once, single reply block, void return types, idleness, no optional methods, ...) - This is somewhat of an artifact now, but I think most of these set of restrictions still enforces a well designed API. */ SU_EXPORT @protocol SPUUserDriver @@ -66,17 +55,15 @@ SU_EXPORT @protocol SPUUserDriver * * Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar. * - * @param updateCheckStatusCompletion A reply indicating whether the initiated update check is done or canceled. - * Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. Replying with SPUUserInitiatedCheckDone - * on the other hand should not be done until -dismissUserInitiatedUpdateCheck is invoked. + * @param cancellation Invoke this cancellation block to cancel the update check. + * Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. */ -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion; +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation; /*! * Dismiss the user initiated update check from the user * * Dismiss whatever was started in -showUserInitiatedUpdateCheckWithCompletion: - * This is an appropriate time to reply with SPUUserInitiatedCheckDone if not having done so already */ - (void)dismissUserInitiatedUpdateCheck; @@ -192,12 +179,9 @@ SU_EXPORT @protocol SPUUserDriver * * Let the user know that downloading the new update started. * - * @param downloadUpdateStatusCompletion A reply of SPUDownloadUpdateCanceled can be used to cancel - * the download at any point before -showDownloadDidStartExtractingUpdate is invoked. - * A reply of SPUDownloadUpdateDone signifies that the download is done, which should not be invoked until - * -showDownloadDidStartExtractingUpdate + * @param cancellation Invoke this cancellation block to cancel the download at any point before -showDownloadDidStartExtractingUpdate is invoked. */ -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion; +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation; /*! * Show the user the content length of the new update that will be downloaded @@ -219,7 +203,6 @@ SU_EXPORT @protocol SPUUserDriver /*! * Show the user that the update finished downloading and started extracting * - * This is an appropriate time to reply with SPUDownloadUpdateDone if not done so already * Sparkle uses this to show an indeterminate progress bar. * * Note that an update can resume at this point after having been downloaded before, @@ -286,14 +269,23 @@ SU_EXPORT @protocol SPUUserDriver /*! * Dismiss the current update installation * - * Stop and tear down everything. Reply to all outstanding reply/completion blocks. + * Stop and tear down everything. * Dismiss all update windows, alerts, progress, etc from the user. * Basically, stop everything that could have been started. Sparkle may invoke this when aborting or finishing an update. */ - (void)dismissUpdateInstallation; +/* + * Below are deprecated methods that have been replaced by better alternatives. + * The deprecated methods will be used if the alternatives have not been implemented yet. + * In the future support for using these deprecated methods may be removed however. + */ @optional +- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion __deprecated_msg("Implement -showUserInitiatedUpdateCheckWithCancellation: instead"); + +- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion __deprecated_msg("Implement -showDownloadInitiatedWithCancellation: instead"); + - (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateNotFoundWithError:acknowledgement: instead"); - (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateInstalledAndRelaunched:acknowledgement: instead"); diff --git a/Sparkle/SPUUserDriverCoreComponent.h b/Sparkle/SPUUserDriverCoreComponent.h deleted file mode 100644 index 4ccfdab3..00000000 --- a/Sparkle/SPUUserDriverCoreComponent.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// SUUserDriverCoreComponent.h -// Sparkle -// -// Created by Mayur Pawashe on 3/4/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#if __has_feature(modules) -#if __has_warning("-Watimport-in-framework-header") -#pragma clang diagnostic ignored "-Watimport-in-framework-header" -#endif -@import Foundation; -#else -#import -#endif -#import "SPUStatusCompletionResults.h" -#import "SUExport.h" - -@protocol SPUStandardUserDriverDelegate; - -SU_EXPORT @interface SPUUserDriverCoreComponent : NSObject - -- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler; -- (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice; - -- (void)registerUpdateCheckStatusHandler:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion; -- (void)cancelUpdateCheckStatus; -- (void)completeUpdateCheckStatus; - -- (void)registerDownloadStatusHandler:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion; -- (void)cancelDownloadStatus; -- (void)completeDownloadStatus; - -- (void)registerAcknowledgement:(void (^)(void))acknowledgement; -- (void)acceptAcknowledgement; - -- (void)dismissUpdateInstallation; - -@end diff --git a/Sparkle/SPUUserDriverCoreComponent.m b/Sparkle/SPUUserDriverCoreComponent.m deleted file mode 100644 index b9f8db91..00000000 --- a/Sparkle/SPUUserDriverCoreComponent.m +++ /dev/null @@ -1,124 +0,0 @@ -// -// SUUserDriverCoreComponent.m -// Sparkle -// -// Created by Mayur Pawashe on 3/4/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import "SPUUserDriverCoreComponent.h" - - -#include "AppKitPrevention.h" - -@interface SPUUserDriverCoreComponent () - -@property (nonatomic, copy) void (^installUpdateHandler)(SPUInstallUpdateStatus); -@property (nonatomic, copy) void (^updateCheckStatusCompletion)(SPUUserInitiatedCheckStatus); -@property (nonatomic, copy) void (^downloadStatusCompletion)(SPUDownloadUpdateStatus); -@property (nonatomic, copy) void (^acknowledgement)(void); - -@end - -@implementation SPUUserDriverCoreComponent - -@synthesize installUpdateHandler = _installUpdateHandler; -@synthesize updateCheckStatusCompletion = _updateCheckStatusCompletion; -@synthesize downloadStatusCompletion = _downloadStatusCompletion; -@synthesize acknowledgement = _acknowledgement; - -#pragma mark Install Updates - -- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler -{ - self.installUpdateHandler = installUpdateHandler; -} - -- (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice -{ - if (self.installUpdateHandler != nil) { - self.installUpdateHandler(choice); - self.installUpdateHandler = nil; - } -} - -- (void)dismissInstallAndRestart -{ - if (self.installUpdateHandler != nil) { - self.installUpdateHandler(SPUDismissUpdateInstallation); - self.installUpdateHandler = nil; - } -} - -#pragma mark Update Check Status - -- (void)registerUpdateCheckStatusHandler:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion -{ - self.updateCheckStatusCompletion = updateCheckStatusCompletion; -} - -- (void)cancelUpdateCheckStatus -{ - if (self.updateCheckStatusCompletion != nil) { - self.updateCheckStatusCompletion(SPUUserInitiatedCheckCanceled); - self.updateCheckStatusCompletion = nil; - } -} - -- (void)completeUpdateCheckStatus -{ - if (self.updateCheckStatusCompletion != nil) { - self.updateCheckStatusCompletion(SPUUserInitiatedCheckDone); - self.updateCheckStatusCompletion = nil; - } -} - -#pragma mark Download Status - -- (void)registerDownloadStatusHandler:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion -{ - self.downloadStatusCompletion = downloadUpdateStatusCompletion; -} - -- (void)cancelDownloadStatus -{ - if (self.downloadStatusCompletion != nil) { - self.downloadStatusCompletion(SPUDownloadUpdateCanceled); - self.downloadStatusCompletion = nil; - } -} - -- (void)completeDownloadStatus -{ - if (self.downloadStatusCompletion != nil) { - self.downloadStatusCompletion(SPUDownloadUpdateDone); - self.downloadStatusCompletion = nil; - } -} - -#pragma mark Simple Acknoledgments - -- (void)registerAcknowledgement:(void (^)(void))acknowledgement -{ - self.acknowledgement = acknowledgement; -} - -- (void)acceptAcknowledgement -{ - if (self.acknowledgement != nil) { - self.acknowledgement(); - self.acknowledgement = nil; - } -} - -#pragma mark Aborting Everything - -- (void)dismissUpdateInstallation -{ - [self acceptAcknowledgement]; - [self cancelUpdateCheckStatus]; - [self cancelDownloadStatus]; - [self dismissInstallAndRestart]; -} - -@end diff --git a/Sparkle/SPUUserInitiatedUpdateDriver.m b/Sparkle/SPUUserInitiatedUpdateDriver.m index dd1b0064..5bcdaa28 100644 --- a/Sparkle/SPUUserInitiatedUpdateDriver.m +++ b/Sparkle/SPUUserInitiatedUpdateDriver.m @@ -50,19 +50,30 @@ } else { self.showingUserInitiatedProgress = YES; - [self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) { - switch (completionStatus) { - case SPUUserInitiatedCheckDone: - break; - case SPUUserInitiatedCheckCanceled: - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.showingUserInitiatedProgress) { - [self abortUpdate]; - } - }); - break; - } - }]; + void (^cancelUpdateCheck)(void) = ^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.showingUserInitiatedProgress) { + [self abortUpdate]; + } + }); + }; + + if ([self.userDriver respondsToSelector:@selector(showUserInitiatedUpdateCheckWithCancellation:)]) { + [self.userDriver showUserInitiatedUpdateCheckWithCancellation:cancelUpdateCheck]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [self.userDriver showUserInitiatedUpdateCheckWithCompletion:^(SPUUserInitiatedCheckStatus completionStatus) { +#pragma clang diagnostic pop + switch (completionStatus) { + case SPUUserInitiatedCheckDone: + break; + case SPUUserInitiatedCheckCanceled: + cancelUpdateCheck(); + break; + } + }]; + } [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO includesSkippedUpdates:YES]; } diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 2217f78d..0065dde1 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -91,7 +91,7 @@ static NSMutableDictionary *sharedUpdaters = nil; // This will be used when the updater is instantiated in a nib such as MainMenu - (instancetype)init { - SULog(SULogLevelDefault, @"DEPRECATION: SUUpdater is now deprecated. Please use SPUStandardUpdaterController as a nib instantiated replacement, or SPUUpdater."); + SULog(SULogLevelDefault, @"DEPRECATION: SUUpdater is deprecated in Sparkle 2 but functional for transitional purposes. Please migrate to SPUStandardUpdaterController as a nib instantiated replacement, or SPUUpdater."); return [self initForBundle:[NSBundle mainBundle]]; } diff --git a/Sparkle/Sparkle.h b/Sparkle/Sparkle.h index a3ec078f..8ec3e01e 100644 --- a/Sparkle/Sparkle.h +++ b/Sparkle/Sparkle.h @@ -32,7 +32,6 @@ #import "SPUUserDriver.h" #import "SPUStandardUserDriver.h" #import "SPUStandardUserDriverDelegate.h" -#import "SPUUserDriverCoreComponent.h" #import "SPUDownloadData.h" #import "SUUpdater.h" // deprecated diff --git a/Sparkle/SparkleCore.h b/Sparkle/SparkleCore.h index 5d3521e7..118672aa 100644 --- a/Sparkle/SparkleCore.h +++ b/Sparkle/SparkleCore.h @@ -29,7 +29,6 @@ #import "SPUUpdatePermissionRequest.h" #import "SUUpdatePermissionResponse.h" #import "SPUUserDriver.h" -#import "SPUUserDriverCoreComponent.h" #import "SPUDownloadData.h" #pragma clang diagnostic pop diff --git a/TestApplication/SUPopUpTitlebarUserDriver.m b/TestApplication/SUPopUpTitlebarUserDriver.m index 58d14125..e1c28838 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.m +++ b/TestApplication/SUPopUpTitlebarUserDriver.m @@ -13,7 +13,6 @@ @property (nonatomic, readonly) NSWindow *window; @property (nonatomic, nullable) SUInstallUpdateViewController *installUpdateViewController; -@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic) NSTitlebarAccessoryViewController *accessoryViewController; @property (nonatomic) BOOL addedAccessory; @property (nonatomic) NSButton *updateButton; @@ -27,7 +26,6 @@ @synthesize window = _window; @synthesize installUpdateViewController = _installUpdateViewController; -@synthesize coreComponent = _coreComponent; @synthesize accessoryViewController = _accessoryViewController; @synthesize addedAccessory = _addedAccessory; @synthesize updateButton = _updateButton; @@ -40,7 +38,6 @@ self = [super init]; if (self != nil) { _window = window; - _coreComponent = [[SPUUserDriverCoreComponent alloc] init]; } return self; } @@ -189,63 +186,52 @@ - (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler { - [self.coreComponent registerInstallUpdateHandler:installUpdateHandler]; - - __weak SUPopUpTitlebarUserDriver *weakSelf = self; [self addUpdateButtonWithTitle:@"Install & Relaunch" action:^(NSButton *__unused button) { - [weakSelf.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + installUpdateHandler(SPUInstallAndRelaunchUpdateNow); }]; } #pragma mark Check for Updates -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerUpdateCheckStatusHandler:updateCheckStatusCompletion]; - [self addUpdateButtonWithTitle:@"Checking for Updates…"]; } - (void)dismissUserInitiatedUpdateCheck { - [self.coreComponent completeUpdateCheckStatus]; [self removeUpdateButton]; } #pragma mark Update Errors -- (void)acceptAcknowledgementAfterDelay +- (void)acceptAcknowledgementAfterDelay:(void (^)(void))acknowledgement { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // Installation will be dismissed shortly after this - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); }); } - (void)showUpdaterError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - NSLog(@"Error: %@", error); [self addUpdateButtonWithTitle:@"Update Errored!" action:nil]; - [self acceptAcknowledgementAfterDelay]; + [self acceptAcknowledgementAfterDelay:acknowledgement]; } - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - [self addUpdateButtonWithTitle:@"No Update Available" action:nil]; - [self acceptAcknowledgementAfterDelay]; + [self acceptAcknowledgementAfterDelay:acknowledgement]; } #pragma mark Download & Install Updates -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerDownloadStatusHandler:downloadUpdateStatusCompletion]; } - (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength @@ -272,7 +258,6 @@ - (void)showDownloadDidStartExtractingUpdate { - [self.coreComponent completeDownloadStatus]; [self addUpdateButtonWithTitle:@"Extracting…"]; } @@ -294,19 +279,15 @@ - (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - [self addUpdateButtonWithTitle:@"Installation Finished!"]; - [self acceptAcknowledgementAfterDelay]; + [self acceptAcknowledgementAfterDelay:acknowledgement]; } #pragma mark Aborting Everything - (void)dismissUpdateInstallation { - [self.coreComponent dismissUpdateInstallation]; - [self removeUpdateButton]; } diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index ad003e49..84aff79a 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -204,7 +204,6 @@ static NSString * const UPDATED_VERSION = @"2.0"; - (void)signApplicationIfRequiredAtPath:(NSString *)applicationPath completion:(void (^)(void))completionBlock { -#ifdef DEBUG // This is unfortunately necessary for testing sandboxing NSXPCConnection *codeSignConnection = [[NSXPCConnection alloc] initWithServiceName:@"org.sparkle-project.TestAppHelper"]; codeSignConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(TestAppHelperProtocol)]; @@ -216,10 +215,6 @@ static NSString * const UPDATED_VERSION = @"2.0"; completionBlock(); }]; -#else - (void)(applicationPath); // ignore unused warning - completionBlock(); -#endif } - (void)applicationWillTerminate:(NSNotification * __unused)notification diff --git a/TestApplication/Sparkle-Test-App.entitlements b/TestApplication/Sparkle-Test-App.entitlements index 35049e47..b9e43ba8 100644 --- a/TestApplication/Sparkle-Test-App.entitlements +++ b/TestApplication/Sparkle-Test-App.entitlements @@ -6,9 +6,16 @@ com.apple.security.network.server + com.apple.security.network.client + + com.apple.security.temporary-exception.mach-lookup.global-name + + $(PRODUCT_BUNDLE_IDENTIFIER)-spks + $(PRODUCT_BUNDLE_IDENTIFIER)-spki + com.apple.security.temporary-exception.shared-preference.read-write - org.sparkle-project.SparkleTestApp + $(PRODUCT_BUNDLE_IDENTIFIER) diff --git a/TestApplication/TestApplication-Info.plist b/TestApplication/TestApplication-Info.plist index 428c815c..0672481c 100644 --- a/TestApplication/TestApplication-Info.plist +++ b/TestApplication/TestApplication-Info.plist @@ -30,5 +30,10 @@ http://localhost:1337/sparkletestcast.xml SUPublicEDKey eRFPLZuNM6m8bltmtpPX4fzKbufI1z6rKJHtgIIsllk= + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/bin/codesign_embedded_executable b/bin/codesign_embedded_executable deleted file mode 100755 index 2337949a..00000000 --- a/bin/codesign_embedded_executable +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -import os, sys, subprocess - -def log_message(message): - sys.stderr.write(message + "\n") - -#Surround a token with double quotes if it has a space in it -def sanitize(argument): - return ('"' + argument + '"' if ' ' in argument else argument) - -def _codesign_service(identity, path, entitlements_path=None): - command = ["codesign", "-o", "runtime", "-fs", identity, path] + ([] if entitlements_path is None else ["--entitlements", entitlements_path]) - log_message(" ".join(map(sanitize, command))) - - process = subprocess.Popen(command, stdout=subprocess.PIPE) - process.communicate() - if process.returncode != 0: - log_message("Error: Failed to codesign %s" % (path)) - sys.exit(1) - -def codesign_service(service_name, identity, path, entitlements_path=None): - #Sign the auxiliary executables (if any) - executables_path = os.path.join(path, "Contents/MacOS/") - if os.path.exists(executables_path): - for executable in os.listdir(executables_path): - if executable != service_name: - _codesign_service(identity, os.path.join(executables_path, executable), entitlements_path) - - #Sign the service bundle - _codesign_service(identity, path, entitlements_path) - -if __name__ == "__main__": - if len(sys.argv) < 3: - log_message("Usage:\n\t%s code-signing-identity executable1 executable1 ..." % (sys.argv[0])) - log_message("Example:\n\t%s \"Developer ID Application\" ./XPCServices/*.xpc" % (sys.argv[0])) - sys.exit(1) - - signing_identity = sys.argv[1] - executables = sys.argv[2:] - - for executable in executables: - parent, child = os.path.split(executable) - service_name = os.path.splitext(child)[0] - entitlements_path = os.path.join(parent, service_name + ".entitlements") - codesign_service(service_name, signing_identity, executable, None if not os.path.exists(entitlements_path) else entitlements_path) diff --git a/sparkle-cli/SPUCommandLineUserDriver.m b/sparkle-cli/SPUCommandLineUserDriver.m index fcb2b46b..edf05cbd 100644 --- a/sparkle-cli/SPUCommandLineUserDriver.m +++ b/sparkle-cli/SPUCommandLineUserDriver.m @@ -17,7 +17,6 @@ @property (nonatomic, nullable, readonly) SUUpdatePermissionResponse *updatePermissionResponse; @property (nonatomic, readonly) BOOL deferInstallation; @property (nonatomic, readonly) BOOL verbose; -@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic) uint64_t bytesDownloaded; @property (nonatomic) uint64_t bytesToDownload; @@ -28,7 +27,6 @@ @synthesize updatePermissionResponse = _updatePermissionResponse; @synthesize deferInstallation = _deferInstallation; @synthesize verbose = _verbose; -@synthesize coreComponent = _coreComponent; @synthesize bytesDownloaded = _bytesDownloaded; @synthesize bytesToDownload = _bytesToDownload; @@ -39,7 +37,6 @@ _updatePermissionResponse = updatePermissionResponse; _deferInstallation = deferInstallation; _verbose = verbose; - _coreComponent = [[SPUUserDriverCoreComponent alloc] init]; } return self; } @@ -62,9 +59,8 @@ } } -- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion +- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerUpdateCheckStatusHandler:updateCheckStatusCompletion]; if (self.verbose) { fprintf(stderr, "Checking for Updates...\n"); } @@ -72,7 +68,6 @@ - (void)dismissUserInitiatedUpdateCheck { - [self.coreComponent completeUpdateCheckStatus]; } - (void)displayReleaseNotes:(const char * _Nullable)releaseNotes @@ -124,16 +119,15 @@ - (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)__unused userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply { - [self.coreComponent registerInstallUpdateHandler:reply]; [self showUpdateWithAppcastItem:appcastItem updateAdjective:@"resumable"]; if (self.deferInstallation) { if (self.verbose) { fprintf(stderr, "Deferring Installation.\n"); } - [self.coreComponent installUpdateWithChoice:SPUDismissUpdateInstallation]; + reply(SPUDismissUpdateInstallation); } else { - [self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + reply(SPUInstallAndRelaunchUpdateNow); } } @@ -187,10 +181,8 @@ exit(EXIT_FAILURE); } -- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion +- (void)showDownloadInitiatedWithCancellation:(void (^)(void))__unused cancellation { - [self.coreComponent registerDownloadStatusHandler:downloadUpdateStatusCompletion]; - if (self.verbose) { fprintf(stderr, "Downloading Update...\n"); } @@ -221,8 +213,6 @@ - (void)showDownloadDidStartExtractingUpdate { - [self.coreComponent completeDownloadStatus]; - if (self.verbose) { fprintf(stderr, "Extracting update...\n"); } @@ -237,15 +227,13 @@ - (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler { - [self.coreComponent registerInstallUpdateHandler:installUpdateHandler]; - if (self.deferInstallation) { if (self.verbose) { fprintf(stderr, "Deferring Installation.\n"); } - [self.coreComponent installUpdateWithChoice:SPUDismissUpdateInstallation]; + installUpdateHandler(SPUDismissUpdateInstallation); } else { - [self.coreComponent installUpdateWithChoice:SPUInstallAndRelaunchUpdateNow]; + installUpdateHandler(SPUInstallAndRelaunchUpdateNow); } } @@ -258,13 +246,11 @@ - (void)showUpdateInstalledAndRelaunched:(BOOL)__unused relaunched acknowledgement:(void (^)(void))acknowledgement { - [self.coreComponent registerAcknowledgement:acknowledgement]; - if (self.verbose) { fprintf(stderr, "Installation Finished.\n"); } - [self.coreComponent acceptAcknowledgement]; + acknowledgement(); } - (void)dismissUpdateInstallation __attribute__((noreturn))