As I have been working for the Developer Tools from Apple for quite a while now, I have really gotten into finding out about all sorts of nice things that others have created for the developer community. One of them is the Sparkle Framework. This framework allows you to automatically update your application via appcasts and deliver them right to your customers; just like Apple’s Software Update application.
So integrating and using this framework is just a charm. I really suggest that you use it! Although the framework works totally fine it really lacks a good documentation for those who are new to this whole developing community (or are coding in a different language other than Cocoa). So I thought I’d make a tutorial that should make life easier. I fiddled ages with the original documentation until I got it to work – which wasn’t that exciting.
BTW – The Foolworkshop (by K. Lawson) has also done a tutorial which includes larger images. Take a look at that as well.
So, let’s start this thing:
- First you have to download the Sparkle framework.
Note: The framework is currently at like version 1.1, apparently, this version does not work with AppleScript applications. I have modified the 1.1 version with the 2.0 beta stuff to create a working version for AppleScript applications. You can download it here (It works for Cocoa applications as well and I actually recommend using it because of stability reasons on Leopard).
Then, open your project.
- Now drag and drop the downloaded “Sparkle.framework” folder into the “Linked Frameworks” in Xcode:

- Now toggle the “Targets” icon in the sidebar of Xcode and right-click to add a new “Copy Build Phase:”

When the info window pops up, set the copy phase to “Frameworks:”

- Then drag the “Sparkle.framework” from the “Linked Frameworks” folder in Xcode, to the newly create build phase:

- Now open up the standard Info.plist file and add the SUFeedURL which is defined in the documentation of Sparkle. This is the part which tells Sparkle which RSS file on the internet it should check in order to receive the updates. It should look something like this:

- Now you have all the steps you need in Xcode. Thus, we will move on to applying the “Check for updates” menu item to your nib file and binding it to the framework.
So open up the nib file in Interface Builder and from the “File” menu, choose to read the class files of your “Sparkle.framework.” Simply navigate to the framework which is inside your Xcode project and select all the header files:
- Getting a little bit more messy, we are going to have to add a NSObject. So, from the Library in Xcode drag the NSObject (the blue box) to your nib file and name it “Updater” from within the attributes tab in the inspector.

- Then select the NSObject and go to the identity tab in the inspector and add a new “id” action named “checkForUpdates:” Don’t forget the colon at the end! Of course and most importantly, set the class to “SUUpdater!”

- Short and easy: add a new menu item and right-click drag to connect it to the Updater NSObject:



- Now you are close to being finished. You only need to create an appcast (you can find a sample in the Sparkle documentation) and finish your app. Then your ready to go to release updates.
Optionally, you can also create a preference option that would allow the user to configure if they want to check for updates on start up or not. If you want to add it, what you do is you create your preferences window with a checkbox. Then bind it to the user defaults key of “SUCheckAtStartup.” Please not that this bind is only for versions before Sparkle 1.5. The newest release has a different binding value, which is “SUEnableAutomaticChecks.” Choose according to your Sparkle version.
Finished! Check if it works. If you wish you can download the sample AppleScript Xcode project that I have used if you wish.
If you have enjoyed this tutorial, then you might consider making a small donation. Feel free to do so by clicking here.
For 1.5, should not key for the shared defaults be SUEnableAutomaticChecks?
Be aware that from 1.5b5 on you should not use the user defaults yourself, they’re supposed to be private. Instead you should bind directly to the SUUpdater instance. Just add one to your Preferences.nib, the same way as in MainMenu.nib. The key is automaticallyChecksForUpdates. You can also bind updateCheckInterval if you like, e.g. for a PopUpButton.