douren8379 2018-12-05 08:50
浏览 212
已采纳

是否可以在Qt(Golang绑定)应用程序中使用Sparkle?

We build a Qt app using: https://github.com/therecipe/qt. Now we need an auto updater and found this: https://sparkle-project.org

Looks like it is being used by multiple apps on my machine:

/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
...

Some articles show me how to use it in Qt:

but it's for C++/Objective C code.

Is it possible to use with Golang? If so, how?

  • 写回答

1条回答 默认 最新

  • dpf7891 2018-12-11 05:02
    关注

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

    sparkle.m:

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

    sparkle.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()
    }
    

    And in main.go, call that 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>
    

    Info.plist:

    <key>SUFeedURL</key>
    <string>https://example.com/appcast.xml</string>
    <key>SUPublicEDKey</key>
    <string>$(/path/to/Sparkle/bin/generate_keys)</string>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用