I have a desktop MacOS app written in Objective-C. I want to add this functionality:
I assume that somewhere on a server sits new app version xx.1.1.dmg
- app shows that an update is available
- user agrees to update
- app downloads the update
- app prompts user to agree to install & restart the app
- magic happens
QUESTIONs:
A. Is there a framework to start the download, display the progress and then update the running application or do I have to implement all this? The update process of many applications look like very similar so it seams like some shared functionality is used.
B. Once you have the update archive on local drive. How to you "replace" the old app with the new one. Do you "just" unpack the archive over the existing app folder? This could be problematic because of open files.
C. How do you force app restart?
D. Is there a way to schedule "after-app-quit" actions which would solve the issues described in B? Could these actions also include the new app start?
There may be a framework available somewhere, but it is so simple that it is probably easier to do it yourself.
A. What I do in my own code is run the download in the background – it's a GET with If-Modified-Since set, so that it will only download if a newer version exists on the server. I store the downloaded file in the Application Support directory. None of this is particularly complicated. Once the download has completed, I quietly include a button in the UI to say that an update is available to be installed. (I could equally have chosen to pop up a message – perhaps on the next app startup).
B. The best thing is not to upload a
.dmg
but a .pkg
file. (Xcode can create these files). Simply opening this file will do the whole installation process, and it will automatically close the app before installing the update. You start it simply with[[NSWorkspace sharedWorkspace] openFile:filenameOfDownloadedPkgFile]