Skip to content

Instantly share code, notes, and snippets.

@steipete
Last active May 5, 2021 15:18
Show Gist options
  • Save steipete/450e1f2ec439df0a3a4b3578b46f4e42 to your computer and use it in GitHub Desktop.
Save steipete/450e1f2ec439df0a3a4b3578b46f4e42 to your computer and use it in GitHub Desktop.
Sparkle + SwiftUI
lass AppUpdateHandler: ObservableObject {
#if SPARKLE
private let delegateHandler = SparkleDelegateHandler()
let sparkle: SPUStandardUpdaterController
init() {
// Setup sparkle updater
// https://docs.microsoft.com/en-us/appcenter/distribution/sparkleupdates
// https://rambo.codes/posts/2021-01-08-distributing-mac-apps-outside-the-app-store
sparkle = SPUStandardUpdaterController(updaterDelegate: delegateHandler, userDriverDelegate: delegateHandler)
}
func checkForUpdates() {
// https://sparkle-project.org/documentation/
sparkle.checkForUpdates(delegateHandler)
}
private class SparkleDelegateHandler: NSObject, SPUUpdaterDelegate, SPUStandardUserDriverDelegate {
func feedURLString(for updater: SPUUpdater) -> String? {
"https://api.appcenter.ms/..." // or whatever you use
}
}
#endif
}
@steipete
Copy link
Author

steipete commented May 5, 2021

Yes, you need to follow the 2.0 integration guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment