Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 126 Vote(s) - 3.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Firebase configuration fails - Swift

#1
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?
Reply

#2
Switch from a simulator to an **"actual iOS device"**!

Worked for me!

After that runs on the simulator too.
Reply

#3
Upgraded firebase to 4.1.0 solved my issue. Also many warnings went way. I would suggest update **Firebase**

pod 'Firebase', '~> 4.1.0'
Reply

#4
I've run into the same issue and none of the proposed fixes helped.

I was seeing the duplicate class implementation warnings as mentioned at the bottom of this issue:

[To see links please register here]


Removing all the firebase frameworks from the Test Targets as mentioned in that post has solved the issue for me.
Reply

#5
### Likely Cause
This is likely happening due to how your Pod dependencies are being set up. Are you seeing any warnings from Xcode about multiple implementations defined in both classes, such as:

objc[54869]: Class FIRApp is implemented in both /Users/hli/Library/Developer/CoreSimulator/Devices/7766B001-8A5F-43B6-8860-5D36E8DC452C/data/Containers/Bundle/Application/8A18B716-D1D2-4110-83E2-9AE577A034CD/FirebaseDemo.app/FirebaseDemo (0x10d306d30) and /Users/hli/Library/Developer/Xcode/DerivedData/FirebaseDemo-ddfdueufgmkxwzameiwbuhnokgax/Build/Products/Debug-iphonesimulator/FirebaseDemo.app/PlugIns/FirebaseDemoTests.xctest/FirebaseDemoTests (0x11df8cbb0). One of the two will be used. Which one is undefined.



If so, it means you probably need to tweak your pod dependencies configuration. Since a XCTest target actually also brings in the host app's target, it's possible to get multiple imports of the same object. In this case, FIRApp was initializing Instance ID, but it was causing Instance ID to check with the _other_ FIRApp, which was saying it wasn't configured. This explains why it's crashing saying that it can't find the app which initialized it.

[See morganchen12@'s answer over in Github to see an example of a correct Podfile](

[To see links please register here]

).


### Original Answer Below:

So, this is happening for possibly two reasons:

1. Firebase can't find your `GoogleService-Info.plist` in your unit testing host app's bundle, or
2. The `GoogleService-Info.plist` file is either missing the `GCM_SENDER_ID` key or has an empty value in it.

We can eliminate (2) pretty easily - can you inspect your `GoogleService-Info.plist` file to see if it has a valid looking `GCM_SENDER_ID` (it will be a bunch of numbers, like 3252652634).

I'll investigate why the `GoogleService-Info.plist` apparently can be found with 3.15.x vs 3.16.0 and later.

Additionally, [as @markshiz said](

[To see links please register here]

), you may not actually want Firebase to be starting up during your unit test for your app. You can put your `FIRApp.configure()` call behind an if-statement, by checking if the app is running as a unit test.

To also help debug this, could you run your test app [with the environment variable `-FIRDebugEnabled` set](

[To see links please register here]

)? The output of that would be very helpful.
Reply

#6
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.
Reply

#7
Have you tried this?

let options = FIROptions(googleAppID: String!,
bundleID: String!,
gcmSenderID: String!,
apiKey: String!,
clientID: String!,
trackingID: String!,
androidClientID: String!,
databaseURL: String!,
storageBucket: String!,
deepLinkURLScheme: String!)
FIRApp.configure(with: config)
Reply

#8
I received the same error but from the **main app**, and came upon this thread when searching. The following answer may not be applicable for **unit tests**, but I am leaving it up in case someone else lands here with the same error message but in their **main app**.

If you are receiving `Google Sender ID must not be nil or empty` from your app it is probably caused by a missing entry under `GCM_SENDER_ID` in the `.plist` file).

There are 2 ways you can fix:

**Shotgun**

Just replace the entire `GoogleService-Info.plist` in your project with a freshly downloaded .plist file from firebase, which should contain the proper entry for your app's `GCM_SENDER_ID`.

**One-Line-of-Code**

In firebase console go to Settings (gear icon next to Overview), then Cloud Messaging. Copy the value under `Sender ID`. In Xcode go to your `GoogleService-Info.plist` file, create an entry for `GCM_SENDER_ID` and paste in the value.
Reply

#9
It took me a while to find the correct version to install until 3.17.0 is out.

pod 'Firebase/Core', '~> 3.15.0'
pod 'Firebase/Database', '~> 3.15.0'
pod 'Firebase/Auth', '~> 3.15.0'

This works guaranteed.

If you forget the `.0` and write down `3.15` instead, it would still install the faulty `3.16.0`.
Reply

#10
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.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through