iOS (Fabric):Crashlytics 在启动时崩溃应用

iOS (Fabric): Crashlytics crashing app on launch

我已经更新了 Crashlytics,但在启动时仍然出现此错误:

Error: *** Terminating app due to uncaught exception 'FABException', reason: '[Fabric] It appears that "Crashlytics" is not a valid Fabric Kit. Please make sure you only pass Fabric Kits to [Fabric with:].'

这是我的代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

         Fabric.with([Crashlytics.self])
         return true
    }

试试这个:-

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
      Fabric.with([Crashlytics.self])
      return true
    }

试试下面的代码片段,它可能会有所帮助:

对于Swift:

//import related frameworks

import Fabric

import Crashlytics

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {

    Fabric.with([Crashlytics()])
    //... your initialization code
    return true
}

对于Objective-C:

#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
     [Fabric with:@[CrashlyticsKit]];
     //... your initialization code
   return YES;
}

我花了7个小时解决了这个问题。问题是:我的代码中有 2 个 Crashlytics 文件导致了这个问题。为了解决这个问题,我删除了旧文件并再次集成了 Crashlytics。

我在同一条线上遇到了崩溃,这是因为我在 FirebaseApp.configure() 之前调用了它。

对于遇到相同问题的任何人,请确保按以下顺序致电他们:

FirebaseApp.configure()
Fabric.with([Crashlytics.self])