I have tried using hdiutil using Process but always run in to the error "hdiutil: attach failed - Device not configured". I am running hdiutil attach -verbose -debug -mountroot /path/to/mount/ /path/to/dmg.dmg where both the mount root and DMG file have been chosen via an NSOpenPanel and support writing by the application.
I have also tried moving the DMG to a directory within the app's storage (as returned via FileManager.default.urls(for:in:)) and mounting it within the same directory but get the same error.
The full output is:
fileURL file:///path/to/dmg.dmg
directoryURL file:///path/to/mount/
calling DIHLDiskImageAttach with
debug: true
image-options:
quiet: false
mount-type: in
drive-options:
main-url: file:///path/to/dmg.dmg
mount-point: file:///path/to/mount/
verbose: true
agent: hdiutil
2020-07-28 17:24:35.848455+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: input dictionary {
agent = hdiutil;
debug = 1;
"drive-options" = {
};
"image-options" = {
};
"main-url" = "file:///path/to/dmg.dmg";
"mount-point" = "file:///path/to/mount/";
"mount-type" = in;
quiet = 0;
verbose = 1;
}
2020-07-28 17:24:35.848677+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: disabling legacy image format attach
2020-07-28 17:24:35.848700+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: newImagekeys = {
"legacy-disabled" = 1;
}
2020-07-28 17:24:35.848729+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: creating DIHelperProxy
2020-07-28 17:24:35.848769+0100 hdiutil[15701:1369864] with dictionary: {
agent = hdiutil;
debug = 1;
"drive-options" = {length = 42, bytes = 0x62706c69 73743030 d0080000 00000000 ... 00000000 00000009 };
"image-options" = {length = 65, bytes = 0x62706c69 73743030 d101025f 100f6c65 ... 00000000 0000001e };
"main-url" = "file:///path/to/dmg.dmg";
"mount-point" = "file:///path/to/mount/";
"mount-type" = in;
operation = DIHelperAttach;
quiet = 0;
verbose = 1;
}
2020-07-28 17:24:35.848787+0100 hdiutil[15701:1369864] [DIHelperProxy alloc]
2020-07-28 17:24:35.848815+0100 hdiutil[15701:1369864] [DIHelperProxy alloc] returning self 0x600002c0c480, retainCount 1
2020-07-28 17:24:35.852410+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: running DIHelperProxy
2020-07-28 17:24:35.852426+0100 hdiutil[15701:1369864] [DIHelperProxy performOperationReturning] entry
2020-07-28 17:24:35.852438+0100 hdiutil[15701:1369864] [DIHelperProxy performOperationReturning] detaching thread
2020-07-28 17:24:35.852675+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] entry
2020-07-28 17:24:35.852696+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] setting up server
2020-07-28 17:24:35.852706+0100 hdiutil[15701:1369867] [DIHelperProxy threadSetupServer] entry
2020-07-28 17:24:35.852737+0100 hdiutil[15701:1369867] [DIHelperProxy threadSetupServer] Cannot start hdiejectd because app is sandboxed
2020-07-28 17:24:35.852750+0100 hdiutil[15701:1369867] [DIHelperProxy threadSetupServer] exiting
2020-07-28 17:24:35.852759+0100 hdiutil[15701:1369867] error: unable to set up framework server.
2020-07-28 17:24:35.852767+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] waiting for task to terminate to avoid zombies
2020-07-28 17:24:35.852775+0100 hdiutil[15701:1369867] checkHelperStatusWaitingForExit: no helper process, skipping
2020-07-28 17:24:35.852783+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] helper exited
2020-07-28 17:24:35.852793+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] exiting
2020-07-28 17:24:35.852824+0100 hdiutil[15701:1369864] [DIHelperProxy performOperationReturning] returning 6
2020-07-28 17:24:35.852847+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: DIHelperProxy returned 6
2020-07-28 17:24:35.852860+0100 hdiutil[15701:1369864] [DIHelperProxy dealloc]
DIHLDiskImageAttach() returned 6
(null)
hdiutil: attach failed - Device not configured
The issue appears to be "Cannot start hdiejectd because app is sandboxed", does this mean it's not possible to read a DMG in a sandboxed app, or is there another method available?