将 cloud_firestore 添加到 pubspec Flutter 后无法为模拟器构建应用程序

Posted

技术标签:

【中文标题】将 cloud_firestore 添加到 pubspec Flutter 后无法为模拟器构建应用程序【英文标题】:Could not build the application for the simulator after adding cloud_firestore to pubspec Flutter 【发布时间】:2020-03-30 00:00:26 【问题描述】:

我在我的 pubspec.yaml 文件中添加了依赖项,并且 pubget 运行没有错误,然后我进入 flutter run 并出现此错误,在添加任何依赖项之前,应用程序在 ios 模拟器上运行良好:

/////////////////////////////////////// /////

Launching lib/main.dart on iPhone X in debug mode...
Running pod install...                                             54.9s
Running Xcode build...                                                  

Xcode build done.                                           164.4s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/kev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/ios/Cl
    asses/CloudFirestorePlugin.m:155:24: error: no visible @interface for 'FIRQuery'
    declares the selector 'queryWhereField:arrayContainsAny:'
            query = [query queryWhereField:fieldName arrayContainsAny:value];
                     ~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/kev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/ios/Cl
    asses/CloudFirestorePlugin.m:157:24: error: no visible @interface for 'FIRQuery'
    declares the selector 'queryWhereFieldPath:arrayContainsAny:'
            query = [query queryWhereFieldPath:fieldPath arrayContainsAny:value];
                     ~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/kev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/ios/Cl
    asses/CloudFirestorePlugin.m:163:24: error: no visible @interface for 'FIRQuery'
    declares the selector 'queryWhereField:in:'
            query = [query queryWhereField:fieldName in:value];
                     ~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/kev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/ios/Cl
    asses/CloudFirestorePlugin.m:165:24: error: no visible @interface for 'FIRQuery'
    declares the selector 'queryWhereFieldPath:in:'
            query = [query queryWhereFieldPath:fieldPath in:value];
                     ~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/kev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/ios/Cl
    asses/CloudFirestorePlugin.m:764:16: warning: 'timestampsInSnapshotsEnabled' is
    deprecated [-Wdeprecated-declarations]
          settings.timestampsInSnapshotsEnabled =
          (bool)call.arguments[@"timestampsInSnapshotsEnabled"];
                   ^
    In module 'FirebaseFirestore' imported from
    /Users/kev/Documents/flutterprojects/shopapp/ios/Pods/Headers/Public/Firebase/Fireba
    se.h:45:
    /Users/kev/Documents/flutterprojects/shopapp/ios/Pods/FirebaseFirestore/Firestore/So
    urce/Public/FIRFirestoreSettings.h:69:20: note: 'timestampsInSnapshotsEnabled' has
    been explicitly marked deprecated here
        __attribute__((deprecated));
                       ^
    1 warning and 4 errors generated.
    note: Using new build systemnote: Planning buildnote: Constructing build description

Could not build the application for the simulator.
Error launching application on iPhone X.

//////////////////////////////////

这是我的 pubspec 文件的样子:

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cloud_firestore: ^0.12.11
  cupertino_icons: ^0.1.2
  firebase_core: ^0.4.2+1
  firebase_analytics: ^5.0.6
  firebase_auth: ^0.15.1

这是扑医生的结果:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.13.6 17G9016, locale en-US)

[!] android toolchain - develop for Android devices (Android SDK version 29.0.2)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 10.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.40.2)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

Github issue link

【问题讨论】:

当我从依赖项中删除 cloud_firestore 时应用程序运行 【参考方案1】:

从颤振终端,试试这个:

扑干净 cd ios pod 更新 Firebase/Firestore

现在,flutter run 将按预期运行。

【讨论】:

【参考方案2】:

在 Flutter 终端中试试这个:

cd ios pod 更新 Firebase/Firestore

在那之后对我来说效果很好。

【讨论】:

【参考方案3】:

1- 通过单击位于 ios 目录中的 Runner.xcworkspace 文件打开 iOS 项目的 xcode

2- 点击 Runner(在 xcode 的左侧)

3- 点击 Build Settings 选项卡(在 xcode 中间)

4- 例如将 iOS 部署目标 更改为 12.1

5- 保存您的操作

6- 运行 flutter clean 然后运行您的应用

【讨论】:

在 Build Settings 中,在 Deployment -> Targeted Device Family 下,选项是,(1) (2) 或 (1,2) 我在正确的地方吗? 在一般情况下,我将部署目标更改为 21.1,但不允许我保存,保存为灰色

以上是关于将 cloud_firestore 添加到 pubspec Flutter 后无法为模拟器构建应用程序的主要内容,如果未能解决你的问题,请参考以下文章

添加“cloud_firestore”时出现颤振错误

致命错误:找不到模块“cloud_firestore”

如何修复颤动的 cloud_firestore 依赖项?

添加依赖项 cloud_firestore 时,新的 Flutter 应用程序失败:^1.0.7

在 `.symlinks/plugins/cloud_firestore/ios` 中找不到 `cloud_firestore` 的 podspec

未找到模块“cloud_firestore”