【问题标题】:App fails when building upon adding Firebase Cloud Messaging Dependency to PubSpec.yaml -Flutter在将 Firebase 云消息传递依赖项添加到 PubSpec.yaml -Flutter 时构建应用程序失败
【发布时间】:2021-03-23 18:42:23
【问题描述】:

当我使用 VScode 或终端或 XCode 构建应用程序时,它可以在不添加依赖项的情况下完美运行,但是当我将依赖项添加到我的 Pubspec.yaml 时,我收到以下错误:


/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCCTLibrary/GDTCCTUploadOperation.m:36:9: fatal error: 'GoogleUtilities/GULURLSessionDataResponse.h' file not found
    #import <GoogleUtilities/GULURLSessionDataResponse.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11.
Exited (sigterm)**

**

我尝试在此处搜索解决方案,但找不到任何解决方案。 我以前尝试过的解决方案是:

  1. 运行 Flutter Clean 然后 Flutter Run(不起作用)
  2. 删除 Podfile.lock 和 podfile 和 .xcworkspace 文件,然后在终端中运行 pod install(无效)
  3. Pod 更新

这是我的颤振医生 Trace:

**[✓] Flutter (Channel stable, 2.0.3, on macOS 11.2 20D64 darwin-x64, locale en-EG)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] Connected device (2 available)**

这是我的 PodFile:


    # Uncomment this line to define a global platform for your project
    # platform :ios, '9.0'
    
    # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
    ENV['COCOAPODS_DISABLE_STATS'] = 'true'
    
    project 'Runner', {
      'Debug' => :debug,
      'Profile' => :release,
      'Release' => :release,
    }
    
    def flutter_root
      generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
      unless File.exist?(generated_xcode_build_settings_path)
        raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
      end
    
      File.foreach(generated_xcode_build_settings_path) do |line|
        matches = line.match(/FLUTTER_ROOT\=(.*)/)
        return matches[1].strip if matches
      end
      raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
    end
    
    require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
    
    flutter_ios_podfile_setup
    
    target 'Runner' do
      use_frameworks!
      use_modular_headers!
    
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
    end
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    end

这是我的 pubspec.yaml,是的,我使用的是旧版本的 firebase 云消息传递,这是由于 firebase Core 和新的 Firebase 云消息传递版本“^9.0.0”之间存在依赖冲突


 version: 1.0.0+1
    
    environment:
      sdk: ">=2.7.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
      firebase_core: "0.7.0"
      firebase_auth: ^0.20.0+1
      flutter_spinkit: "^4.1.2"
      google_sign_in: ^4.5.3
      connectivity: ^2.0.2
      path: any
      sqflite: ^1.3.2+3
      share: ^0.6.5+4
      flutter_facebook_login: ^3.0.0
      apple_sign_in: ^0.1.0
      provider: ^4.0.1
      crypto: ^2.1.5
      in_app_purchase: ^0.5.1
      flutter_email_sender: ^5.0.0  
      scroll_snap_list: ^0.6.0
      firebase_messaging: ^5.1.2
      flutter_twitter_login:
      git: https://github.com/Kiruel/flutter_twitter_login
      cupertino_icons: ^1.0.0
    
    dev_dependencies:
      flutter_test:
        sdk: flutter

【问题讨论】:

  • 我遇到了同样的问题,尽管根据我的颤振医生说一切都很好,即 Android SDK 安装正常
  • firebase.google.com/docs/ios/setup 建议您的项目必须针对 iOS 10 或更高版本,因此我更改了平台 :ios, '12.0' 但这也没有帮助。

标签: ios firebase flutter firebase-cloud-messaging


【解决方案1】:

我终于找到了解决办法。解决方案是在 firebase 中创建 iOS 应用程序时不遵循 firebase.google.com 上的指南。您应该严格遵守https://firebase.flutter.dev/docs/overview/上的准则

回顾一下我采取的步骤:

  1. 创建了一个新的颤振项目
  2. 在 pubspec.yaml 中,在依赖项下添加了 firebase_core: "0.7.0"。酒吧得到了吗
  3. 浏览到项目目录 > iOS 文件夹 > 打开 projectname.xcworkspace
  4. 点击 Runner 并在 General 中复制 Bundle Identifier。
  5. 在“常规”选项卡的“开发信息”中将 iOS 版本更改为 10 或更高版本
  6. 将此 Bundle Identifier 粘贴到“将 Firebase 添加到您的 iOS 应用”第 1 步注册中
  7. 点击下一步并下载 GoogleService-Info.plist
  8. 在 projectname.xcworkspace 中单击 TOP 的 Runner。右键单击并按“将文件添加到 Runner”。浏览 GoogleService-Info.plist 文件。确保启用“如果需要,复制项目”复选框
  9. 完成后运行项目,无需采取任何进一步的步骤,它应该可以正常工作。

我刚刚创建了两个新项目,以确保在发布之前它可以正常工作并且可以正常工作。我希望它也对你有用。

【讨论】:

  • 这不是我的解决方案,但我希望它可以帮助一些人
【解决方案2】:

错误报告说If the Android SDK has been installed to a custom location, please use flutter config --android-sdk 更新到那个位置。`

你试过了吗?

【讨论】:

  • 我不需要 android SDK 我在 ios 上启动应用程序这不是问题。还是谢谢
【解决方案3】:

问题显然出在 Firebase 云消息包上,唯一对我有用的解决方案是升级所有 Firebase 包。

打开 Pub.dev 并搜索您拥有的每个 firebase 依赖项并更新您将使用的版本酒吧得到。最新的软件包不会引发此错误。(版本 9.0.0)。

【讨论】:

    猜你喜欢
    • 2018-11-28
    • 2021-06-11
    • 2017-04-12
    • 2020-02-04
    • 2019-08-27
    • 1970-01-01
    • 2021-08-09
    • 2020-01-30
    • 2020-05-14
    相关资源
    最近更新 更多