Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openDMGFile not working #2

Open
Bikram40 opened this issue Aug 29, 2022 · 1 comment
Open

openDMGFile not working #2

Bikram40 opened this issue Aug 29, 2022 · 1 comment

Comments

@Bikram40
Copy link

i want to add this function to my application but that is not working even i give to sandbox, any solution ?

@vtaraikovich
Copy link

Hi, @Bikram40! I faced the same issue and found a solution. If you want to open .dmg file you should follow the next flow:

  1. Mount your .dmg file using command hdiutil mount <name>.dmg (or $filePath from example) ;
  2. Install the application by copying files to /Application folder with command cp -R /Volumes/<title from config.json>/<app name>.app /Applications;
  3. Unmount .dmg file hdiutil unmount /Volumes/<title from config.json>/;
  4. Additionally I added deletion downloaded .dmg file command rm $filePath.

Also you can join all commands in one: hdiutil mount $filePath && cp -R /Volumes/<title from config.json>/<app name>.app /Applications && hdiutil unmount /Volumes/<title from config.json>/ && rm $filePath

The full implementation of the method in my project looks like this:

 Future<void> openDMGFile(String filePath) async {
    await Process.run('sh', [
      '-c',
      "hdiutil mount $filePath && cp -R /Volumes/InAppUpdateDesktop/in_app_update_desktop.app /Applications && hdiutil unmount /Volumes/InAppUpdateDesktop/ && rm $filePath",
    ]);
  }

If you need full source code you can find it in my GitHub repository:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants