Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'FABException', reason: '[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.' when using Firebase and Crashlytics

I have a rather peculiar scenario when working with Firebase in our app. Without adding Crashlytics and Fabric to the project, when I run unit tests for the project the following code is hit:

@try {
        [FIRApp configure];
} @catch (NSException *exception) {
        DLog(@"**** Unable to configure Firebase due to exception %@", exception.description);
}

When debugging the unit tests an exception isn't raised and so I assume firebase is configured and all is Working. Tests pass and there are no issues.

I then very simply just add Crashlytics with Fabric to the project. I add this as a run script to my build phases "${PODS_ROOT}/Fabric/run" for the project and then run unit tests again. The unit tests fail and I get:

Terminating app due to uncaught exception 'FABException', reason: '[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'

as an error, when I run the project however everything is fine. The issue only arises when running tests. I have tried the following:

  1. Add Crashlytics and Fabric to the project target and I get the same error.
  2. I do step 1 and also to the unit tests target and I still get the same error.
  3. I do step 2 and then I also add Firebase Core to the unit tests target and I still get the same error.
  4. I do step 3 and then also add "${PODS_ROOT}/Fabric/run" to a run script but on the unit tests target and still get the same error.

I think Firebase isn't being initialized correctly and this in turn causes Fabric to not be initialized correctly and hence the failure. But I'm not to sure how to fix the issue. Any guidance and suggestions would be appreciated.

like image 786
user481610 Avatar asked May 10 '18 13:05

user481610


4 Answers

I just check one thing. If you registered your app in Firebase console, your AppDelegate.swift file should have Firebase.configure() code in didFinishLaunchingWithOptions function.

like this.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    print("[caution] : didFinishLaunchingWithOptions")
    FirebaseApp.configure()
    Messaging.messaging().delegate = self
    Fabric.with([Crashlytics.self])
    return true
}

I suffered the same problem. I just add that code and problem solved. I wish you too.

like image 117
user7614285 Avatar answered Nov 09 '22 08:11

user7614285


change this configuration:

def main_pods
    pod 'Fabric'
    pod 'Crashlytics'
    pod 'Firebase/Core'
end

target 'TargetName' do
    project 'Project.xcodeproj'
    main_pods
end

target 'OneMoreTargetName' do
    project 'Project.xcodeproj'
    main_pods
end

target 'TargetNameTests' do
    project 'Project.xcodeproj'
    main_pods
end

target 'TargetNameSwiftTests' do
    project 'Project.xcodeproj'
    main_pods
end

target 'TargetNameUITests' do
    project 'Project.xcodeproj'
    main_pods

    pod 'Utils', '~> 0.3.3'
    pod 'Pod', '~> 1.4.1'
end

to this:

def main_pods
    pod 'Fabric'
    pod 'Crashlytics'
    pod 'Firebase/Core'
end

target 'TargetName' do
    project 'Project.xcodeproj'
    main_pods

    # Move tests inside target block
    target 'TargetNameTests' do
        inherit! :search_paths # add custom flag
    end

    target 'TargetNameSwiftTests' do
        inherit! :search_paths # add custom flag
    end

    target 'TargetNameUITests' do
        inherit! :search_paths # add custom flag

        pod 'Utils', '~> 0.3.3'
        pod 'Pod', '~> 1.4.1'
    end
end

target 'OneMoreTargetName' do
    project 'Project.xcodeproj'
    main_pods
end
like image 35
Dmitry Coolerov Avatar answered Nov 09 '22 07:11

Dmitry Coolerov


I was upgrading Crashlytics and I've reproduced the error. In my case, the problem has been solved when I've removed the following code:

//[Fabric with:@[[Crashlytics class]]];
like image 44
Jorge Piera Llodrá Avatar answered Nov 09 '22 08:11

Jorge Piera Llodrá


The error message is quite straight forward.

Your Fabric keys in your Info.plist are in incorrect format.

It must be a dictionary as state in its document:

https://fabric.io/kits/ios/crashlytics/install

<key>Fabric</key>
    <dict>
        <key>APIKey</key>
        <string>YOUR_FABRIC_API_KEY</string>
        <key>Kits</key>
        <array>
            <dict>
                <key>KitInfo</key>
                <dict/>
                <key>KitName</key>
                <string>Crashlytics</string>
            </dict>
        </array>
    </dict>
like image 39
GIJOW Avatar answered Nov 09 '22 08:11

GIJOW