无法在Swift应用中导入Firebase [英] Cannot import Firebase in Swift app

查看:140
本文介绍了无法在Swift应用中导入Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图学习Firebase时,我遵循了Firebase网站的IOS快速入门部分中的步骤。我使用Cocoapods并按照记录的步骤进行操作。但是,导入Firebase会导致编译器错误。我没有看到框架任何地方,但我确实看到Firebase的目标C文件。通过遵循下载zip文件并将其添加到项目的手动过程,我可以使其工作。不过,我想了解我做错了什么。

解决方案

您不需要使用桥接Header。

Firebase SDK使用Swift模块映射,所以您必须让CocoaPods知道。



使用这个podfile:

  use_frameworks! #this允许您使用导入Firebase 
pod'Firebase','> = 2.5.0'

然后你应该可以在任何Swift文件中使用导入Firebase



CocoaPods安装,XCode可能会感到困惑。清理一个 Cmd + K 并重新执行 Cmd + Shift + R 。如果这仍然是给你错误,然后重新启动Xcode,并尝试干净,并再次生成。


In attempting to learn Firebase, I followed the steps in the IOS Quickstart section of the Firebase website. I use Cocoapods and followed the steps exactly as documented. However, "import Firebase" results in a compiler error. I don't see the Framework any where but I do see the Firebase objective C files.. . By following the manual process of downloading the zip file and adding it to the project I can make it work. However, I would like to understand what I am doing wrong.

解决方案

You shouldn't need to use a Bridging Header.

The Firebase SDK uses Swift module mapping, so you'll have to let CocoaPods know.

Use this podfile:

use_frameworks! # this allows you to use import Firebase
pod 'Firebase', '>= 2.5.0'

Then you should be able to use import Firebase in any Swift file.

Sometimes after opening from CocoaPods install, XCode can get confused. Do a Cmd+K to clean and a Cmd+Shift+R to rebuild. If that still is giving you errors, then restart Xcode and try the clean and build again.

这篇关于无法在Swift应用中导入Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆