From 692322d9b8a9002422ef26e6c45f9b159795d30e Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 27 Dec 2024 08:16:18 -0500 Subject: [PATCH] macos: disable Sparkle checks in Debug and Release This approach uses Xcode's Info.plist preprocessing to conditionally set `SUEnableAutomaticChecks=false` for the Debug and Release build schemes. It is unset for the ReleaseLocal scheme. When this Info.plist key is explicitly set to false (as it is for these build schemes), we disable auto-updates at runtime. Otherwise, we apply the behavior defined by our "auto-update" configuration. --- macos/Ghostty-Info.plist | 4 ++++ macos/Ghostty.xcodeproj/project.pbxproj | 5 +++++ macos/Sources/App/macOS/AppDelegate.swift | 7 ++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/macos/Ghostty-Info.plist b/macos/Ghostty-Info.plist index 914c6ed6b..17caf19d7 100644 --- a/macos/Ghostty-Info.plist +++ b/macos/Ghostty-Info.plist @@ -96,6 +96,10 @@ +#if SPARKLE_CHECKS_DISABLED + SUEnableAutomaticChecks + +#endif SUPublicEDKey wsNcGf5hirwtdXMVnYoxRIX/SqZQLMOsYlD3q3imeok= diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index 68322756b..3dd37c0ff 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -730,6 +730,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_PREPROCESS = YES; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -843,6 +844,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_PREPROCESS = YES; + INFOPLIST_PREPROCESSOR_DEFINITIONS = "SPARKLE_CHECKS_DISABLED=1"; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -899,6 +902,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_PREPROCESS = YES; + INFOPLIST_PREPROCESSOR_DEFINITIONS = "SPARKLE_CHECKS_DISABLED=1"; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 8d56b91d5..7ebf52d3d 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -484,9 +484,10 @@ class AppDelegate: NSObject, default: UserDefaults.standard.removeObject(forKey: "NSQuitAlwaysKeepsWindows") } - // Sync our auto-update settings - // Local (source) builds always disable the updater - if let commit = Bundle.main.infoDictionary?["GhosttyCommit"] as? String, !commit.isEmpty { + // Sync our auto-update settings. If SUEnableAutomaticChecks (in our Info.plist) is + // explicitly false (NO), auto-updates are disabled. Otherwise, we use the behavior + // defined by our "auto-update" configuration. + if Bundle.main.infoDictionary?["SUEnableAutomaticChecks"] as? Bool != false { updaterController.updater.automaticallyChecksForUpdates = config.autoUpdate == .check || config.autoUpdate == .download updaterController.updater.automaticallyDownloadsUpdates =