Skip to main content

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:32
Two-Part Update System
  • UpdateService (this page) - Fetches release metadata from GitHub API
  • AppUpdater - Downloads DMG and installs updates
Together they provide automatic updates by checking GitHub releases and installing new versions.

UpdateService

Type Definition

Implemented as an enum with static methods (no instances).

checkForUpdate()

Fetches the latest release from GitHub and returns it if newer than the running version.
Returns: GitHubRelease if a newer version is available, nil if current version is up to date. Throws: Network errors or JSON decoding errors.

Implementation Details

The method:
  1. Fetches the latest release from https://api.github.com/repos/xaif/r2Vault/releases/latest
  2. Sets Accept header to application/vnd.github+json for GitHub API v3
  3. Decodes the JSON response into a GitHubRelease object
  4. Strips leading “v” from tag name (e.g., “v1.2.3” → “1.2.3”)
  5. Compares versions numerically (1.2.3 < 1.10.0)
  6. Returns release if newer, nil otherwise

API URL

Points to the GitHub Releases API for the r2Vault repository.

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

Finds the first DMG asset and returns its download URL.

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

Update SecurityThe current implementation:
  • Uses HTTPS for GitHub API (transport security)
  • Removes quarantine attributes (com.apple.quarantine)
  • Does NOT verify code signatures
  • Does NOT verify DMG checksums
For production apps, consider:
  • Verifying DMG checksums from GitHub release notes
  • Checking code signatures before installation
  • Using Apple’s Sparkle framework for updates
  • Implementing delta updates for bandwidth efficiency

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
  • MenuBarManager - Can display update notifications
  • GitHub Releases API - Source of update metadata