【问题标题】:swift- use of undeclared type 'firebase' in iosswift-在 ios 中使用未声明的类型“firebase”
【发布时间】:2016-07-05 18:59:23
【问题描述】:

我也安装了 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
    }

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    您是否构建并清理了项目?

    通过 CocoaPods 添加框架后,在大多数情况下,您应该立即清理和构建项目。

    这应该负责为您的应用添加/构建新框架并使其处于活动状态以供使用

    另外,请注意,您的项目的另一个副本将在添加 pod 时创建,称为“yourProjectName.xcworkspace”(您可以在您的目录中找到它)。它将有一个浅蓝色的缩略图。添加 pod 后,您必须开始使用该项目的副本而不是普通项目。

    // 注意:一般使用 CocoaPods,当你添加一个 Pod 到你的 Podfile 时,你只需要保存 Podfile 并在你的终端中输入 'podinstall'。确保在此之前进入您的项目目录。这将自动导入框架。但是,您确实需要在文件中编写导入语句才能明显使用它

    您不需要显式导入框架(如果使用 Cocoa Pods)

    【讨论】:

    • @aarti 您是否将框架文件拖到您的项目中?只是好奇
    • 您不应该将任何文件拖到项目中。只需在 podfile 中提及 pod 并在终端中使用 pod install 即可。没有别的了。之后也要清理和构建。
    • 首先我安装了 pod,然后我将 firebase 框架拖到应用程序中
    • 不要拖动任何东西。按照我的步骤。首先删除您从外部拖动的所有 Firebase 文件。 (同时删除与 firebase 相关的二进制文件和框架。)接下来在 pod 文件中添加 pod 名称。然后进行 pod install。
    • 一旦你做了 pod install,那么你应该清理和构建项目,它会直接将所有文件带到项目中。仔细阅读答案,里面应有尽有
    猜你喜欢
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多