xcode 无法调用非函数类型“module<Firebase>”的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37330220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:49:33  来源:igfitidea点击:

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

iosxcodeswiftfirebase

提问by Edward Du

i have a strange error when i was using firebase from google.

当我使用来自谷歌的 firebase 时,我遇到了一个奇怪的错误。

when i trying to init the Fire base setup the ref address for it using this code here

当我尝试在此处使用此代码初始化 Fire 基础设置参考地址时

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

, it shows an error:

,它显示一个错误:

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

my pod file looks like this:

我的 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

Environment: Xcode 7.3.1 (7D1014) Firebase straight from the official site. Swift language.

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

please anyone help ?

请有人帮忙吗?

回答by tomW

My pod file looks like this :

我的 pod 文件如下所示:

platform :ios, ‘9.2'

    use_frameworks!

target 'firebaseWithChris' do

    pod 'Firebase'

    pod 'Firebase/Database'

end

Xcode:in viewController.swift file in viewDidLoad method

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

instead of

代替

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

try

尝试

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

This worked for me :]

这对我有用:]

回答by tsig

I'm also new to Firebase and run in the same problem. It seems that Firebase 3.2.0 and FirebaseDatabase 3.0.1. use different approach. The following worked for me:

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

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

回答by KevinS

I ran into this same problem. You might be referring to some sample code for Firebase.com. The API has been updated and is no longer referred to as "Firebase.com" It's not clear what the new name is -- ?

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

Anyway, the link below guides you through updating your podfile to include:

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

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

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

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

remember to run

记得跑

pod update 

and changing your code to call the new methods. It's working for me with Xcode 7.2

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

回答by EberronBruce

I had the same issue. So, this is what I did to resolve it. I uninstall Firebase Cocoapods. Then I installed Firebase manually.

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

I used this link.
https://www.firebase.com/docs/ios/alternate-setup.html
and added the frameworks and dependencies that states on the this url.

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

Note: These libraries.
libicucore.dylib
libc++.dylib
Should be .tbd

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

The answer was given here.
Xcode compile error with Firebase

答案在这里给出。
Firebase 的 Xcode 编译错误

After I manually installed Firebase the error went away. If anyone knows why I would love to know myself what caused this error.

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

Note: Google updated Firebase. So, maybe you look more into that.

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

回答by benji

I had the same issue. In order to resolve it, you have to modify your podfile. I wrote in my podfile those two lines (as it was asked by firebase in its intro video: https://www.youtube.com/watch?v=joVi3thZOqc)

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

pod 'Firebase'

pod 'Firebase/Database'   

hope it will help you :)

希望它会帮助你:)

回答by nivritgupta

i also face the same issue . i delete the ccocoa pod and follow this link to install the firebase through cocoapod . after that i am able to solve this problem

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

Step 1 :- you need CocoaPods 1.0.0 or later

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

Step 2 :- Create a Firebase project in the Firebase console,

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

Click Add Firebase to your iOS app and follow the setup steps. If you're importing an existing Google project, this may happen automatically and you can just download the config file.click here

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

Step 3 :- Add the SDK

第 3 步:- 添加 SDK

pod 'Firebase'

吊舱'Firebase'

now Initialize Firebase in your app

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

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

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

Thanks

谢谢

回答by ??ng An

Firebase is belonged to Google now. I had many updates. Please, take a look at: https://firebase.google.com/support/guides/firebase-ios

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