ioscrashlyticsimessage-extension

How to use Crashlytics with iMessage Extensions?


I have an iMessage extension within my iOS app. Can Crashlytics capture its crashes?

I've tried adding the same Fabric entry from my main app's Info.plist into my iMessage extension's Info.plist, and adding the following to my MSMessagesAppViewController subclass (as recommended for Today widget intregation):

- (instancetype _Nonnull)initWithNibName:(NSString * _Nullable)nibNameOrNil
                                  bundle:(NSBundle * _Nullable)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil
                           bundle:nibBundleOrNil];
    if (self)
    {
        // Start up Answers and Crashlytics
        [Fabric with:[NSArray<id> arrayWithObjects:
                      [Answers class],
                      [Crashlytics class],
                      nil]];
    }

    return self;
}

But when I start iMessage and choose my iMessage extension, it just hangs on the previous screenshot. It never starts.


Solution

  • Mike from Fabric here.

    We have experimental support for only Crashlytics on iMessage Extensions. To get things working:

    1. Add your Fabric Run Script Build Phase to your extension's target. Copy and paste the one in your main app.
    2. Add the Fabric and Crashlytics.framework to your extension's linked libraries
    3. Add the Crashlytics.startWithAPIKey("YourActualApiKey") to your extension's view controller's initWithCodermethod. If you don't have an initWithCoder method currently, it should look like this in the end:

      required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) Crashlytics.startWithAPIKey("yourApiKey") }

    Reference: https://stackoverflow.com/a/27153383/3975963