11

In attempting to learn Firebase, I followed the steps in the IOS Quickstart section of the Firebase website. I use Cocoapods and followed the steps exactly as documented. However, "import Firebase" results in a compiler error. I don't see the Framework any where but I do see the Firebase objective C files.. . By following the manual process of downloading the zip file and adding it to the project I can make it work. However, I would like to understand what I am doing wrong. Xcode Page

Syed Tariq
  • 2,878
  • 3
  • 27
  • 37

7 Answers7

17

Documentation is outdated. I've used:

import FirebaseCore
MCMatan
  • 8,623
  • 6
  • 46
  • 85
10

You shouldn't need to use a Bridging Header.

The Firebase SDK uses Swift module mapping, so you'll have to let CocoaPods know.

Use this podfile:

use_frameworks! # this allows you to use import Firebase
pod 'Firebase', '>= 2.5.0'

Then you should be able to use import Firebase in any Swift file.

Sometimes after opening from CocoaPods install, XCode can get confused. Do a Cmd+K to clean and a Cmd+Shift+R to rebuild. If that still is giving you errors, then restart Xcode and try the clean and build again.

David East
  • 31,526
  • 6
  • 67
  • 82
  • Hey David - that's fine but seems not to be documented. https://www.firebase.com/docs/ios/quickstart.html – Darko Dec 26 '15 at 20:33
  • You're right, it should be in the docs. The module mapping is a newer addition so it hasn't made its way there yet. – David East Dec 26 '15 at 20:42
  • Hi David: I have the two commands as shown. I also used the 'Clean' command and restarted. But could not make it work. – Syed Tariq Dec 27 '15 at 05:13
  • In the tutorial (link in my comment) the reference to Firebase is implied. I do not see any 'import Firebase' anywhere is the code but the class is used. – Syed Tariq Dec 27 '15 at 05:16
  • Hi David: I was wrong regarding installation using Cocoapods. I opened the .xcworkspace from the console and did a 'Clean' and 'Build' as you suggested. Then 'import Firebase' did not issue a compile error. So essentially your answer is correct. Thhank you. – Syed Tariq Dec 27 '15 at 06:00
9
import FirebaseCore

and
FirebaseApp.configure()
These are the new documented injections into FireBase in Swift, rather than what you were using. Good day, sir.

Harris B
  • 113
  • 3
  • 7
2

You need to create an ObjC bridging header. There are many SO tutorials about that.

Darko
  • 9,655
  • 9
  • 36
  • 48
1

So I was having the same problem. Right now the fix is very simple, before you type import Firebase, after following the instructions, simply build your project. i.e. cmd+b, this did it for me, before doing this it does not recognize the path, no need to change the path!

dherre3
  • 498
  • 1
  • 4
  • 9
1

I got the same problem. and i try to execute these code below in terminal, then it works for me. After change your pod file with pod 'Firebase'. Go to terminal:

$ cd yourSource
$ pod install
$ pod repo update

waiting it update for about 5 minutes. Then calling update pod

$ pod update

it will update Firebase and install some parts are lacked I think it has something wrong about the version because i saw it installed ver 2.5 and when i called pod update, i was seeing it was installing ver 3.0

Heo Đất Hades
  • 1,573
  • 18
  • 14
0

Make sure you launched the project from "your_project_name.xcworkspace" file, instead of "your_project_name.xcodeproj" file. If not, your project won't find firebase.

hafiz031
  • 2,236
  • 3
  • 26
  • 48