在 ios 上安装 Firebase 模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37322473/
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
Firebase Module install on ios
提问by N.Hicheri
I followed all instructions for integrating the new firebase
release on ios
:
我遵循了将新firebase
版本集成到以下的所有说明ios
:
I downloaded the file
GoogleService-Info.plist
and include it in the project.I installed the framework with cocoapods
我下载了该文件
GoogleService-Info.plist
并将其包含在项目中。我用 cocoapods 安装了框架
The problem is with this line:
问题出在这一行:
@import Firebase;
Xcode prints this error:
Xcode 打印此错误:
"Module Firebase not found"
“未找到模块 Firebase”
What is the solution?
解决办法是什么?
My code :
我的代码:
#import "AppDelegate.h"
@import Firebase
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
// Override point for customization after application launch.
return YES;
}
回答by Rubberduck
I ended up fixing it by using
我最终通过使用修复它
#import <Firebase/Firebase.h>
#import <Firebase/Firebase.h>
instead of
代替
@import Firebase
@import Firebase
回答by adolphefrancois
Got the same issue on the import. My target's build settings overrode the 'Header search path' without the '$(inherited)' flag
在导入时遇到了同样的问题。我的目标的构建设置覆盖了没有 '$(inherited)' 标志的 'Header search path'
'pod update' warns you about that.
'pod update' 会警告你这一点。
Open your target build settings enter image description here
In 'Header search paths' add a line containing $(inherited).
打开您的目标构建设置, 在此处输入图像描述
在“标题搜索路径”中添加一行包含 $(inherited)。
It solved the issue for me
它为我解决了这个问题
Hope it helps
希望能帮助到你
回答by kiran
Its work for me in this way.
它以这种方式为我工作。
using FirebaseCore/FirebaseCore.h
使用FirebaseCore/FirebaseCore.h
Try the below code.
试试下面的代码。
#import "AppDelegate.h"
#import <FirebaseCore/FirebaseCore.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[FIRApp configure];
return YES;
}
回答by nimit
I tried the above but sadly, nothing worked. Clean the build folder, clearing Xcode cache helped me. Try this:
我尝试了上述方法,但遗憾的是,没有任何效果。清理构建文件夹,清除 Xcode 缓存对我有帮助。尝试这个:
- Quit Xcode.
- Delete project's temp files located at ~/Library/Developer/Xcode/DerivedData
- Delete ProjectName.xcworkspace
- Delete Podfile.lock file and Pods folder
- Run pod install.
- Open the newly created ProjectName.xcworkspacefile and build.
- 退出 Xcode。
- 删除位于 ~/Library/Developer/Xcode/DerivedData 的项目临时文件
- 删除 ProjectName.xcworkspace
- 删除 Podfile.lock 文件和 Pods 文件夹
- 运行 pod 安装。
- 打开新创建的 ProjectName。xcworkspace文件并构建。
Pay extensive attention to the 6th step. Open this newly created xcworkspace, not xcodeproj.
高度重视第6步。打开这个新创建的xcworkspace,而不是 xcodeproj。
Original answer: https://stackoverflow.com/a/44486792/913601
回答by Ethan Doan
I have same issue and found solution in here: iOS - Firebase error: Use of unresolved identifier FIRApp running supplied code
我有同样的问题,在这里找到了解决方案:iOS - Firebase 错误:使用未解析的标识符 FIRApp 运行提供的代码
Doing the following steps on the terminal command line:
在终端命令行上执行以下步骤:
- pod repo update
- Commented the pod 'Firebase' line from my Podfile
- pod install (this removed the old Firebase)
- Added the pod 'Firebase' line again.
- pod install (added the new Firebase)
- pod 回购更新
- 评论了我的 Podfile 中的 pod 'Firebase' 行
- pod install(这删除了旧的 Firebase)
- 再次添加了 pod 'Firebase' 行。
- pod install(添加了新的 Firebase)
2nd and 3rd steps were the key I think, otherwise CocoaPods didn't try to update it. As I said maybe this could've been solved by doing pod update but now I can't go back and try again.
我认为第 2 和第 3 步是关键,否则 CocoaPods 没有尝试更新它。正如我所说,也许这可以通过执行 pod update 来解决,但现在我无法回去再试一次。
回答by Ian Barber
There are two ways of adding the Firebase SDK to your iOS project. You can either use CocoaPods, in which case its really important to make sure your pod dependency is in the target you are using. E.g.
有两种方法可以将 Firebase SDK 添加到您的 iOS 项目。您可以使用 CocoaPods,在这种情况下,确保您的 pod 依赖项位于您正在使用的目标中非常重要。例如
use_frameworks!
platform :ios, '7.0'
pod 'Firebase/Analytics'
target 'Target1' do
end
target 'Target2' do
end
There are a lot of different ways of configuring targets in CocoaPods, so your Podfile may look different. The important thing is that the target you specify is linked with the pod - in this case I have specified the Analytics pod so its available to all targets, but if I put it just in the Target1 do...end
block, then it wouldn't be available in Target2.
在 CocoaPods 中有很多不同的配置目标的方法,所以你的 Podfile 可能看起来不同。重要的是您指定的目标与 pod 相关联 - 在这种情况下,我指定了 Analytics pod,因此它可用于所有目标,但如果我只将它放在 Target1do...end
块中,那么它在目标 2。
If you're using the framework integration method, then make sure the libraries are specified in the Link Binary With Librariessection of your Build Phases tab. This should happen automatically if you drag them into a Frameworks group in Xcode.
如果您使用框架集成方法,请确保在Build Phases 选项卡的Link Binary With Libraries部分中指定了库。如果您将它们拖到 Xcode 中的 Frameworks 组中,这应该会自动发生。
Finally, if that doesn't work, Xcode may have cached something bad. Try opening the Productmenu, hold down Option and click Clean build folder.
最后,如果这不起作用,Xcode 可能缓存了一些不好的东西。尝试打开Product菜单,按住 Option 并单击Clean build folder。
回答by aaltintop
I had the same problem. I found that the problem was I have three targets in Cocoapods file. And only my main one target has Firebase added. So that when I want to import Firebase to a file that is used in other targets, Xcode gives error and says Module 'Firebase' not found. This is my pods project file. One solution for me is adding Firebase pod to all targets. Or another solution is removing the file from other targets.
我有同样的问题。我发现问题是我在 Cocoapods 文件中有三个目标。而且只有我的主要目标之一添加了 Firebase。因此,当我想将 Firebase 导入到其他目标中使用的文件时,Xcode 会出错并显示未找到模块“Firebase”。这是我的 pods 项目文件。对我来说,一种解决方案是将 Firebase pod 添加到所有目标。或者另一种解决方案是从其他目标中删除文件。
def common_pods
pod 'XXX'
end
target 'myMainProject' do
common_pods()
pod 'Firebase/Core'
pod 'Firebase/AdMob'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
end
target 'myExtention1' do
common_pods()
end
target 'myextension2' do
common_pods()
end
回答by Cristi B?lu??
This is lame but i fixed integration problems by adding the sources to my project instead using pods. I had to manually fix few files too.
这很蹩脚,但我通过将源添加到我的项目而不是使用 pod 来解决集成问题。我也不得不手动修复几个文件。
回答by Jayprakash Dubey
I had similar issue stating that FirebaseMessaging module not foundin header even though I had correct Podfile configuration.
我遇到了类似的问题,指出即使我有正确的 Podfile 配置,在标头中也找不到 FirebaseMessaging 模块。
Solution is to remove Cocoapods from project and add it again.
You can remove CocoaPodsfrom project using this link.
Thereafter, you can add CocoaPodsagain using this link.
Below is snapshot for Podfile that I have used.
下面是我使用过的 Podfile 的快照。
Below snapshot shows log on dependencies that are installed using Pods.
下面的快照显示了使用 Pod 安装的登录依赖项。
回答by dilip chaurasiya
update your pods. open terminal go to your project directory and type the following command
更新你的豆荚。打开终端转到您的项目目录并键入以下命令
pod update
豆荚更新