0

Our app is being stored in /Users/Shared/OurAppData/OurApp.app. One of the reasons for this is to enforce user to use launcher.

But, now we've met the problem, when we want to update our app through the launcher(we download zip file, extract that and that wants to replace our app with the new one with)

try FileManager.default.replaceItemAt(URL(fileURLWithPath : Paths.ourAppPath) , withItemAt: extractedURL)

"You don’t have permission to save the file “OurApp” in the folder “ OurApp Data”."

My question is - is there a way to handle that situation? I guess the best solution to promt user for login and password for permissions, and to replace that file? I guess this is something outside the Swift scope, and probably AppleScript, or even .sh.

Please, help.

Thanks

rmaddy
  • 314,917
  • 42
  • 532
  • 579
PolosatiyVjih
  • 269
  • 3
  • 12

1 Answers1

0

I recommend to have a look at the Sparkle framework for updating applications.

Sparkle handles the checking if an update is available, downloading the update, asking for an administrator password if required, and cleaning up the downloaded files after the update.

For most application it is enough to just have the new version archived as zip archive.

But it is also possible to update application with helper applications or agents which are outside of the main application bundle.

This can be done with installer package *.pkg. If you are familiar with Sparkle, the "Automatic installation" referred here will only show the Sparkle UI. In the background it will use macOS’s built-in command line installer, /usr/sbin/installer.

In most cases it will make sense to have the same .pkg as user facing installer and update, it is not required.

If your application is sandbox, there are a couple of forks of the framework.

catlan
  • 25,100
  • 8
  • 67
  • 78
  • We already use sparkle for updating our launcher, but the problem is our main app is done in Unity3D... – PolosatiyVjih Oct 30 '17 at 15:29
  • Sparkle can also be used with installer packages (.pkg). This way you should be able to update all parts of your app. See https://sparkle-project.org/documentation/package-updates/ – catlan Oct 30 '17 at 15:56
  • Not sure I understand how it will behave? User will install apps(launcher and app) via installer. Then will delete an installer. And how update that now? – PolosatiyVjih Oct 30 '17 at 16:31
  • I update my answer. It is not important how the app is installed (Just to focus on you question). Does this answer you question? – catlan Oct 30 '17 at 17:10
  • Not really. I still jot understand, I will open launcher, and it should check for updates from sparkle, and if they are, right now it will update the launcher itself, but I cant understand how it will update the second app, it will download pkg with both apps and install that? – PolosatiyVjih Oct 30 '17 at 17:19
  • Yes. The pkg can contain both apps. – catlan Oct 30 '17 at 17:25
  • Hm, is there any specific setup for that case? Or the same as regular sparkle? – PolosatiyVjih Oct 30 '17 at 17:30
  • It is the same regular sparkle, only instead of the archived application bundle you point sparkle to an archived installer `pkg`. – catlan Oct 30 '17 at 17:36
  • Kk, let me try that tomorrow, and I will let you know!) for now thanks, you have given me nice trail! – PolosatiyVjih Oct 30 '17 at 17:44