Firebase iOS SDK - Missing Database URL - ios

Hi I get the following error that I have inherited from a previous developer. My app keeps crashing with the following :
2016-06-21 22:26:16.828 Drnk[3234:1081556] The default app has not been configured yet.
2016-06-21 22:26:16.832 Drnk[3234:1081556] *** Terminating app due to uncaught exception 'MissingDatabaseURL', reason: 'Failed to get FIRDatabase instance: FIRApp object has no databaseURL in its FirebaseOptions object.'
*** First throw call stack:
My App delegate has the following code:
FIRApp.configure()
My controller where I call the database and the app crashes has the following code:
var ref: FIRDatabaseReference!
self.ref = FIRDatabase.database().reference()
I have added the google-services-plist file to my project as instructed.
This all works with another app I am developing but I can't solve this.

Make sure you're not calling FIRDatabase.database().reference() before viewDidLoad

In your class define a var:
var ref: FIRDatabaseReference?
then in viewDidLoad
ref = FIRDatabase.database().reference()

This is how I fixed it here https://stackoverflow.com/a/65866188/4833705
I didn't want to add the same code twice and the comments are kinda long so someone might miss this.

Download and replace the GoogleService-info.plist again since you have already registered the database in your account

Related

Failed to get default firebase instance in swift

As I was working on my iOS app, I got this error out of no where
Terminating app due to uncaught exception 'FIRAppNotConfigured', reason: 'Failed to get default Firebase Database instance. Must call `[FIRApp configure]` (`FirebaseApp.configure()` in Swift) before using Firebase Database.'
on the line initializing DB_BASE
var DB_BASE = Database.database().reference()
class DataService {
static let instance = DataService()
}
I have FirebaseApp.configure() in my didFinishLaunchingWithOptions AppDelegate function, so I'm not sure what the error is all about. I've tried updating pods, restarting my computer, but no luck so far.
I haven't worked with Database specifically, but we use Storage, Analytics and Remote Config. Have you put google-services.json to the root of the project?
The code you provided doesn't make it totally clear, but if DB_BASE by any chance is a member of a singleton (like DataService.instance), try moving it to a different place. Static variables get inited before applicationDidFinishLaunching is called.

Firebase database iOS crashing GTMSessionFetcher

I updated firebase and since then my app keeps crashing with the following error
Fetcher delegate class: NRMAURLSessionTaskDelegate Fetcher made an
extra session: GTMSessionFetcher 0x125d53db0 Couldn't assign
delegate.
Fetcher delegate class: NRMAURLSessionTaskDelegate
-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x125d53db0
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTMSessionFetcher
setFetcher:forTask:]: unrecognized selector sent to instance
0x125d53db0'
* First throw call stack: (0x18260ad8c 0x1817c45ec 0x182618098 0x1826105c8 0x1824f641c 0x104637b14 0x104613928 0x10461011c
0x102d9364c 0x102d96bdc 0x102d95140 0x102d92a54 0x102db3f90
0x102db36b0 0x102da0e00 0x105bfd1dc 0x105bfd19c 0x105c0bdfc
0x105c006ac 0x105c0bc20 0x105c006ac 0x105c0cd54 0x105c13e38
0x18222fe70 0x18222fb08) libc++abi.dylib: terminating with uncaught
exception of type NSException
the call that I make and crashes is the following:
let reviewsRef = Database.database().reference()
reviewsRef.child("reviews").queryOrdered(byChild: "timestamp").queryLimited(toLast: count)
I added a debug log and the call is made only once.
It seems the line that the app is crashing is
let ref = Database.database().reference()
Did anything changed regarding configuring Firebase from 4.9 to 5.0 version?
Another update:
It seems to be working on the Xcode simulator but not on device. Device is iPhone 6s with 11.4
Kind of working since on simulator I receive the whole database instead of only the "reviews" that I am requesting
if the rules are:
{
"rules": {
".read": true,
but when I change to:
"rules": {
"reviews": {
".read": true,
I get permission denied(on simulator).It has to do maybe with authentication? I understand that those 2 might be two different issues.
I have no idea why this happened on the first place. But I created a new project in firebase with exact same rules and it worked... for some reason the specific project became corrupt on firebase side.
NRMAURLSessionTaskDelegate indicates usage of New Relic - if it worked on a clean project there might be an incompatibility with Firebase

Setting cachePolicy of a parse query crashes application

I'm developing in Swift using the latest version of Parse from the website. I am attempting to set my cache policy to the NetworkElseCache value, which is displayed below:
let userRelation = User.currentUser()?.relationForKey("friends")
let userQuery = userRelation!.query()
userQuery.cachePolicy = .NetworkElseCache
userQuery.findObjectsInBackgroundWithBlock {
(users, error) -> Void in
print("Success")
}
The error occurs on the line:
userQuery.cachePolicy = .NetworkElseCache
and if the line is removed, the application runs fine, the error produced is:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Method not allowed when Pinning is enabled.'
I really don't have any idea what to do from here, I only started iOS development about a week ago using Parse and Swift, so I'm a bit on the lost side. I don't understand the callstack either, or how it will help me find my problem.
Disable the LocalDataStore in your AppDelegate.m
So comment following line
Parse.enableLocalDatastore() // Comment this line and try
Here's the full explanation from the engineers at Parse. But yes, long story short, if you're using local datastore, you will not be able to also use different cache policies.

iOS, Error when initializing GMSPlacesClient - unrecognized selector sent to instance

I am trying to integrate Google Maps API's Autocomplete feature on the app.
I am trying to instantiate GMSPlacesClient on the a ViewController's viewDidLoad override, according to the documentation here.
https://developers.google.com/places/ios-api/start
var placesClient: GMSPlacesClient?
override func viewDidLoad() {
placesClient = GMSPlacesClient()
super.viewDidLoad()
}
GMSServices has been instantiated on the AppDelegate using my key.
But I'm getting the following error during instantiation.
2015-10-02 22:04:59.734 food2eat[93509:13849667] -[NSThread gtm_performBlock:]: unrecognized selector sent to instance 0x7ffc03f04f80
2015-10-02 22:04:59.766 food2eat[93509:13849667] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSThread gtm_performBlock:]: unrecognized selector sent to instance 0x7ffc03f04f80'
What am I doing wrong?
Faced the same problem. This error started after I changed the GMS API key.
Oh I figured it out alright! I remembered that It worked for me while not using CocoaPods.
I specifically remember that I needed to add a bunch of frameworks, but the important thing here is that you have to add the -ObjC flag, to the Other Linker Flags in your target's Build Settings.
After doing that it worked for me!

Error when running Firebase in Swift

I am playing around with Firebase and I am trying to print the value of an item in Swift. This is the only code in the whole application, so nothing really complicated is going on.
var myRootRef = Firebase(url:"https://jotty.firebaseio.com/")
override func viewDidLoad() {
super.viewDidLoad()
myRootRef.observeEventType(.Value, withBlock: {
snapshot in
println(snapshot.value)
})
}
When I run this I get an error:
2015-07-15 12:15:03.492 Jotty[32431:733653] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FRepo youForgotToSetMinusObjCInTheOtherLinkerFlagsInYourXCodeProject]: unrecognized selector sent to instance 0x7b28b7a0'
Would anyone know how to fix this? I have been trying to fix this all day but I have no idea what is wrong with the application.
In "Build Settings" under "Other Linker Flags" use the "-ObjC" flag.
I recommend using CocoaPods instead of a manual setup.
See the Firebase docs for a manual setup.

Resources