1203 - 搞定 Sparkle

程序中自动升级是个挺麻烦的事。还好,有了 Sparkle,事情变得简单了。

根据 Sparkle 官方教程一步步走下来,还挺顺利的。有 2 个需要注意的地方:

  • sparkle:shortVersionString 对应 XCode 中的 Build, sparkle:shortVersionString 对应 XCode 中的 Version
  • 本地化更新日志:官方说是在 xml:lang 中使用 2 个字母表示的国家,但实际是 zh-Hans 这样的完整标识符。试了好多遍,终于试出来了,感叹我的坚持和机智。

以下是 Sparkle 中的 AppCase 示例,供参考。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>iPic Mover's Changelog</title>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 0.1.0</title>
<description xml:lang="en">
<![CDATA[
<ul>
<li>Feature 1</li>
<li>Feature 2</li>
</ul>
]]>
</description>
<description xml:lang="zh-Hans">
<![CDATA[
<h3>新功能</h3>
<ul>
<li>功能 1</li>
<li>功能 2</li>
</ul>
<a href="https://toolinbox.net">了解更多</a>
]]>
</description>
<pubDate>Sat, 03 Dec 2016 19:20:11 +0000</pubDate>
<enclosure url="http://localhost/~jason/iPicMover/iPicMover_v0.1.0.dmg" sparkle:version="10" sparkle:shortVersionString="0.1.0" type="application/octet-stream" />
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
</item>
</channel>
</rss>