When I create a test application with a sandbox and add additional error checking:
FILE *file = fopen("/tmp/file.txt","a+"); if (file != NULL) { fprintf(file,"%s\n", "silly debug message"); fclose(file); } else { NSLog(@"Failed to create file: %d", errno); }
I get:
2013-02-09 10:19:43.680 WriteTest[11988:303] Failed to create file: 1
From the command line:
$ perror 1 1 : Operation not permitted
Thus, you cannot write to /tmp in the application sandbox. You need to follow the Sandbox Application Design Guide to determine where you can write files, possibly using Core Foundation and features like CFCopyHomeDirectoryURL() to get the location of files that you can write to an isolated environment.
source share