almond
almond

Reputation: 39

storage() is unavailable use object construction FIRStorage() and database() is unavailable use object construction FIRDatabase()

When I put the code:

let databaseRef = FIRDatabase.database().reference()

I get the error:

database() is unavailable use object construction FIRDatabase()

And with:

let storageRef = FIRStorage.storage().reference()

I get the error:

storage() is unavailable use object construction FIRStorage()

I've added import FirebaseDatabase and import FirebaseStorage and have added them to my pod file and i have Xcode 7.2.1 and swift 2.

Upvotes: 2

Views: 536

Answers (2)

Tejas Ardeshna
Tejas Ardeshna

Reputation: 4371

First one is import like this:

import Firebase

Then create an object by:

let ref = Database.database().reference()

After latest release, FIRDatabase changed to Database

Upvotes: 1

Drei
Drei

Reputation: 874

Ok so assuming your're using the newest version of swift and firebase pods, it's now written as Database instead of FIRDatabse and Storage instead of FIRStorage.

Furthermore, your podfile needs to have

pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Storage'

for what you're doing.

Make sure that when you close, you save the Podfile and then run podinstall. Furthermore, its important that you use the .xcworkspace not the .xcodeproj after installing.

Lastly, I think you should only need

import Firebase

because it includes database and storage.

Upvotes: 1

Related Questions