Software Updates: How To Do Them "Live" in your code

Discussion in 'Mac Programming' started by GothicChess.Com, Apr 26, 2007.

  1. GothicChess.Com macrumors regular

    GothicChess.Com

    Joined:
    Apr 6, 2007
    Location:
    Philadelphia, PA
    #1
    I am writing an application that will require a fair number of large external files, but every user might not want all of them. Just as I was thinking how the best way to distribute the app without making a complex installer (large download anyway) or stripping down the app too much, I received a "Software Update" notification.

    Then, the little light bulb went off :)

    I can make the installer build all of the essential support files, and then allow the user the option to do a "Software Update" and pull down the files at their leisure.

    Does anyone know of a link that shows some sample source code that demonstrates how Apple does their own "Software Update"?

    I would need "two flavors" of it:

    1. User Initiates -- If they want more of the support files, then can use a menu option to make a request.

    2. Server Side Initiates -- If a "necessary support file changes", it would be great if I could notify everyone that is connected, the way Apple does.

    I know there is probably a mountain of code to handle this request, but if I could just find out the core API files I would be able to handle all of the tedium required to make this work.

    Thanks in advance to all who share their ideas!
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    First off, there is no "API" for this. Generally, one develops a library/framework for handling this, and reuses it over and over in each app, since it's so common of a feature (see Sparkle).

    Second, what are you coding in? Cocoa, Java, etc?

    Generally how software updates are done, is you have a master list (XML) on your server that lists every possible update (with details such as name, description, version, etc). Then you have the local files all cataloged somehow, each file with its version number associated with it (in the case of Cocoa, each bundle has its own version string already). If you're not developing in Cocoa, you will have to figure out a way to associate version numbers with a file or folder.

    Then you periodically (on launch, every X minutes, etc) load the XML on the server, and compare what you have on the local machine, and finally, present a dialog to the user with the new updates.
     
  3. mduser63 macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #3
    It doesn't work this way. Both scenarios work the same way. Apple can't "push" code, it's just that Software Update automatically checks Apple's servers for updates every so often and notifies you if there are any available that you don't have installed. Software update doesn't care if they're new or not, so the exact same paradigm could just as easily be used to install/update optional components.

    All that said, you may want to look closely at Sparkle because it might be easier to modify it to suit your needs than to roll your own solution from scratch. Sparkle is free and open source and licensed under the BSD license so you're welcome to use it in closed source/commercial apps.
     
  4. GothicChess.Com thread starter macrumors regular

    GothicChess.Com

    Joined:
    Apr 6, 2007
    Location:
    Philadelphia, PA
    #4
    I am writing it in C with the Carbon API using XCode.

    I understand conceptually how to do this, but how does one "locate" all of the users of the software that are online at a given moment in time?

    That has to be rather difficult!

    And where can one get this "Sparkle" code, or should I just try googling it?
     
  5. mkrishnan Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #5
    This is a really nice product. And I've taken advantage of it, I guess, because Adium updates this way. It does an okay job of managing security. On the plus side, it makes the user provide authorization to update things in the /applications folder if the user does not own rights (it still drives me crazy that Firefox somehow subverts this... it really shouldn't be able to do so! :mad: ). The downside is that, at least in what I've seen with Adium, if the user accidentally mistypes their password or admin account and hits the button, not only will it fail, but it will terminate the updating procedure. This means that the user will have to download the update file AGAIN! :rolleyes:

    But still, it's a great project overall. :)

    http://sparkle.andymatuschak.org/
     
  6. mduser63 macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #6
    Like I explained, that's not how it's done at all. Nevermind the technical issues (which are huge) there are some pretty big ethical problems with the idea. It's the software on the user's computer that checks for updates. There is no central "pushing" of updates going on. The server doesn't know about the users out there needing to be updated, it merely provides a way for the software to check if it needs to update itself. Does that make sense?

    EDIT: Ahh, I see that you've edited your post with a note that you realize this. Nevermind...
     
  7. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #7
    Sparkle is a Cocoa framework.

    However, check out Nano. It is a C++ wrapper for much of Carbon and provides several nice features that are similar to what Cocoa has. It comes with a software updating feature - you might be able to use that code in your app (looks like it works very similarly to Sparkle).
     
  8. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #8
    If some enthusiastic new Cocoa programmer felt like fixing this I'd certainly be willing to answer questions about the code, since I've worked on it before...

    < looks around at the forum hopefully ;) >
     

Share This Page