Using Sparkle: the Basics
Follow this guide, and you’ll have Sparkle up and running in your application in no time at all! Just a few quick steps:
- Link the framework: Drag Sparkle.framework into the Linked Frameworks folder in the Files list of your Xcode project, making sure to check the “Copy items into destination group’s folder” box in the resulting sheet.
- Deploy the framework:
- Create a new Copy Files build phase (Project > New Build Phase) and select Frameworks for the destination.
- Switch to the Project page (⌘-0), find your Target in the files list, and reveal its contents by clicking the disclosure triangle next to it.
- Drag Sparkle.framework from the Linked Frameworks folder to the new Copy Files phase.
- Instantiate the updater:
- Open MainMenu.nib in Interface Builder.
- Click the Classes tab.
- Go to Classes > Read Files..., navigate to your project directory, then import Sparkle.framework/Headers/SUUpdater.h. SUUpdater should now appear in the class list.
- Select SUUpdater and go to Classes > Instantiate SUUpdater.
- Create a “Check for updates...” menu item in the application menu and connect it to checkForUpdates: in SUUpdater (using Control+drag).
- Make an appcast:
- Sparkle uses appcasts for update information. If you already have one, you can skip this section.
- Appcasts are simple: they are RSS feeds with enclosures around software. For Sparkle, these enclosures contain updates to your application. You can make RSS feeds by hand or with the help of another application (Feeder is a nice one).
- Whenever you release a new version of your application, compress the .app into an archive (zip, tar, tbz, tgz, or dmg), name it with the format: YourApp_VersionNumber.zip. For example: Pixen_2.4.zip. Then add a new item to your appcast enclosing that archive.
- The description property (or body) should contain release notes for the update (use HTML, but escape < and > with < and > or CDATA tags) or the URL of a web page with the release notes to display. If you don’t want to display release notes, set SUShowReleaseNotes to <false/> (or No in Property List Editor) in Info.plist.
- Sparkle adds some new attributes and properties to the RSS standard (more on those later). To use these features, you’ll need to add a URI to your <rss> tag like this:
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"> - See the Appcast Sample section later in this document for a sample feed you can use.
- Enter your appcast’s URL: open your target’s Info.plist and add an SUFeedURL key set to the URL of your appcast:
<key>SUFeedURL</key> <string>http://www.yourdomain.com/app/example.xml</string>
And that’s it! You’re done! Build and run, and Sparkle should be up and running. You might want to create a test update in your appcast to see how everything works.