热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

无法将Firebase导入Swift类-CannotImportFirebaseIntoSwiftClass

IamtotallynewtoFirebaseandbuildingiOSapps.InXcode7,IamtryingtoimportFirebaseinto

I am totally new to Firebase and building iOS apps. In Xcode 7, I am trying to import Firebase into my Swift class. In a swift file, I have typed "import Firebase".

我对Firebase和构建iOS应用程序完全陌生。在Xcode 7中,我试图将Firebase导入我的Swift类。在swift文件中,我输入了“import Firebase”。

I am getting an error that says

我收到一个错误说

"No such module 'Firebase'"

“没有这样的模块'Firebase'”

Any help would be greatly appreciated.

任何帮助将不胜感激。

10 个解决方案

#1


15  

There are two ways to install Firebase: manually, and with CocoaPods.

有两种方法可以安装Firebase:手动和CocoaPods。

I recommend using CocoaPods. In your Podfile, make sure you specify !use_frameworks:

我建议使用CocoaPods。在您的Podfile中,请确保指定!use_frameworks:

platform :ios, "9.0"
use_frameworks!

target 'MyProject' do
 pod 'Firebase'
end

Then after you pod install and open the MyProject.xcworkspace, you should be able to use import Firebase.

然后在您安装pod并打开MyProject.xcworkspace后,您应该可以使用导入Firebase。

edit by Jay:

杰伊编辑:

If you are targeting OS X your pod file may look more like this

如果您的目标是OS X,则您的pod文件可能看起来更像这样

platform :osx, '10.10'
use_frameworks!

target 'MyProject' do
  pod 'FirebaseOSX', '>= 2.4.2'
end

#2


31  

For me it was this:

对我来说就是这样:

The Framework is called FirebaseAnalytics now and not Firebase.

该框架现在称为FirebaseAnalytics而不是Firebase。

The official documentation even has this wrong.

官方文档甚至有这个错误。

So after installing with CocoaPods (Firebase version 3.4.0) this works:

因此,在使用CocoaPods(Firebase版本3.4.0)安装后,这可以:

import FirebaseAnalytics

#3


5  

If you imported Firebase manually, update Framework Search Paths and Header Search Paths under your target's Build Settings so they include the Firebase frameworks.

如果您手动导入Firebase,请在目标的Build Settings下更新Framework Search Paths和Header Search Paths,以便它们包含Firebase框架。

#4


2  

If you have added the firebase framework manually, delete it and add it again.Rebuild the project and it will work.

如果您已手动添加了firebase框架,请将其删除并再次添加。重建项目即可。

There seems to be a bug.This happens when you discard the changes.

似乎有一个错误。当您放弃更改时会发生这种情况。

#5


2  

When using the CocoaPods installation method, you can start by removing the project workspace file:
rm -rf MyProject.xcworkspace

使用CocoaPods安装方法时,可以先删除项目工作区文件:rm -rf MyProject.xcworkspace

Then, edit the Podfile to following, which will be automatically set for the latest version of Firebase:

然后,将Podfile编辑为以下内容,将自动为最新版本的Firebase设置:

use_frameworks! 
target 'MyProject' do
  pod 'Firebase/Core'
  pod 'Firebase/Database'
end

target 'MyProjectUITests' do
  pod 'Firebase/Core'
  pod 'Firebase/Database'
end

Finally, reinstall the pod

最后,重新安装pod

pod install

#6


1  

For me, I had to make sure that cocoapods was updated to version 1.0.0.

对我来说,我必须确保cocoapods已更新到版本1.0.0。

Just run sudo gem install cocoapods, then clean project and pod install. Compiler should not complain anymore.

只需运行sudo gem install cocoapods,然后清理项目和pod安装。编译器不应再抱怨了。

#7


0  

For me, I found that I wrote the line : (pod 'Firebase') in the wrong line in the pod file. you only need to find the comment : # Pods for projectName and then replace it with pods like: pod 'Firebase' or : pod 'Firebase/Auth'

对我来说,我发现我在pod文件的错误行中写了一行:( pod'Firebase')。你只需要找到评论:#Pods为projectName然后用pods替换它们:pod'Firebase'或:pod'Firebase / Auth'

#8


0  

  1. open terminal and type cd "drag and drop your project" Enter
  2. 打开终端并输入cd“拖放你的项目”回车
  3. type "pod init"
  4. 输入“pod init”
  5. open pod file with xcode
  6. 用xcode打开pod文件
  7. under use_frameworks! type pod 'Firebase' pod 'Firebase/xxx'
  8. 在use_frameworks下!输入pod'Firebase'pod'Firebase / xxx'
  9. back to terminal and type "pod install" 6.open your project folder and run xxx.xcworkspace
  10. 返回终端并键入“pod install”6.打开项目文件夹并运行xxx.xcworkspace

#9


0  

In your Podfile make sure to have pod 'Firebase' in addition to your pod 'Firebase/Core' enter image description here After, :wq from vim and run a command pod update. Make sure to open .xcworkspace

在你的Podfile中,确保除了你的pod'Firebase / Core'之后还有pod'Firebase',之后:来自vim的wq并运行命令pod更新。确保打开.xcworkspace

#10


0  

So after spending hours and hours trying to fix this error I did the following and my life went back to normal

所以在花了几个小时试图修复这个错误后,我做了以下事情,我的生活恢复了正常

a) Went to my Podfile and changed pod 'Firebase', '~> 4.8' to pod 'Firebase/Core'

a)去我的Podfile并将pod'Firebase','〜> 4.8'更改为pod'Firebase / Core'

b) Then I went into my AppDdelegate changed from import Firebase to import FirebaseCore

b)然后我进入我的AppDdelegate,从导入Firebase更改为导入FirebaseCore

If you were facing the same problem as me this solution will work for you

如果您遇到与我相同的问题,此解决方案将适合您


推荐阅读
  • imnewtotheswiftandxcodeworld,soimhavingaproblemtryingtointegrateapackagetomypro ... [详细]
  • iOS推送手机消息的技术背后的奥秘揭示
    作者:allenzzhao,腾讯IEG运营开发工程师消息推送我们几乎每天都会用到,但你知道iOS中的消息推送是如何实现的吗?本文将从推送权限申请,到本地和远程消息推送, ... [详细]
  • 嗨,我想用多处理来加速我的代码。但是,apply_async对我不起作用。我试着做一个简单的例子,比如:frommultip ... [详细]
  • 2015年iOS测试现状
    本文由伯乐在线-nathanw翻译,dopcn校稿。未经许可,禁止转载!英文出处:www.mokacoding.com。欢迎加入翻译小组。几周前,我决定将将我在mokacoding ... [详细]
  • 我的iOS开发入门自学路径
    我有一个清单,列着希望在大学里完成的事。比如,学一门乐器,和朋友去旅游,搭建自己的博客,去滑翔,看各主题的书籍。其中一项是,写自己的App并且上架。去年开始,我准备完成这一项,所以 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • Annotation的大材小用
    为什么80%的码农都做不了架构师?最近在开发一些通用的excel数据导入的功能,由于涉及到导入的模块很多,所以开发了一个比较通用的e ... [详细]
  • Xcode离线安装帮助文档1.在线查看帮助文件:Xcode下查看帮助文件,菜单Help-DeveloperDocumentation在右上角搜索框中即可检索,但速度很慢 ... [详细]
  • iOS开发Debug和Release的理解
    2019独角兽企业重金招聘Python工程师标准参考:http:blog.csdn.netmad1989articledetails406580331&# ... [详细]
  • 运行就报对我有效的解决方法是:把真机和模拟器需要的文件手动加入其中,具体请参考网络上提供的其他解决方 ... [详细]
  • jsappsugar,基于,js,语法,定义 ... [详细]
  • 转载自http:blog.csdn.netzhifeiyu2008articledetails8829637打开Java的JAR文件我们经常可以看到文件中包含着一个META-INF ... [详细]
  • 这是一篇CocoaChina的一个网友整理的Xcode快捷键大全,实在是太多了,我看得眼花缭乱的,不过还是非常实用,想学习就往下看吧!可能有些新手刚用mac,不知与windows键 ... [详细]
  • 1、前言在macOS下,如果对大量图片进行处理或数据收集,查找了一下,通过使用sips命令,可以进行图片的大部分操作处理,如果使用shell,就可以灵活和自动化的批量操作图片!2、 ... [详细]
author-avatar
24吴梦琦_581
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有