Getting Console Output When Running iCuke

March 1, 2011

One of the difficulties with running under iCuke is what happens if a crash occurs. Since you don't have access to the console, you might be losing information you need to debug the issue.

You can easily redirect the logging messages and your application's console to a file by adding this code to the beginning of your app delegate's applicationDidFinishLaunching: method.

   FILE *f = fopen("/tmp/errors.log", "w");
   extern int dup2(int, int);
   dup2(fileno(f), 1);
   dup2(fileno(f), 2);

Clearly hackish, and clearly not code you should ever commit, but it works.

Tags: iOS iCuke fixme