首页 文章

FirebaseApp.configure()使用未解析的标识符'FirebaseApp'时出错

提问于
浏览
7

所以每次在我的pod文件中我决定添加像pod 'Firebase/Storage’ with pod ' Firebase / Core'这样的东西,在我的应用程序中精致的 FirebaseApp.configure() 有一个错误使用未解析的标识符'FirebaseApp'我的pod文件是

https://docs.google.com/document/d/1U7s5StRuNrI_2WtpHSvHhwhA1TMCsQ255dnjDAEhhcE/edit?usp=sharing

5 回答

  • 1

    您的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:.
        }
    }
    

    我假设你正在使用xcode 8和swift 3 .

  • 0

    试试pod'Firebase'而不是pod'Firebase / Core'

    并检查“pod install”后是否安装了Firebase 4.x

  • 2

    在我的情况下是因为我使用的是较旧版本的Firebase(3.11.1)

    pod repo update
    pod update
    

    更新我的repo和我的本地规格存储库与Firebase(4.2.0)FirebaseApp由Xcode解决!

  • 9

    这将解决这个问题

    sudo gem install cocoapods 
     pod update
    
  • 0

    morganchen12 在此GitHub评论中的解决方案为我解决了同样的问题 . 我需要修改单元测试的Podfile(OP已经完成),然后将Firebase添加到Header Search路径 .

    为了保存,评论是:

    问题是由测试运行时中的重复FIRApp类定义引起的 . 您的Podfile应如下所示:目标“FirebaseDemo”
    install_pods

    目标“FirebaseDemoTests”做
    继承! :search_paths
    结束
    结束
    为了避免丢失所需的模块Firebase错误,请将“$
    / Firebase / Core / Sources”添加到Xcode中测试目标的标头搜索路径的末尾 .

相关问题