Auto-Update macOS app outside of MacAppStore

I have a sandboxed/hardened app that is distributed outside of the MacAppStore. I want to allow the app to auto-update itself.

I currently have the ability in the app to figure out if there is a newer version which then informs the user and gives them an option to download the app (currently it downloads to ~/Downloads in the app container). The app comes as a simple zip file that only includes the app itself. Once downloaded, then NSWorkspace.shared.open(URLtoDownloadedUpdate) will expand the zip and place the app in ~/Downloads.

What I want is it to replace the current version of the app w/ this newly downloaded version. Is this possible?

First, how do I find out where the old app is stored? And then how do I replace it with the new version when the old app is still running?

I realize many people use Sparkle to do this instead of rolling their own. I simply do not want to depend on a third party.

I couldn't figure out how to do either one. So, after downloading, I simply open a Finder window with the update highlighted. I'll leave it up to the user to figure out the rest.

For the first thing, finding the running app’s own location, you can use NSBundle.mainBundle.bundleURL. Typed from memory, away from my Mac.

If the app is sandboxed, it won't have permission to replace itself. Sparkle works around this issue by using a non sandboxed helper. It's open source, so you can check exactly what's Sparkle is doing and replace it if you want.

Auto-Update macOS app outside of MacAppStore
 
 
Q