Mount Network Drives when Sandbox Mode is ON

I have implemented Network drive mounting using NetFSMountURLSync with different protocols (AFP, SMB, NFS and NFS (Final cut protocol)). Below mentioned is my code to achieve it.

Example url : smb:/

Example mount path : file:/

NSURL *url = [[NSURL alloc] initWithString:mountURLString];

NSURL *mountpath = [NSURL fileURLWithPath:@"/Volumes/" isDirectory:YES];

CFMutableDictionaryRef mountOpts = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

CFDictionarySetValue(mountOpts, kNetFSMountAtMountDirKey, CFSTR("MountAtMountDir"));

CFArrayRef mountpoints = NULL;

NSInteger error = NetFSMountURLSync(

(__bridge CFURLRef) url,

(__bridge CFURLRef) mountpath,

NULL,

NULL ,

0,

mountOpts,

&mountpoints);


It works fine when Sandbox Mode is OFF but the above code doesn’t work when Sandbox mode is ON. It returns me error as 1 which is “Operation not permitted” according to the Error.h file. I know there are restrictions in Sandbox mode, but its important for my application to mount network drives because its one of the core features of my application. Any help is appreciated. Thanks in advance.

Answered by DTS Engineer in 45881022

Have you tried mounting the volume at a location inside your app’s container?

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

Have you tried mounting the volume at a location inside your app’s container?

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks eskimo, you saved my day!!! 🙂

Mount Network Drives when Sandbox Mode is ON
 
 
Q