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:
"${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.
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.
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
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]]];
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>
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