In my application I'm successfully using Firebase and in AppDelegate I do the setup:
// ### Initialize Firebase
FIRApp.configure()
Now I do some unit tests on related target and when I launch it I get errors:
2017-04-14 14:53:22.351 MyProject[28753] <Error> [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
2017-04-14 14:53:22.354 MyProject[28753] <Error> [Firebase/Messaging][I-IID001000] Firebase is not set up correctly. Sender ID is nil or empty.
2017-04-14 14:53:22.356 MyProject[28753] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3800000 started
2017-04-14 14:53:22.356 MyProject[28753] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2017-04-14 14:53:22.381 MyProject[28753:712475] *** Terminating app due to uncaught exception 'com.firebase.instanceid', reason: 'Could not configure Firebase InstanceID. Google Sender ID must not be nil or empty.'
Versions:
Firebase/Core (3.16.0)
Firebase/Messagging (3.16.0)
Any advice?
I just noticed it's started happening to me and my travis builds are failing with Firebase 3.16. I downgraded to 3.7.1 which was the version I had previously on the project and it's working again.
I haven't had time to look into it more but it's a quick fix. It may be a Firebase bug or they might have changed something and the setup is different now.
Edit: Apparently rolling back to 3.15 works well enough.
Beginning in Firebase 3.16.0
, it seems Google Firebase isn't picking up the GoogleService-Info.plist
from the unit test build, even if the plist
is included in both the app and unit test targets. This doesn't seem to be resolved in 3.17.0
. As others have noted, downgrading to 3.15.0
seems to sidestep the issue.
But for many, initialization of Firebase during unit tests may not be necessary, and actually unintended --for example, you probably don't want Firebase reporting on unit test crashes. In these scenarios, you can easily add a guard around FIRApp.configure()
to not initialize it while running unit tests via the following:
import Foundation
func isUnitTesting() -> Bool {
return ProcessInfo.processInfo.environment["TEST"] != nil
}
if !isUnitTesting() {
FIRApp.configure()
}
Then be sure to define the environment variable TEST=1
only in your testing scheme.
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