A little trick

I had a problem that my app did not work outside Xcode (had to include the metalkit.framework

I found a simple trick to get my NSLog outputs and locate the issue:

NSURL *downloadsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDownloadsDirectory inDomains:NSUserDomainMask] firstObject];

NSURL *fileURL = [downloadsDirectory URLByAppendingPathComponent:@"Log.txt"];

NSString *filePath = [fileURL path];
    
    // Redirect stderr to the file
   freopen([filePath fileSystemRepresentation], "a+", stderr);

Now you get debug info in your Download folder!

Thanks for sharing!

An alternative way to do this, one that doesn’t require code changes, is to run your app from Terminal. I give an example of this, albeit towards a different goal, in the App Can’t Be Opened section of Resolving Trusted Execution Problems.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This was of course the first thing I attempted, but got no output.

Roger Kjøde

A little trick
 
 
Q