---
title: "Updates with Sparkle"
description: "Sparkle 2 in a CefSwift app: keys, signing Sparkle's helpers, appcasts, deltas and their sizes."
---

```sh
cd Examples/SparkleUpdates
./demo.sh   # bundles 1.0 and 1.1, makes the appcast, serves it and opens 1.0
```

## Shipping updates with Sparkle

CefSwift has no updater of its own and does not depend on one.
[Sparkle 2](https://sparkle-project.org) updates a CefSwift app as it does
any Mac app. What differs is the size (Chromium's framework is most of the
app), the helper apps and Sparkle's own helpers, which must all carry the
app's signature, and notarization. The SparkleUpdates example
(`Examples/SparkleUpdates`, a package of its own) has one window, Check
for Updates… in the app menu, and `demo.sh`, which builds 1.0 and 1.1,
makes the appcast and installs the update from a local server.

**Add Sparkle** to the app's target, and give the bundle a feed and the
public half of an EdDSA key in cefapp.json's `infoPlist`:

```swift
// Package.swift (doc-samples: skip)
.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.10.1"),
// the app's target:
.product(name: "Sparkle", package: "Sparkle"),
```

```jsonc
// cefapp.json
"infoPlist": {
  "SUFeedURL": "https://example.com/myapp/appcast.xml",
  "SUPublicEDKey": "…the key generate_keys prints…",
  "SUEnableAutomaticChecks": true,
},
```

`cef bundle --info-plist <file>` adds a plist's keys on top, which is how
`demo.sh` gives each build its key and local feed. Start the updater in the
app's `init` (CefSwift has created the application by then) and put Check
for Updates… in the app menu:

```swift
// doc-samples: skip (needs the Sparkle package)
import Sparkle

let updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
// In the app's commands:
CommandGroup(after: .appInfo) {
    Button("Check for Updates…") { updater.updater.checkForUpdates() }
}
```

**Keys.** Sparkle's tools come with the package, in
`.build/artifacts/sparkle/Sparkle/bin` once it is resolved.
`generate_keys` creates the key pair, keeps the private key in the login
keychain and prints the public one for `SUPublicEDKey`; `generate_keys -x
<file>` exports the private key for a release machine, which signs with
`generate_appcast --ed-key-file <file>`. One key signs every update the app
will ever accept: keep it out of the repository, and back it up, since an
app whose key is lost can only be updated by downloading it again. (The
demo makes a throwaway pair with CryptoKit for each run instead, so it
never touches the keychain; `generate_appcast` reading the keychain asks
for permission in a dialog.)

**Bundling and signing.** `cef bundle` copies `Sparkle.framework` into
`Contents/Frameworks` with the app's other libraries, from where SwiftPM
unpacked the binary target (`.build/artifacts`). The framework holds four
programs of its own (`Autoupdate`, `Updater.app`, `Installer.xpc` and
`Downloader.xpc`), which Sparkle's package signs ad hoc. `cef bundle`
signs each with the app's identity, the hardened runtime and the secure
timestamp, inside out and keeping the entitlements it was signed with
(less `com.apple.application-identifier`, which `Autoupdate` carries from
Sparkle's own build and which a team signature would need a provisioning
profile for), then the framework, then the app, as notarization requires
and as `codesign --deep` would not. The XPC services are used only by
sandboxed apps: Sparkle starts them only when the Info.plist asks for them
(`SUEnableInstallerLauncherService`, `SUEnableDownloaderService`), which a
CefSwift app, never sandboxed, does not. An Xcode target embeds and signs
Sparkle with Xcode's own Embed & Sign, as for any app.

**Notarizing.** Notarize each release as any other
([Distribution builds](/ship/notarization#distribution-builds-developer-id-notarized)).
`--notarize` staples the ticket and zips the stapled app again, so
`dist/MyApp.zip` is the update archive: a copy Sparkle installs carries
its ticket.

```sh
swift package --allow-writing-to-package-directory --allow-network-connections all \
    cef bundle --product MyApp --version 1.1 --build 12 \
    --sign "Developer ID Application: Example Corp (A1B2C3D4E5)" --notarize --keychain-profile notary
cp dist/MyApp.zip updates/MyApp-1.1.zip
```

`CFBundleVersion` (`--build`) is what Sparkle compares; raise it with
every release.

**The appcast and deltas.** Put each release's archive in one folder and
run `generate_appcast` on it: it writes `appcast.xml`, signs each archive
with the EdDSA key, and makes delta updates from earlier versions it
finds there (`--maximum-deltas`, five by default). Upload the archives,
the deltas and the appcast to the server `SUFeedURL` names, over HTTPS.

**What the demo shows.** `Examples/SparkleUpdates/demo.sh --unattended`,
with the Command Line Tools and signed ad hoc: 1.0 reads the appcast from
`127.0.0.1`, downloads the delta, verifies its EdDSA signature, installs
1.1 in place and relaunches it, about 5 seconds after launch, and the
installed app's signature verifies. Without `--unattended`, App menu ›
Check for Updates… offers 1.1 in Sparkle's own window. Two things are for
a local run only. The feed is plain HTTP, which the demo allows with
`NSAllowsLocalNetworking` in its Info.plist overlay; a real feed is HTTPS.
The builds are signed ad hoc, so each has a signature of its own:
`generate_appcast` warns that the two signing identities differ, and
Sparkle accepts the update on its EdDSA signature alone. A release signed
with one Developer ID passes both checks. The app installs without
notarization here because a copy built on this Mac carries no quarantine;
on any other Mac, Gatekeeper needs the notarized archive above.

**Sizes.** The SparkleUpdates example (English only) on CEF 158.0.6, signed
ad hoc, and the Browser example (every locale pack) on the same CEF:

| | SparkleUpdates | Browser |
|---|---|---|
| The app (`du`) | 303 MiB: Chromium's framework 288 MiB, Sparkle 2.8 MiB | 358 MiB: Chromium's framework 338 MiB |
| Its update archive (`ditto` zip) | 144.0 MB | 158.9 MB |
| A delta from 1.0 to 1.1 (`BinaryDelta`) | 3.5 KB (the version alone) | 26.7 KB (a change to the app's code) |

Chromium's framework is nearly all of every full download, and it changes
only when CEF does, so a delta between two releases on the same CEF
carries the app's code alone. A release that moves to a new CEF changes the
framework's 246 MB binary: `BinaryDelta` from CEF 156.0.31 to 158.0.6 did
not finish in 42 minutes on an 8 GB M2, so make deltas for such a release
on a bigger machine, or ship it as a full archive (`generate_appcast
--maximum-deltas 0`) and let the deltas resume at the next one.
