No file access permission for Cocoa app but works with command line app

33 Views Asked by At

If I create a command line tool project and run something like:

NSError *error = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
if(![fileManager createDirectoryAtPath:@"/vault/ahh/eee" withIntermediateDirectories:YES attributes:nil error:&error])
{
    NSLog(@"couldn't make dir: %@", error);
}

I am actually able to make the 'eee' directory. But if I do the same thing with an app (Cocoa):

couldn't make dir: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “eee” in the folder “ahh”." UserInfo={NSFilePath=/vault/ahh/eee, NSUnderlyingError=0x600000a5d800 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

Why is this and what should I do for the app so that it can handle file accesses?

1

There are 1 best solutions below

1
Hyperian On

Found the answer. you can turn off sandbox by going to signing and capabilities tab and just remove the sandbox settings on the right.