Is it possible to open .dmg or .xip in my Mac OS app?

I have a requirement to download and install a required package before starting the actual task in a MAC application. and the downloaded package is coming from the private server through https API, I tried to run mount process for the file but it fails for .dmg formate.

Code Block
let task = Process.launchedProcess(launchPath: "/usr/bin/hdiutil", arguments: ["attach", "-verbose", "-debug", "-mountroot", "/dev/disk2","<path of downloaded file>"])
task.waitUntilExit()

It says hdiutil: attach failed - Device not configured

So I thought of asking the backend developer to provide .XIP, would that be a solution? Because I think that won't give any signing or permission issue. Any Suggestion?

Is your app sandboxed?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Yes it is sandboxed.
in my requirement the downloaded package is a support package for further task to perform, so it has to be downloaded and instal first, now this is my first Mac project, all I understand is Mac doesn't allow to install anything which is not downloaded from trusted env. and we need to change setting to allow from anywhere.
but I need to do this from code. (install and execute)
similar to below code of Windows, Could you suggest any better approach or tell me if I am on a wrong approach.

Code Block
public static void ExecuteExe(string exePath)
{
Process process = new Process();
process.StartInfo.FileName = exePath;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
process.WaitForExit();
}



It depends what the additional component contains. DMGs are a good way to distribute components that users can manage themselves (like dragging an APP into /Applications), but XIP is a special case:

The xip tool is used to create a digitally signed archive. As of macOS Sierra, only archives that are signed by Apple are trusted, and the format is deprecated for third party use.

Another format is PKG, but that assumes the user will be installing components which require administrator privileges.
Is there a limitation preventing the component from being bundled with the app?

Yes it is sandboxed.

The sandbox is designed to prevent this kind of thing. Is this a Mac App Store app? If so, it's dead in the water.

If not, I'm not sure a sandboxed app can even run hdiutil. I definitely don't know what kinds of temporary entitlements you would have to add for this. I can tell you that "/dev/disk2" is never going to work. Even if you can get hdiutil to run and it does run, it would be running in your app's sandbox. You would have to give it a container-specific path for a mount point.

Yes it is sandboxed.

Is it sandboxed because you intend to distribute via the Mac App Store? Or sandboxed because it’s simply the right thing to do?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

I am having similar requirement.

Given that NainaSoni90 has gone silent here, I recommend that you open a new thread with the details of your specific issue. Feel free to reference the relevant parts of this thread from your new thread. And post the new thread’s link here so that see it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is it possible to open .dmg or .xip in my Mac OS app?
 
 
Q