How to use Crashlytics with iMessage Extensions?

2019-05-11 05:35发布

问题:

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.

回答1:

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



回答2:

Crashlytics isn't supported for iMessage extensions yet.

iMessage extensions aren't officially supported yet, but we're looking into adding it!