Using Sparkle for System Preference bundles

Asked by junkzilla

Hi,

I'm a Cocoa n00b so probably missing something obvious here. I installed Spakle for a normal app but now I would like to integrate it with a System Preference bundle I'm making. I tried to follow the wiki but the "Updating a Bundle" article is a little bit too advanced for me.

It's the part: "Instead, you should instantiate the SUUpdater instance for your bundle in code at an early stage, just after your bundle was loaded."that I don't understand. How do I do this?

I tried to add the [SUUpdater updaterForBundle:[NSBundle bundleForClass:[self class]] line to my awakeFromNib method but that does not compile, it doesn't know the SUUpdater there. How can I tell it where to look?

Is there any sample code available? Sorry for this super easy questions...

Thank you all!

Question information

Language:
English Edit question
Status:
Solved
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Solved by:
Andy Matuschak
Solved:
Last query:
Last reply:
Revision history for this message
Best Andy Matuschak (andymatuschak) said :
#1

Sorry for the confusion. There should really be some sample code.

It doesn't know what SUUpdater is because you have to #import <Sparkle.h>.

Somewhere in your code, you should write:
SUUpdater * updater = [SUUpdater updaterForBundle:[NSBundle bundleForClass:[self class]]];
[updater setAutomaticallyChecksForUpdates:YES];
[updater resetUpdateCycle];

Revision history for this message
junkzilla (junkzilla-bugmenot) said :
#2

Thanks Andy, that works! I forgot the Sparkle import.

Now, when I click the "Check for updates" button in my bundle (it's a preference pane bundle) it adds the SULastCheckTime to com.apple.systempreferences user defaults. I can see why but it feels wrong. What if another bundle in the system preferences is using Sparkle as well?

I checked the source code of Perian and they have a complicated separate update app. Is that the right way to do it? Can I add a namespace or something?

Revision history for this message
Andy Matuschak (andymatuschak) said :
#3

Yes, that's incorrect. Specifically, Sparkle will put the preference in the appropriate place for the bundle you provide in the code snippet I listed above. Note that the bundle being provided is [NSBundle bundleForClass:[self class]]. To be more explicit, try [NSBundle bundleWithIdentifier:@"com.you.foo"]

Revision history for this message
junkzilla (junkzilla-bugmenot) said :
#4

Thanks Andy Matuschak, that solved my question.