Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

robvas

macrumors 68040
Original poster
Mar 29, 2009
3,240
630
USA
I am using the latest Xcode and latest MacOS, how do I disable sandboxing so I can access a users home directory?

I don't have the checkbox checked for Enable Sandboxing but I keep getting this directory instead of the users home dir:

file://localhost/Users/robert/Library/Developer/Xcode/DerivedData/Grab-azfpkhbwpmzueraynimpurcnwdvx/Build/Products/Debug/

This just started happening before I updated Xcode a week or two ago.
 
I am using the latest Xcode and latest MacOS, how do I disable sandboxing so I can access a users home directory?

I don't have the checkbox checked for Enable Sandboxing but I keep getting this directory instead of the users home dir:

file://localhost/Users/robert/Library/Developer/Xcode/DerivedData/Grab-azfpkhbwpmzueraynimpurcnwdvx/Build/Products/Debug/

This just started happening before I updated Xcode a week or two ago.

Post your code.
 
Code:
- (void) saveCGImage:(CGImageRef)image {
  NSUserDefaults *defaults = [NSUserDefaults
															standardUserDefaults];
	time_t rawtime;
	struct tm *timeinfo;
	char buffer[80];
	
	time (&rawtime);
  timeinfo = localtime (&rawtime);
  strftime (buffer,80,[[defaults objectForKey:GRBFileNameString] cStringUsingEncoding:NSUTF8StringEncoding ],timeinfo);
	
	NSString *fName = [NSString stringWithCString:buffer encoding:NSUTF8StringEncoding];
	
//  NSString *screenShotFilePath = [NSString stringWithFormat:fName, NSHomeDirectory()];
	
	NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *docsDirectory = [paths objectAtIndex:0];

	NSString *screenShotFilePath = [NSString stringWithFormat:fName, docsDirectory];

	NSLog(@"path = %@", screenShotFilePath);
  
  [self CGImageWriteToFile:image filePath:screenShotFilePath];
}

- (void) CGImageWriteToFile:(CGImageRef)image filePath:(NSString*)path {
  CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:path];
  
  NSLog(@"url = %@ END", url);
  
  CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL);
  CGImageDestinationAddImage(destination, image, nil);
  
  if (!CGImageDestinationFinalize(destination)) {
    NSLog(@"Failed to write image to %@", path);
  }
  
  CFRelease(destination);
}

Output:

2012-09-30 17:42:47.045 Grab[4892:303] path = CAPTURE-09-30-2012.PNG
2012-09-30 17:42:47.046 Grab[4892:303] url = CAPTURE-09-30-2012.PNG -- file://localhost/Users/robert/Library/Developer/Xcode/DerivedData/Grab-azfpkhbwpmzueraynimpurcnwdvx/Build/Products/Debug/ END
 
Ahhh nevermind I figured it out - building the path wrong, the functions return what they should.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.