Pod 安装 Firebase/Analytics 失败

Pod install Firebase/Analytics fails

我正在使用 Window 10 并尝试使用 Pod 将 Firebase/Analyticsflutter 集成,一切似乎都很好,除了当我 运行 pod install

这里是stackTrace


 

    CocoaPods : 1.9.3
            Ruby : ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]
        RubyGems : 3.0.3
            Host : Unable to find an executable (No such file or directory - sw_vers)  ()
           Xcode : -version) ()
             Git : git version 2.27.0.windows.1
    Ruby lib dir : F:/Ruby26-x64/lib
    Repositories : trunk - CDN - https://cdn.cocoapods.org/

这是我的 Pod 文件


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

target 'Runner' do
  
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  # Pods for Runner


end

  # 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


podfile 在我的 flutter 项目的 ios 文件夹中

你能帮我解决这个问题吗?

您需要更新 pod 存储库。因此,请从命令行尝试以下命令。

pod repo update

如果错误仍然存​​在,那么您可能需要升级 cocoa pods。

sudo gem install cocoapods 

我在 flutter 项目中集成 firebase 存储时遇到了同样的错误。我做了 pod repo update,问题消失了。

编辑:

如果您在 pod 文件中手动添加了 firebase analytics pod,则只需将其删除。

需要在flutter项目的.yaml文件中添加依赖

dependencies:
  firebase_analytics: ^6.0.0

查看 here 了解更多详情。

注意:在处理 flutter 项目时,您不需要使用 pod(iOS) 或 gradle(android) 安装任何库,除非非常具体要求.

如果有任何特定的平台要求,那么您需要为 iOS 项目添加 pod 文件,如下所示...

你需要在 target 'Runner' 里面写 pod 'Firebase/Analytics' do...end 块,如下所示...

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

 target 'Runner' do

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

    # Pods for Runner

  # add the Firebase pod for Google Analytics
    pod 'Firebase/Analytics'

end

pod 'Firebase/Analytics' 应在“end”关键字之前添加。目前您已将其添加到“end”关键字之后。 希望我的回答能解决您的问题

您的广告连播必须在 targetend 关键字之间。

target 'Runner' do
      
    //Comment the next line if you don't want to use dynamic frameworks
    use_frameworks!
      pod 'Firebase/Analytics'

end