Since today extensions run as separated a process I am sure they will not log any crashes out of the box. I assume we need to initialize Crashlytics on the widget separately. E.g. in the viewDidLoad
method of the TodayViewController
.
Crashlytics support got in touch with me and provided these steps. I tested them and it now works for me iOS 8 app.
Add the Crashlytics Run Script Build Phase to your extension's target as well (copy / paste the same you added to your main app)
Add the Crashlytics.framework
to your extension's linked libraries
(e.g. simply check the extension target in its file inspector)
Add the Crashlytics.startWithAPIKey("yourApiKey")
to your extension's view controller's initWithCoder
method. (In Apple's today extension template it is called TodayViewController
by default)
> if you have no initWithCoder
method yet, it should look like this afterwards:
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
Crashlytics.startWithAPIKey("yourApiKey")
}
Here is Twitter's own guide to implementing it:
https://twittercommunity.com/t/integrate-fabric-crashlytics-with-ios-8-extension/28905
So, copy the libraries, for instance if you're using CocoaPods you can add Fabric and Crashlytics to the Extension target:
In Podfile:
target :TodayExtension do
pod 'Fabric'
pod 'Crashlytics'
end
and run pod install
. And don't forget to set Build Active Architecture Only
to NO
, or you may get linker errors
Then in your TodayViewController:
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
...
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
[Fabric with:@[CrashlyticsKit]];
return self;
}
and copy the Fabric Run Script in build phases to your Today Extension target, and copy the Fabric entry from the info plist from the main application into your Today Extension's info plist
Here is official how-to described how to use Crashlytics in iOS Extensions:
viewController
's initWithCoder
method Fabric.with([Crashlytics.self])
And... you good to go!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With