Overview
UpdateService fetches the latest release metadata from the GitHub API and determines if a newer version is available. It works in conjunction with AppUpdater which handles the actual DMG download and installation.
Located at:
Fiaxe/Services/UpdateService.swift:32Two-Part Update System
- UpdateService (this page) - Fetches release metadata from GitHub API
- AppUpdater - Downloads DMG and installs updates
UpdateService
Type Definition
checkForUpdate()
Fetches the latest release from GitHub and returns it if newer than the running version.GitHubRelease if a newer version is available, nil if current version is up to date.
Throws: Network errors or JSON decoding errors.
Implementation Details
- Fetches the latest release from
https://api.github.com/repos/xaif/r2Vault/releases/latest - Sets Accept header to
application/vnd.github+jsonfor GitHub API v3 - Decodes the JSON response into a
GitHubReleaseobject - Strips leading “v” from tag name (e.g., “v1.2.3” → “1.2.3”)
- Compares versions numerically (1.2.3 < 1.10.0)
- Returns release if newer,
nilotherwise
API URL
GitHub Data Types
GitHubRelease
Represents a GitHub release.String
Release version tag (e.g.,
"v1.2.3").String
URL to the release page on GitHub.
String?
Release notes in Markdown format.
[GitHubAsset]
Array of release assets (downloadable files).
URL?
Computed property returning the download URL for the first
.dmg asset.dmgDownloadURL
GitHubAsset
Represents a release asset file.String
Asset filename (e.g.,
"R2Vault-1.2.3.dmg").String
Direct download URL for the asset.
AppUpdater Integration
For complete documentation on the DMG download and installation process, see AppUpdater. The AppUpdater handles:- Downloading DMG files from GitHub releases
- Progress tracking during download
- Mounting and installing updates
- Safety checks for writable locations
- Automatic app replacement and relaunch
Usage Examples
Check for Updates
Download and Install
Automatic Updates
Security Considerations
App Store Distribution
If distributing via the Mac App Store:
- Remove the auto-update system entirely
- App Store handles all updates automatically
- Self-updating violates App Store guidelines
- Can still check GitHub API to notify users of updates
Related Services
- MenuBarManager - Can display update notifications
- GitHub Releases API - Source of update metadata