Sparkle 套件是最常見的 Mac App 檢查更新方案
本章介紹如何安裝並使用 Sparkle
Sparkle 套件Sparkle 套件File > Add Package Dependencies...
https://github.com/sparkle-project/Sparkle.git
Sparkle Update ObjectSparkle Updater 的程式碼:import SwiftUI
import Sparkle
struct UpdaterView: View {
    var updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil).updater
    var body: some View {
        Button("檢查更新") {
            updater.checkForUpdates()
        }
        .buttonStyle(.borderedProminent)
    }
}
其他詳細寫法請參考:Sparkle Programmatic Setup
Sparkle 最新版本
Sparkle或是Sparkle-for-Swift-Package-Manager都可以
Sparkle 內以下三個檔案複製到 /bin 底下:./bin/generate_keys
./bin/sign_update
./bin/generate_appcast
$ mv ./bin/generate_keys Users/${user}/.local/bin/generate_keys
$ mv ./bin/sign_update Users/${user}/.local/bin/sign_update
$ mv ./bin/generate_appcast Users/${user}/.local/bin/generate_appcast
$ generate_keys
    <key>SUPublicEDKey</key>
    <string>pfIShU4dEXqPd5ObYNfDBiQWcXozk7estwzTnF9BamQ=</string>
Info.plist 內加上以下幾個參數:| Key | Type | Value | 
|---|---|---|
| SUPublicEDKey | String | 剛剛你產出的 EdDSA | 
| SUFeedURL | String | 填入 appcast.xml 上傳的 URL (步驟五會解釋) | 
如果沒有
Info.plist,可以到專案 Targets 內的Info加上數值

其他參數及說明請參考:Sparkle Customization
Sparkle 使用
Bundle Version來判斷 APP 是否是新版本

.entitlements 檔案的 App Sandbox 設定成 NO
Xcode:Product > Archive
Archive:Distribute app > Direct Distribution> Distribute
Status 變為 Ready to distributeExport Notarized App 輸出 App
Xcode 專案資料夾就是專案
.xcodeproj存在的資料夾

appcast.xml
appcast.xml是Sparkle用來辨認 App 版本的檔案所有的更新資訊,包含版本、更新內容,都需要寫在
appcast.xml內
$ generate_appcast -o appcast.xml .
Xcode 專案資料夾就是專案
.xcodeproj存在的資料夾
appcast.xml,並把專案資料夾內所有版本的 zip 都簽章完成appcast.xml 內:
appcast.xml 上傳到雲端,連結必須是我們在 Info.plist SUFeedURL 填入的 URL