Xcode 11 - Firebase 问题(没有这样的模块“Firebase”)

Posted

技术标签:

【中文标题】Xcode 11 - Firebase 问题(没有这样的模块“Firebase”)【英文标题】:Xcode 11 - Firebase issue (No Such module "Firebase") 【发布时间】:2019-11-21 09:31:04 【问题描述】:

我在这个网站上尝试了所有可能的答案,但都没有奏效。我添加了一个 pod 文件,但在导入 Firebase 后,我不断收到 (No such module 'Firebase') 错误

这是我的 appDelegate 的代码

//
//  AppDelegate.swift
//  Firebase app
//
//  Created by Karan Singh on 11/21/19.
//  Copyright © 2019 Karan Singh. All rights reserved.
//

import UIKit
import Firebase


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate 

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool 
        FirebaseApp.configure()
        return true
    

    // MARK: UISceneSession Lifecycle

    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration 
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) 
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    



这是我的 pod 文件的样子

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'Firebase app' do
  # Comment the next line if you don't want to use dynamic frameworks
 use_frameworks!

  # Pods for Firebase app

# add the Firebase pod for Google Analytics
    pod 'Firebase/Analytics'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods

    pod 'Firebase/Auth'

end

我仍在学习 Xcode 中的编码 - 感谢您帮助我解决这个问题!

【问题讨论】:

尝试构建项目... 添加pod 'Firebase/Core Firebase/Core 已弃用且没有必要。 可能需要构建 Xcode 模块缓存。 【参考方案1】:

正如 Hurobaki 所说,您必须像这样在 podfile 中添加 firebase/core:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'FirebaseApp' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
    # Add the Firebase pod for Google Analytics
    pod 'Firebase/Analytics'
    pod 'Firebase/Core'
    pod 'Firebase/Messaging'
    pod 'Firebase/Auth'

end   

【讨论】:

FirebaseOSX 是古老的。有关当前推荐的 OSX 方法,请参阅github.com/firebase/firebase-ios-sdk#macos-and-tvos。 Firebase/Core 现已弃用。现在只需要使用 Firebase/Analytics 即可获得核心功能,因为分析是核心功能

以上是关于Xcode 11 - Firebase 问题(没有这样的模块“Firebase”)的主要内容,如果未能解决你的问题,请参考以下文章

使用选项配置 firebase 在 Xcode 11 和 Firebase 6.19 中崩溃

Firebase 动态链接无法从冷启动 - Xcode 11,iOS 13

从 Xcode 11 更新到 12 后的 App Delegate/Scene Delegate 和 Firebase 问题 [关闭]

在 Xcode 11.5 中从 AppDelegate 访问 ViewController(firebase google 登录)

SwiftUI 与 Firebase 使用 Xcode 11 GM 种子 2 - Swift UI Firestore

Xcode 11 Firebase auth for Mac app has error 访问钥匙串时出错