FirebaseCore.h 文件未在使用 CocoaPods 的项目中生成

FirebaseCore.h file not generating in project using CocoaPods

我最近在我的项目中安装了 CocoaPods 和 Firebase。我一直在尝试构建,但出现以下错误:

  1. 'FirebaseCore/FirebaseCore.h' file not found

  2. Could not build Objective-C module 'Firebase'

  3. Command PhaseScriptExecution failed with a nonzero exit code

我检查了我的文件夹,FirebaseCore.h 文件肯定不存在。我重新安装了 CocoaPods,修改了 Podfile 并多次执行 'pod update' 和 'pod install'。

我已经查看了堆栈溢出中列出的几个问题和解决方案,但其中 none 有效。

这是我的规格:

  1. Xcode 11.3.1

  2. Swift 5

我的 Podfile 如下所示:

# platform :ios, '9.0'

target 'project' do

      use_frameworks!

      # Pods for Project
      pod 'MessageKit', '~> 3.0.0-swift5'
      pod 'MessageInputBar'
      # Add the Firebase pod for Google Analytics
    pod 'Firebase/Analytics'

    # Add the pods for any other Firebase products you want to use in your app
    # For example, to use Firebase Authentication and Cloud Firestore
    pod 'Firebase/Auth'
    pod 'Firebase/Firestore'
    end

甚至我在升级到 Xcode 11.2.1 时也遇到了同样的问题。使用 Firebase 6.13.0 后错误得到解决。 请按以下方式更改您的 Podfile,

 pod 'Firebase', '=6.13.0'
 pod 'Firebase/Core'
 pod 'Firebase/Analytics'

这是您在使用 .xcodeproj 文件打开项目时会遇到的错误。

您需要使用.xcworkspace 文件打开项目。

该文件是在使用 cocoapods 安装 pods 时生成的。

其他尝试

  • 退出 XCode。进入终端并执行此 sudo gem install cocoapods。然后使用 cocoapods.app 使用您的 pod 文件更新项目。然后清理并重建项目。

  • 在您的项目中,select 左栏中的项目名称(项目文件所在的位置)。然后在 Targets 中,确保团队弹出窗口 select 为您的团队名称,而不是 'None',并且您的签名证书是正确的。

  • 这个很极端,但我看到它纠正了一些构建问题。删除登录钥匙串(使用 keychain.app)。这也将删除您所有存储的密码,因此请记住这一点。

Somehow my base project had other issues that were generating this error that I was never able to uncover.  So I did the following:
1. Created a new project and imported old project files.
2. Installed cocoapods on the new project
3. Followed the FireBase instructions referenced in the answer from @Jay
4. Cleaned project and performed a build
5. No more error