You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS下Sparkle静默/后台自动更新配置问题求助

问题

我希望Sparkle在无需用户干预的情况下自动下载并安装更新,已在Info.plist中配置以下参数:

<key>SUEnableAutomaticChecks</key>
<true/>
<key>SUScheduledCheckInterval</key>
<integer>3600</integer>
<key>SUAutomaticallyUpdate</key>
<true/>
<key>SUAllowsAutomaticUpdates</key>
<true/>

但当更新周期(1小时)结束后,仍会弹出新版本可用的提示窗口。

查阅Sparkle文档得知:

In Sparkle 2, updates will be downloaded but not installed automatically if authorization is required. In all versions of Sparkle, if the application hasn’t quit for 1 week the user will be presented with installing the downloaded update (unless the updater delegate overrides this).

我的应用位于Applications文件夹,删除时Finder无需额外权限,不存在授权问题,且更新包为应用zip而非pkg,请问是否还需额外配置或代码实现需求?

解决方案
  • 非沙箱应用需实现代理逻辑:Sparkle 2中SUAutomaticallyUpdate默认只对沙箱应用生效,非沙箱应用即使配置了该键,仍会弹出提示。你需要实现SPUUpdaterDelegate的两个关键方法,跳过所有用户交互:
    // 跳过下载权限提示
    - (BOOL)updaterShouldPromptForPermissionToDownloadUpdates:(SPUUpdater *)updater {
        return NO;
    }
    
    // 自动确认安装更新
    - (BOOL)updater:(SPUUpdater *)updater shouldInstallUpdate:(SUAppcastItem *)update {
        return YES;
    }
    
  • 检查更新包签名一致性:更新包的签名必须和当前应用完全匹配,否则Sparkle会触发安全提示,无法静默完成安装。
  • 处理长运行周期提示:如果应用连续运行超过1周,Sparkle会强制弹出安装提示。若要避免这种情况,需在代理中重写updaterShouldShowInstallUpdateAlert:方法并返回NO:
    - (BOOL)updaterShouldShowInstallUpdateAlert:(SPUUpdater *)updater {
        return NO;
    }
    
  • 确认无其他逻辑干扰:确保没有自定义代码修改了Sparkle的自动更新设置,比如动态禁用SUAllowsAutomaticUpdates。

内容的提问来源于stack exchange,提问作者njLT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 20:12:19