【问题标题】:Cannot call value of non-function type 'module<Firebase>'无法调用非函数类型“module<Firebase>”的值
【发布时间】:2016-09-16 17:55:30
【问题描述】:

我在使用来自 google 的 firebase 时遇到了一个奇怪的错误。

当我尝试初始化 Fire 基地时,在这里使用此代码为其设置参考地址

let BASE_URL = "YOUR_FIREBASE_URL"
var FIREBASE_REF = Firebase(url: BASE_URL)

,显示错误:

Cannot call value of non-function type 'module<Firebase>'

我的 pod 文件如下所示:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

target 'Mission Board' do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  pod 'Firebase', '>=2.4.2'
end

环境: Xcode 7.3.1 (7D1014) Firebase 直接来自官方网站。 Swift 语言。

请任何人帮忙?

【问题讨论】:

标签: ios xcode swift firebase


【解决方案1】:

我的 pod 文件如下所示:

platform :ios, ‘9.2’

    use_frameworks!

target 'firebaseWithChris' do

    pod 'Firebase'

    pod 'Firebase/Database'

end

Xcode:在 viewDidLoad 方法中的 viewController.swift 文件中

而不是

var rootRef = Firebase(url:"https://<YOUR-FIREBASE-APP>.firebaseio.com")

试试

var rootRef = FIRDatabase.database().reference()

这对我有用:]

【讨论】:

  • 这也为我编译,但你在哪里指定应用程序的 url?
  • @CristiBăluță 它在 GoogleService-Info.plist 文件中
【解决方案2】:

我也是 Firebase 的新手,遇到了同样的问题。似乎 Firebase 3.2.0 和 FirebaseDatabase 3.0.1。使用不同的方法。以下对我有用:

let rootRef = FIRDatabase.database().referenceFromURL(BASE_URL)
var messageRef: FIRDatabaseReference!

【讨论】:

    【解决方案3】:

    我遇到了同样的问题。您可能指的是 Firebase.com 的一些示例代码。 API 已更新,不再称为“Firebase.com”。不清楚新名称是什么——?

    无论如何,下面的链接将指导您更新您的 podfile 以包含:

    pod 'Firebase/Core'
    pod 'Firebase/Database'
    pod 'Firebase/Auth'
    

    https://firebase.google.com/support/guides/firebase-ios

    记得跑

    pod update 
    

    并更改您的代码以调用新方法。它适用于 Xcode 7.2

    【讨论】:

      【解决方案4】:

      我有同样的问题。所以,这就是我为解决它所做的。我卸载了 Firebase Cocoapods。然后我手动安装了 Firebase。

      我使用了这个链接。
      https://www.firebase.com/docs/ios/alternate-setup.html
      并添加了在此 url 上声明的框架和依赖项。

      注意:这些库。
      libicucore.dylib
      libc++.dylib
      应该是 .tbd

      这里给出了答案。
      Xcode compile error with Firebase

      在我手动安装 Firebase 后,错误消失了。如果有人知道为什么我很想知道自己是什么导致了这个错误。

      注意:Google 更新了 Firebase。所以,也许你会更深入地了解这一点。

      【讨论】:

      • 我是否只删除所有将被视为完全卸载的 pod 文件?
      • 另一个问题,要初始化我需要在 appDelegate.swift 中调用 FIRApp.configure() 的 Firebase,但我发现有另一个类似这样的错误:使用未解析的标识符 'FIRApp' 是什么原因?跨度>
      • @EberronBruce 您正在使用旧方法通过 cocoa-pod 安装 firebase,我认为您的 firebase 版本是 2.5.1 而当前的 firebase 版本是 3.0.1 。使用此链接firebase.google.com/docs/ios/setup#add_the_sdk
      【解决方案5】:

      我有同样的问题。为了解决它,您必须修改您的 podfile。我在我的 podfile 中写了这两行(正如 firebase 在其介绍视频中提出的那样:https://www.youtube.com/watch?v=joVi3thZOqc

      pod 'Firebase'
      
      pod 'Firebase/Database'   
      

      希望对你有帮助:)

      【讨论】:

        【解决方案6】:

        我也面临同样的问题。我删除了 cccoa pod 并按照此链接通过 cocoapod 安装 firebase。之后我就可以解决这个问题了

        第 1 步:- 您需要 CocoaPods 1.0.0 或更高版本

        第 2 步:- 在 Firebase 控制台中创建一个 Firebase 项目,

        点击将 Firebase 添加到您的 iOS 应用,然后按照设置步骤操作。如果您要导入现有的 Google 项目,这可能会自动发生,您只需下载配置文件即可。click here

        第 3 步:- 添加 SDK

        pod 'Firebase'

        现在在您的应用中初始化 Firebase

        https://firebase.google.com/docs/ios/setup#add_the_sdk

        谢谢

        【讨论】:

          【解决方案7】:

          Firebase 现在属于 Google。我有很多更新。请看一下:https://firebase.google.com/support/guides/firebase-ios

          【讨论】:

            猜你喜欢
            • 2017-04-06
            • 1970-01-01
            • 1970-01-01
            • 2016-10-04
            • 1970-01-01
            • 2017-08-16
            • 2020-02-01
            • 2021-01-15
            • 2021-03-30
            相关资源
            最近更新 更多