Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common update procedure for auto-updating apps on OSX?

I'm working on an Objective-C Cocoa app in Xcode for OSX which will be distributed outside the App Store.

One of the menu items in the app is "Check for Updates". The user can click this item and check if there's an update available.

If there is an update available, the update will be downloaded.

My question is : What is the common approach for updating an app? Since the app is open, it can't overwrite itself. So how is this typically done?

Do you separate your app into a launcher and the app itself? If so, I imagine that when the user starts the app, it is in fact the launcher that's started. The launcher then checks to see if an update has been downloaded and it replaces the old app binary with the new app binary. Is that how it's done on OSX or is there a smarter way?

like image 304
user1884325 Avatar asked Sep 23 '13 16:09

user1884325


1 Answers

Sparkle is really good, however if you prefer in-house solution then here is one possible approach.

Steps:

  • Old application (after launch) checks for updates
  • if update found download and unpack it into a temp location
  • launch an external application do to the "swapping" replace old currently running app with the new one unpacked into a temp location
  • old app terminates

Where the real "magic" happens is when old app is done with the download and unpack. Then old app from it's bundle copies to a temp location it's relauncher (simple terminal app) and launches it with the following command line args:

  • First param is the process ID of the old app (which is running)
  • Second is the path to the new version (this will be moved into Applications folder)
  • Third (optional) path to the old application (used to delete it explicitly)

When all is done, after launching the relauncher old app terminates. At this point relauncher is already running and waits for old app's termination.

When old app terminates then relauncher does three things:

  • Deletes the old app from Applications
  • Copies new version from temp location into Applications
  • Launches the new version from Applications.

Update is done.

like image 137
robert Avatar answered Oct 12 '22 23:10

robert