[PYTHON] Until you incorporate the Crashlytics Kit into your kivy-based iOS app

Kivy is a framework for developing iOS / Android apps in Python. I personally like it and touch it often, but since it's a big deal, I incorporated Crashlytics, a crash report analysis service, and proceeded with the work so that I could collect information at the time of the crash.

Premise

Write up to here easily

$ (Do various installations, etc.)
$ pip install buildozer
$ mkdir kivyapp
$ cd kivyapp
$ buildozer init
$ buildozer iOS debug
IPA kivyapp-0.0.1.ipa available in the bin directory

What is troublesome

Review how to install CrashlyticsKit

Embedding CrashlyticsKit itself is extremely easy, and if you have an ApplicationDelegate class called in main, you can just put [Fabric with: @ [CrashlyticsKit]]; in the method didFinishLaunchingWithOptions.

Kivy-ios main ()

The source template that defines the main () function on kivy-ios is here. Unlike regular iOS apps, UIApplicationMain is not called. When I trace the process, it seems to be called by this was. Since the Delegate class was defined in SDLUIKitDelegate in the same source, it seems to be troublesome to insert the process.

What happened

https://gist.github.com/attakei/9c6e887b2662742228c2

I plugged in these sources. Great push.

// .h file
@interface SDLUIKitDelegate (KivyAppDelegate)
 
@end

// .m file
@implementation SDLUIKitDelegate (KivyAppDelegate)
 
+ (NSString *)getAppDelegateClassName
{
    return @"KivyAppDelegate";
}
 
@end

Forcibly rewrite the Delegate class that should be called by the category function of SDLUIKitDelegate in this implementation,

// .h file
@interface KivyAppDelegate: SDLUIKitDelegate
 
@end

// .m file
@implementation KivyAppDelegate

-(void)postFinishLaunch
{
    [Fabric with:@[CrashlyticsKit]];
    
    // call superclass method.(continue to run as kivy)
    [super postFinishLaunch];
}

@end

Here, in KivyAppDelegate that inherits SDLUIKitDelegate, override postFinishLaunch () and insert the CrashlyticsKit call. (Because Kivy's main operation is in the postFinishLaunch of SDLUIKitDelegate itself, be sure to call it with the override method)

With this, I managed to register the app on the Crashlytics side.

Recommended Posts

Until you incorporate the Crashlytics Kit into your kivy-based iOS app
Incorporate Sheltie Judgment AI into your web app
Until you self-host your own interpreter