31

I am totally new to Firebase and building iOS apps. In Xcode 7, I am trying to import Firebase into my Swift class. In a swift file, I have typed "import Firebase".

I am getting an error that says

"No such module 'Firebase'"

Any help would be greatly appreciated.

David East
  • 31,526
  • 6
  • 67
  • 82
Will Jackson
  • 335
  • 1
  • 4
  • 8

11 Answers11

49

For me it was this:

The Framework is called FirebaseAnalytics now and not Firebase.

The official documentation even has this wrong.

So after installing with CocoaPods (Firebase version 3.4.0) this works:

import FirebaseAnalytics
Ole
  • 603
  • 1
  • 6
  • 4
26

There are two ways to install Firebase: manually, and with CocoaPods.

I recommend using CocoaPods. In your Podfile, make sure you specify use_frameworks!:

platform :ios, "9.0"
use_frameworks!

target 'MyProject' do
 pod 'Firebase'
end

Then after you pod install and open the MyProject.xcworkspace, you should be able to use import Firebase.

edit by Jay:

If you are targeting OS X your pod file may look more like this

platform :osx, '10.10'
use_frameworks!

target 'MyProject' do
  pod 'FirebaseOSX', '>= 2.4.2'
end
Cesar Bielich
  • 4,754
  • 9
  • 39
  • 81
David East
  • 31,526
  • 6
  • 67
  • 82
10

If you imported Firebase manually, update Framework Search Paths and Header Search Paths under your target's Build Settings so they include the Firebase frameworks.

Crashalot
  • 33,605
  • 61
  • 269
  • 439
  • 1
    I had to add to `Header search Paths` the path to the place where Firebase.h is. For example `$(PROJECT_DIR)/Frameworks/Firebase` – Tomasz Nazarenko Apr 13 '18 at 07:05
4

When using the CocoaPods installation method, you can start by removing the project workspace file:
rm -rf MyProject.xcworkspace

Then, edit the Podfile to following, which will be automatically set for the latest version of Firebase:

use_frameworks! 
target 'MyProject' do
  pod 'Firebase/Core'
  pod 'Firebase/Database'
end

target 'MyProjectUITests' do
  pod 'Firebase/Core'
  pod 'Firebase/Database'
end

Finally, reinstall the pod

pod install
Idan
  • 5,405
  • 7
  • 35
  • 52
2

If you have added the firebase framework manually, delete it and add it again.Rebuild the project and it will work.

There seems to be a bug.This happens when you discard the changes.

shivamkaushik
  • 374
  • 1
  • 12
2
  1. open terminal and type cd "drag and drop your project" Enter
  2. type "pod init"
  3. open pod file with xcode
  4. under use_frameworks! type pod 'Firebase' pod 'Firebase/xxx'
  5. back to terminal and type "pod install" 6.open your project folder and run xxx.xcworkspace
Habib Alejalil
  • 435
  • 1
  • 4
  • 17
1

For me, I had to make sure that cocoapods was updated to version 1.0.0.

Just run sudo gem install cocoapods, then clean project and pod install. Compiler should not complain anymore.

Guy Daher
  • 5,526
  • 5
  • 42
  • 67
1

So after spending hours and hours trying to fix this error I did the following and my life went back to normal

a) Went to my Podfile and changed pod 'Firebase', '~> 4.8' to pod 'Firebase/Core'

b) Then I went into my AppDdelegate changed from import Firebase to import FirebaseCore

If you were facing the same problem as me this solution will work for you

GyroCocoa
  • 1,542
  • 16
  • 19
1

Those who are using swift 3 are welcome to try this. It worked for me.

My pod file:

platform :osx, '9.0'
use_frameworks!

target 'MyProject' do
  pod 'Firebase/Messaging'
  pod 'Firebase'
end

AppDelegate:

import FirebaseCore
import FirebaseMessaging
Bobbbay
  • 322
  • 6
  • 18
Naval Hasan
  • 1,226
  • 1
  • 13
  • 18
0

For me, I found that I wrote the line : (pod 'Firebase') in the wrong line in the pod file. you only need to find the comment : # Pods for projectName and then replace it with pods like: pod 'Firebase' or : pod 'Firebase/Auth'

0

In your Podfile make sure to have pod 'Firebase' in addition to your pod 'Firebase/Core' enter image description here After, :wq from vim and run a command pod update. Make sure to open .xcworkspace

bisamov
  • 650
  • 1
  • 8
  • 24