Sparkle Software Updates
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Sparkle Software Update system in Buddi provides an automated mechanism for detecting, downloading, and installing application updates. Built on the Sparkle framework, it ensures that users can stay up-to-date with the latest features and security patches through a native macOS interface integrated into the application's settings and notch menu.
The system utilizes an Appcast feed to track versioning and distribution metadata. Within the application, it provides both a traditional settings interface for configuration and a streamlined update row within the Notch UI for real-time status monitoring and interaction.
Sources: buddi/components/Settings/SoftwareUpdater.swift:1-10, buddi/Buddi/UI/Views/NotchMenuView.swift:110-120, Updates/appcast.xml:1-5
System Architecture
Component Hierarchy
The update system is composed of several layers, from the remote XML feed to the SwiftUI view models that drive the user interface.
This diagram shows the flow of update information from the remote metadata feed through the internal managers to the various UI components.
Sources: buddi/components/Settings/SoftwareUpdater.swift:10-25, buddi/Buddi/UI/Views/NotchMenuView.swift:130-150
Update Metadata (Appcast)
The foundation of the update process is the appcast.xml file. This RSS feed contains items representing specific releases, including version numbers and enclosure links to the .dmg installation files.
| Element | Description |
|---|---|
sparkle:version | The internal build version number. |
sparkle:shortVersionString | The user-facing version string (e.g., 0.1.0). |
sparkle:minimumSystemVersion | The lowest macOS version supported by the update. |
enclosure url | The direct download link to the update package. |
pubDate | The release timestamp of the update. |
Sources: Updates/appcast.xml:4-14
Implementation Details
View Model Logic
The CheckForUpdatesViewModel acts as an observer for the SPUUpdater. It specifically monitors the canCheckForUpdates property to ensure the UI remains synchronized with the internal state of the Sparkle engine.
final class CheckForUpdatesViewModel: ObservableObject {
@Published var canCheckForUpdates = false
init(updater: SPUUpdater) {
updater.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}
}
Sources: buddi/components/Settings/SoftwareUpdater.swift:10-18
UI Integration
The system is exposed to the user through three primary interfaces:
- UpdaterSettingsView: Found in the application settings, allowing users to toggle "Automatically check for updates" and "Automatically download updates".
- UpdateRow: A dynamic row in the
NotchMenuViewthat reflects the current state of the update lifecycle (Checking, Downloading, Extracting, Ready to Install). - SparkleView: Used during onboarding or specific update transitions to provide visual feedback via a
CAEmitterLayersparkle effect.
Sources: buddi/components/Settings/SoftwareUpdater.swift:42-65, buddi/Buddi/UI/Views/NotchMenuView.swift:163-220, buddi/components/Onboarding/SparkleView.swift:10-30
Update Lifecycle Flow
The UpdateManager (referenced in NotchMenuView) manages a state machine that transitions through the following phases:
This state machine represents the sequence of events from initial check to final installation and application relaunch.
Sources: buddi/Buddi/UI/Views/NotchMenuView.swift:233-280
Configuration Options
Users can configure the behavior of the Sparkle engine through settings which persist via the SPUUpdater instance.
| Option | Type | Description |
|---|---|---|
automaticallyChecksForUpdates | Boolean | Whether the app polls the appcast feed without user intervention. |
automaticallyDownloadsUpdates | Boolean | Whether the app pre-fetches update files once discovered. |
notificationSound | String | The sound played when an update is ready (defaulting to "Pop"). |
Sources: buddi/components/Settings/SoftwareUpdater.swift:51-60, buddi/models/Constants.swift:165-170
Conclusion
The Sparkle Software Update system provides a robust, state-aware framework for application maintenance. By leveraging the SPUUpdater and a structured Appcast feed, Buddi maintains a seamless update experience that bridges traditional settings with the innovative Notch-based UI.
Sources: buddi/components/Settings/SoftwareUpdater.swift:1-5, buddi/Buddi/UI/Views/NotchMenuView.swift:110-120