Now I am trying to use my command line application written in Objective-C.
Question
When the application was not in the sandbox, I could get the directory in which the user called the application using [[NSFileManager defaultManager] currentDirectoryPath]. However, after the sandbox, the application always returns for the current directory, /Users/{MY_ACCOUNT}/Library/Containers/{BUNDLE_IDENTIFIER}/Dataregardless of where the command line application is called from.
Code example
In fact, I want to know the absolute path to the files that the user passed as arguments to the command.
So, when, for example, I invoke my command line application as follows:
$ pwd
/Users/MY_ACCOUNT/Desktop
$ ./foo/my_executable subfolder/myfile.txt
Next part:
NSURL *url = [NSURL fileURLWithFileSystemRepresentation:argv[1] isDirectory:NO relativeToURL:nil];
printf("path: %s\n", [[url absoluteURL] fileSystemRepresentation]);
the application will not return the sandbox :
path: /Users/MY_ACCOUNT/Desktop/subfolder/myfile.txt
but in the Sandbox :
path: /Users/MY_ACCOUNT/Library/Containers/BUNDLE_IDENTIFIER/Data/subfolder/myfile.txt
, , .
Sandboxed?
, ?
, .
environment [NSProcessInfo processInfo] , Sandboxed.
NSDictionary *env = [[NSProcessInfo processInfo] environment];
NSString *currentPath = env[@"PWD"];
, Terminal.app, . , PWD.
, As @daij-djan , . , .
( -, , , , !)