Daniel Ryan
Daniel Ryan

Reputation: 7100

TestFlight TFLog not uploading when there is a crash

When TestFlight crashes I have a log I wish to upload with its crash report.

Following the instructions on their website I came up with this solution, but it doesn't seem to be sending the log I pass to TFLog. However it reports the crash just fine.

-(void)applicationDidFinishLaunching:(UIApplication *)application {

    /*Setup crash handlers for TestFlight so we can send logs. */
    NSSetUncaughtExceptionHandler(&testFlightHandleExceptions);
    // create the signal action structure
    struct sigaction newSignalAction;
    // initialize the signal action structure
    memset(&newSignalAction, 0, sizeof(newSignalAction));
    // set SignalHandler as the handler in the signal action structure
    newSignalAction.sa_handler = &testFlightSignalHandler;
    // set SignalHandler as the handlers for SIGABRT, SIGILL and SIGBUS
    sigaction(SIGABRT, &newSignalAction, NULL);
    sigaction(SIGILL, &newSignalAction, NULL);
    sigaction(SIGBUS, &newSignalAction, NULL);
    [TestFlight takeOff:TESTFLIGHT_API_KEY];
}

void testFlightHandleExceptions(NSException *exception) {
    [LogManager e: @"Sending crash to TestFlight" Tag:@"AppDelegate"];
    TFLog(@"%@",[LogManager getLog]);
}

Where have I gone wrong? Or is there a better way in doing this?

Upvotes: 1

Views: 378

Answers (1)

jasongregori
jasongregori

Reputation: 11656

There are two problems I can see with this:

  1. testFlightHandleExceptions is going to be called after the crash and it's logs are recorded. Instead you need to be calling TFLog inside of LogManager every time you log something (before the crash). That's how it's meant to be used.

  2. It is not ok to use objc inside of a signal handler. For that matter, most c isn't even allowed.

Hope that helps :)

Jason

Upvotes: 3

Related Questions