xcode FirebaseApp.configure() 使用未解析的标识符“FirebaseApp”时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44753265/
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
FirebaseApp.configure() has an error use of unresolved identifier 'FirebaseApp'
提问by Ralph Rodriguez
So every time in my pod file I decide to add something like pod 'Firebase/Storage' with pod 'Firebase/Core', in my app delicate FirebaseApp.configure()
has an error use of unresolved identifier 'FirebaseApp' my pod file is
因此,每次在我的 pod 文件中,我决定添加类似 pod 'Firebase/Storage' 和 pod 'Firebase/Core' 之类的内容,在我的应用程序FirebaseApp.configure()
中,使用未解析的标识符 'FirebaseApp' 时出现错误,我的 pod 文件是
https://docs.google.com/document/d/1U7s5StRuNrI_2WtpHSvHhwhA1TMCsQ255dnjDAEhhcE/edit?usp=sharing
https://docs.google.com/document/d/1U7s5StRuNrI_2WtpHSvHhwhA1TMCsQ255dnjDAEhhcE/edit?usp=sharing
回答by KingCoder11
Your appdelegate class should look like this:
您的 appdelegate 类应如下所示:
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
I am assuming you are using xcode 8 and swift 3.
我假设您使用的是 xcode 8 和 swift 3。
回答by Jorge Casariego
In my case was because I was using an older version of Firebase (3.11.1)
就我而言,是因为我使用的是旧版本的 Firebase (3.11.1)
pod repo update
pod update
After update my repo and my local specs repositories with Firebase (4.2.0) FirebaseApp was resolved by Xcode!
使用 Firebase (4.2.0) 更新我的存储库和本地规范存储库后,Xcode 解决了 FirebaseApp 问题!
回答by Jungyeol
Try pod 'Firebase' instead of pod 'Firebase/Core'
尝试 pod 'Firebase' 而不是 pod 'Firebase/Core'
And check if Firebase 4.x was installed after 'pod install'
并检查“pod install”后是否安装了 Firebase 4.x
回答by Steven B.
The solution by morganchen12at this GitHubcomment resolved the same issue for me. I needed to modify the Podfile for the unit tests (OP already completed), and then add Firebase to the Header Search paths.
morganchen12在此GitHub评论中的解决方案为我解决了同样的问题。我需要修改单元测试的 Podfile(OP 已经完成),然后将 Firebase 添加到标题搜索路径。
For preservation, the comment is:
为了保存,评论是:
The issue is caused by duplicate FIRApp class definitions in the test runtime.
Your Podfile should look like this:
target "FirebaseDemo" do install_pods target "FirebaseDemoTests" do inherit! :search_paths end end
In order to avoid the missing required module Firebase error, add "${PODS_ROOT}/Firebase/Core/Sources" to the end of your test target's Header Search Paths in Xcode.
该问题是由测试运行时中重复的 FIRApp 类定义引起的。
您的 Podfile 应如下所示:
target "FirebaseDemo" do install_pods target "FirebaseDemoTests" do inherit! :search_paths end end
为了避免缺少必需的模块 Firebase 错误,请将“${PODS_ROOT}/Firebase/Core/Sources”添加到 Xcode 中测试目标的标头搜索路径的末尾。
回答by batgun
This will resolve this
这将解决这个问题
sudo gem install cocoapods
pod update