An auto updating example built for Flutter Desktop that uses Sparkle.
You can easily just download the project and replace the feed url if you wish! Or fork the project template.
More info here: https://sparkle-project.org/documentation/
Add Sparkle to your MacOS macos/Podfile
target 'Runner' do
use_frameworks!
use_modular_headers!
# Extra Pods
pod 'Sparkle' # <-- Add This Line
Open macos/Runner/info.plist
and add the following keys:
<key>SUFeedURL</key>
<string>YOUR_FEED_URL</string>
<key>SUEnableAutomaticChecks</key>
<true/>
Replace YOUR_FEED_URL
with your AppCast url. You can test by using this demo feed.
Open macos/Runner/MainFlutterWindow.swift
and modify it to look like this:
import Cocoa
import FlutterMacOS
import Sparkle
class MainFlutterWindow: NSWindow {
@IBAction func checkForUpdates(_ sender: Any) {
let updater = SUUpdater.shared()
updater?.feedURL = URL(string: "YOUR_FEED_URL")
updater?.checkForUpdates(self)
}
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
super.awakeFromNib()
}
}
Open the application worspace macos/Runner.xcworkspace
.
Add a menu item:
Add a new opbject:
Change the class:
Connect the action by holding shift: