Sparkle Updating System
For a while now I’ve known about the Sparkle update framework that developers can insert into their applications to give them the ability to update themselves with minimal user interaction. Just yesterday I decided to download it and attempt to work it into all 3 of my applications. I just finished testing one of the applications knowing that if one worked all the others would as well. The test went as it should. Therefore, in barely a day I’ve managed to get it working across 3 applications I’ve been developing. Looking back on the process it all seems quite simple, but because it certainly isn’t I’ll explain what I did here in this blog post. The directions are in the extended body (because of how long they are). The first step is to add the framework into your project. Do this by dragging it from the Finder window into the “/Frameworks/Linked Frameworks” folder in the “Groups & Files” sidebar in the Xcode project (make sure that Finder copies the file to the project directory). Then go into the “Project” menu and choose “New Build Phase -> New Copy Files Build Phase”. In the window that comes up choose “Frameworks” from the popup menu and close the window. Then drag the “Sparkle.framework” from the “Linked Frameworks” folder into that new “Copy Files” location inside your applications target. At this point run your application to be sure that everything works as it should.
Next open the NIB for your application. In the start window for your interface choose the “Classes” tab. From the “Casses” menu choose “Read Files…”. Navigate to your project directory and go into the “Headers” of the “Sparkle.framework”. Choose the “SUUpdater” and click the “Parse” button. Then select the “SUUpdater” from the main window and choose “Instantiate SUUpdater” from the “Classes” menu. That will return the main window to the “Instances” tab and in that tab should be a “SUUpdater” alongside all the other parts that were already there.
Your next job is to add the interface elements to start the update checks. I added a menu item to the main application menu and a button to the preferences window. Connect these to the “checkForUpdates:” command inside the “SUUpdater” instance. Now you have the entire interface tied up.
If your app already has an appcast then the next step is already done, if not, here’s what you need to do. Sparkle’s documentation pdf has an example appcast xml in it, but the basics are here. Basically it’s an RSS feed with an enclosure. So inside the enclosure tag you need the URL to the apps download. The file name needs to be like “My App_1.0.zip”. You also add in the URL to change notes for Sparkle to display to help the user know the importance of the update. The rest is shown in the documentation that comes with Sparkle.
Now back in Xcode open the “Info.plist” for your application. Add a new key by the name of “SUFeedURL” and make the string the URL to your application’s appcast xml file. You’ve just told “Sparkle” where to check what version is current and what the download URL is.
At this point Sparkle is set up. There are more complicated things you can try to do, but I’m trying them right now so I can’t explain that to you. Also, when the application first launches with Sparkle installed it might ask you if you want it to check on startup. Part of what I’m trying to learn is how to make a checkbox for that option in the preferences window. Enjoy, Alex.