No such module 'FirebaseDatabase'

2019-05-23 09:52发布

I am developing iOS app with Swift 3 with Firebase database.

My Podfile:

target 'MyApp' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MyApp
  pod 'Firebase/Core'
  pod 'Firebase/Auth'
  pod 'Firebase/Database'
end

I run pod install, which installs the pods.

I created a class:

import Foundation
import FirebaseDatabase // Error: no such module 'FirebaseDatabase'

class MyDatabase {
    var ref: DatabaseReference!
    ...
}

But I get compiler error no such module 'FirebaseDatabase', why?

5条回答
萌系小妹纸
2楼-- · 2019-05-23 10:21

As the previous comments, make sure to check that your target name is exactly the same as in Xcode project settings, make sure to work in the generated .xcworkspace and what also helps is to Clean your project. Command + Shift + K

查看更多
成全新的幸福
3楼-- · 2019-05-23 10:21

I think you missed this step. In your AppDelegate first import Firebase, then add the below code enter image description here

查看更多
姐就是有狂的资本
4楼-- · 2019-05-23 10:26

As per previous comment please check the above whether you are using:

  1. .xcworkspace or not
  2. Check your target name
  3. Uninstall all pod and update your pod repo and than re install Pod
查看更多
手持菜刀,她持情操
5楼-- · 2019-05-23 10:29

Just try this , Make sure to Update all pods and secondly we don't need to explicitly import FirebaseDatabase , Just write import Firebase and you are done

import Foundation
import Firebase

class myDatabase {
    var DbReference = DatabaseReference()
}

My podFile

pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'Firebase/Database'
查看更多
Deceive 欺骗
6楼-- · 2019-05-23 10:34

Build the project.

The project needs to be built once for modules that come from CocoaPods to get installed into Xcode's ModuleCache (~/Library/Developer/Xcode/DerivedData/ModuleCache/) and be available for the editor's syntax checking.

查看更多
登录 后发表回答