我们构建一个 Qt 应用程序使用:https://github.com/therecipe/qt . 现在我们需要一个自动更新程序并找到这个:https://sparkle-project.org

看起来它正在被我机器上的多个应用程序使用:

/Applications/VLC.app/Contents/Frameworks/Sparkle.framework 
/Applications/Adium.app/Contents/Frameworks/Sparkle.framework 
/Applications/TeamViewer.app/Contents/Frameworks/Sparkle.framework 
/Applications/Docker.app/Contents/Frameworks/Sparkle.framework 
... 

一些文章向我展示了如何在 Qt 中使用它:

但它适用于 C++/Objective C 代码。

是否可以与 Golang 一起使用?如果是,怎么办?

请您参考如下方法:

https://github.com/therecipe/qt/issues/743#issuecomment-444689169

Spark .m:

#import <Headers/SUUpdater.h> 
 
static SUUpdater* updater = nil; 
 
void sparkle_checkUpdates() 
{ 
    if (!updater) { 
        updater = [[SUUpdater sharedUpdater] retain]; 
    } 
 
    [updater setUpdateCheckInterval:3600]; 
    [updater checkForUpdatesInBackground]; 
} 

Spark .go:

// +build darwin windows 
 
package main 
 
/* 
#cgo CFLAGS: -I ${SRCDIR}/Sparkle.framework 
#cgo LDFLAGS: -F ${SRCDIR} -framework Sparkle 
 
void sparkle_checkUpdates(); 
*/ 
import "C" 
 
func sparkle_checkUpdates() { 
    C.sparkle_checkUpdates() 
} 

main.go 中调用 func:

action := widgets.NewQMenuBar(nil).AddMenu2("").AddAction("Check for Updates...") 
// http://doc.qt.io/qt-5/qaction.html#MenuRole-enum 
action.SetMenuRole(widgets.QAction__ApplicationSpecificRole) 
action.ConnectTriggered(func(bool) { sparkle_checkUpdates() }) 

appcast.xml:

<?xml version="1.0" standalone="yes"?> 
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0"> 
  <channel> 
    <title>Premium VPN</title> 
    <item> 
      <title>1.0.0.2905</title> 
      <pubDate>Tue, 11 Dec 2018 11:09:10 +0800</pubDate> 
      <sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion> 
      <enclosure url="https://example.com/x.zip" sparkle:version="1.0.0.2905" sparkle:shortVersionString="1.0.0.2905" sparkle:edSignature="$(/path/to/Sparkle/bin/sign_update)" length="104408678" type="application/octet-stream"/> 
    </item> 
  </channel> 
</rss> 

信息.plist:

<key>SUFeedURL</key> 
<string>https://example.com/appcast.xml</string> 
<key>SUPublicEDKey</key> 
<string>$(/path/to/Sparkle/bin/generate_keys)</string> 


评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!