I've encountered a strange problem where the FirebaseApp.configure()
call causes my app to instantly crash for my unit test target. It runs just fine for my standard builds.
Any ideas why this is happening?
Here's the stack trace:
2018-04-18 11:42:57.252405+0100 Avalanche[14289:124354] 4.8.1 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40007000 started
2018-04-18 11:42:57.252454+0100 Avalanche[14289:124361] 4.8.1 - [Firebase/Core][I-COR000005] No app has been configured yet.
2018-04-18 11:42:57.252712+0100 Avalanche[14289:124354] 4.8.1 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://googl/RfcP7r)
2018-04-18 11:42:57.371588+0100 Avalanche[14289:124278] [Crashlytics] Version 3.9.3 (128)
2018-04-18 11:42:57.390507+0100 Avalanche[14289:124278] *** Terminating app due to uncaught exception 'FABException', reason: '[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000113c0a1e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000011329f031 objc_exception_throw + 48
2 CoreFoundation 0x0000000113c7f975 +[NSException raise:format:] + 197
3 Avalanche 0x000000010f654dec -[Fabric validFabricConfigFromInfoPlist:] + 353
4 Avalanche 0x000000010f654a16 -[Fabric fabricConfig] + 127
5 Avalanche 0x000000010f654bce -[Fabric APIKey] + 392
6 Avalanche 0x000000010f61e6d7 -[Crashlytics APIKey] + 55
7 Avalanche 0x000000010f62a087 -[CLSCrashReportingController APIKey] + 57
8 Avalanche 0x000000010f62977f -[CLSCrashReportingController startWithProfilingMark:betaToken:] + 257
9 Avalanche 0x000000010f61e088 __20-[Crashlytics start]_block_invoke + 637
10 libdispatch.dylib 0x0000000114b93779 _dispatch_client_callout + 8
11 libdispatch.dylib 0x0000000114b94c0a dispatch_once_f + 55
12 Avalanche 0x000000010f61de05 -[Crashlytics start] + 106
13 Avalanche 0x000000010f61e23a +[Crashlytics initializeIfNeeded] + 48
14 Avalanche Tests 0x0000000129cd440a __15+[Fabric with:]_block_invoke + 538
15 libdispatch.dylib 0x0000000114b93779 _dispatch_client_callout + 8
16 libdispatch.dylib 0x0000000114b94c0a dispatch_once_f + 55
17 Avalanche Tests 0x0000000129cd41ee +[Fabric with:] + 222
18 Avalanche Tests 0x0000000129cd5dea __14+[Fabric load]_block_invoke + 580
19 Foundation 0x0000000112cc0324 -[__NSObserver _doit:] + 298
20 CoreFoundation 0x0000000113ba5b8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
21 CoreFoundation 0x0000000113ba5a65 _CFXRegistrationPost + 453
22 CoreFoundation 0x0000000113ba57a1 ___CFXNotificationPost_block_invoke + 225
23 CoreFoundation 0x0000000113b67422 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1826
24 CoreFoundation 0x0000000113b665a1 _CFXNotificationPost + 609
25 Foundation 0x0000000112c80e57 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
26 Avalanche 0x000000010f6d41a7 +[FIRApp sendNotificationsToSDKs:] + 393
27 Avalanche 0x000000010f6d309e +[FIRApp configureDefaultAppWithOptions:sendingNotifications:] + 302
28 Avalanche 0x000000010f6d2eda +[FIRApp configure] + 380
29 Avalanche 0x000000010f609490 _T09Avalanche11AppDelegateCACycfc + 192
30 Avalanche 0x000000010f6094c3 _T09Avalanche11AppDelegateCACycfcTo + 19
31 UIKit 0x00000001109eb6c4 _UIApplicationMainPreparations + 1491
32 UIKit 0x00000001109eb087 UIApplicationMain + 111
33 Avalanche 0x000000010f60b447 main + 55
34 libdyld.dylib 0x0000000114c08955 start + 1
)
li
bc++abi.dylib: terminating with uncaught exception of type NSException
Before the crash, I also see a large number of log entries like:
objc[14289]: Class RCNKeyValue is implemented in both /Users/sammcneilly/Library/Developer/CoreSimulator/Devices/E62EC87E-0B07-4A83-A165-819E693AEB87/data/Containers/Bundle/Application/6C3F993F-4CEB-462F-9257-0F3C8E088BC0/Avalanche.app/Avalanche (0x10f7bdd50) and /Users/sammcneilly/Library/Developer/Xcode/DerivedData/Avalanche-ewiqmxxekhpknrhhfuyljlekgzat/Build/Products/Development-iphonesimulator/Avalanche.app/PlugIns/Avalanche Tests.xctest/Avalanche Tests (0x129e075d8). One of the two will be used. Which one is undefined.
I've installed Firebase and Firebase/Crashlytics via CocoaPods. I'm not sure if this is related to Xcode 9.3 - this is happening on two separate projects, and I'm fairly certain it didn't happen previously for the older project.
I've printed out the bundle contents and the GoogleService-Info.plist
file appears to be there.
Any help would be much appreciated!
Adding a unit test in Xcode If you already have a project, you can add a Unit Testing Bundle to it as well. Go to File > New > Target. Select iOS Unit Testing Bundle and then click Next. When you create a new Unit Test target for your project, it consists of a template class.
Firebase Crashlytics is a lightweight, realtime crash reporter that helps you track, prioritize, and fix stability issues that erode your app quality. Crashlytics saves you troubleshooting time by intelligently grouping crashes and highlighting the circumstances that lead up to them.
Using ⌃⌘U will run all the test cases without building the test target. It is the opposite of ⇧⌘U. This is especially useful when you want to skip a slow-building test target and jump straight into running all the test cases.
Ok so this turned out to be caused by an incorrectly-configured Pod file. My main target and unit test target were configured to use the following pods:
pod 'Crashlytics', '~> 3.10.1'
pod 'Fabric', '~> 1.7.6'
pod 'Firebase/Core', '~> 4.8'
pod 'FirebaseRemoteConfig', '~> 2.1'
Removing the additional Firebase pods for the test target ONLY (other than Firebase/Core
) and running pod install
again helped.
I'm not altogether sure why this worked, so would be very grateful if someone could explain this to me.
The "${PODS_ROOT}/Fabric/run"
build phase script was configured on my primary target as detailed in Google's docs here: https://firebase.google.com/docs/crashlytics/get-started, and adding it to the test target didn't help either...
Thanks to everyone for their input, but adding the Fabric
details manually to the Info.plist
file just caused a build error. I believe this step is automatically handled for Firebase.
We had the same crash when running XCTest. We use the following to get around it.
if NSClassFromString("XCTest") != nil {
return true
} else {
FirebaseApp.configure()
}
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