Leem.fin Leem.fin - 1 year ago 154
iOS Question

Failed to initialize Firebase

I am developing an iOS project (with xcode 8 & swift 3). I have installed firebase pod through cocoapod. This is my pod:

target 'myApp' do
pod 'Firebase', '~> 3.9'

Then I open myApp.xcworkspace file, the project is opened in Xcode.

Then I try to initialize a firebase instance by:

let BASE_URL = "https://myapp-35211.firebaseio.com/"
// ERROR: Cannot call value of non-function type 'module<Firebase>'
let firebase = Firebase(url: "\(BASE_URL)")

(I have
import Firebase

I am trying to use firebase database.

Why I get the above error?

====== UPDATE =======

OK, I followed the steps to initialize Firebase (add my project in Firebase, download the GoogleService-Info.plist & use
, etc). Now I get this error:

enter image description here


My Podfile is like this:

target 'myApp' do
pod 'Firebase', '~> 3.9'

Does it mean this pod doesn't include

===== UPDATE AGAIN =====

OK, add
to Podfile solved the above issue, but why
pod doesn't include
? Isn't it a subset of

Answer Source

I'm not sure why are you using the base url on your code, because now, when you are setting up your firebase project, you can link your app project with your firebase project passing your Bundle identifier.

Take a look on the firebase documentation: https://firebase.google.com/docs/database/ios/start

If you do so, then you just need to do 2 steps:

1 - On you appDelegate over didFinishLaunchingWithOptions: add:


2 - On the class that you want to take your firebase reference you can do:

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

This way you will have on ref the reference to the root of your firebase database

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download