我已经安装了 firebase 的 pod 并导入了框架,并且已经做了一切可能的事情..但我仍然遇到了这种使用 undeclare 'firebase' 的错误。
导入 UIKit
导入 JSQMessagesViewController
导入 Firebase
class ChatViewController: JSQMessagesViewController {
var ref: Firebase
@IBOutlet weak var blackBtn: UIButton!
@IBOutlet weak var menuView: UIView!
@IBOutlet weak var TypeTxt: UITextField!
var messages = [JSQMessage]()
var outgoingBubbleImageView: JSQMessagesBubbleImage!
var incomingBubbleImageView: JSQMessagesBubbleImage!
override func viewDidLoad() {
super.viewDidLoad()
ref = Firebase(url: "https://candleheart-6bee6.firebaseio.com/")
// var ref = Firebase(url:"https://fir-example-fea13.firebaseio.com/names")
// ref.setValue(["name":"mamta"])
// title = "ChatChat"
setupBubbles()
collectionView!.collectionViewLayout.incomingAvatarViewSize = CGSizeZero
collectionView!.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero
// messageRef = rootRef.childByAppendingPath("messages")
TypeTxt.layer.cornerRadius = 22.0
TypeTxt.layer.borderWidth = 2.0
TypeTxt.layer.borderColor = UIColor.whiteColor().CGColor
TypeTxt.layer.backgroundColor = UIColor.whiteColor().CGColor
}
最佳答案
您是否构建并清理了该项目?
通过 CocoaPods 添加框架后,在大多数情况下,您应该立即清理并构建项目。
这应该负责向您的应用添加/构建新框架并使其处于事件状态以供使用
此外,请注意,添加 pod 后将创建项目的另一个副本,名称类似于“yourProjectName.xcworkspace”(您可以在目录中找到它)。它将有一个浅蓝色缩略图。添加 Pod 后,您必须开始使用项目的该副本而不是普通项目。
//注意:通常使用 CocoaPods,当您将 pod 添加到 Podfile 时,您只需保存 Podfile 并在终端中输入“podinstall”即可。确保在此之前到达您的项目目录。这将自动导入框架。但是,您确实需要在文件中编写导入语句才能明显地使用它
您不需要显式导入框架(如果使用 Cocoa Pods)
关于ios - swift-在ios中使用未声明的类型 'firebase',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38201685/